LLDB mainline
UserID.h
Go to the documentation of this file.
1//===-- UserID.h ------------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_UTILITY_USERID_H
10#define LLDB_UTILITY_USERID_H
11
12#include "lldb/lldb-defines.h"
13#include "lldb/lldb-types.h"
14
15namespace lldb_private {
16class Stream;
17
18/// \class UserID UserID.h "lldb/Core/UserID.h"
19/// A mix in class that contains a generic user ID.
20///
21/// UserID is designed as a mix in class that can contain an integer based
22/// unique identifier for a variety of objects in lldb.
23///
24/// The value for this identifier is chosen by each parser plug-in. A value
25/// should be chosen that makes sense for each kind of object and should allow
26/// quick access to further and more in depth parsing.
27///
28/// Symbol table entries can use this to store the original symbol table
29/// index, functions can use it to store the symbol table index or the
30/// DWARF offset.
31struct UserID {
32 /// Construct with optional user ID.
34
35 /// Destructor.
36 ~UserID() = default;
37
38 /// Clears the object state.
39 ///
40 /// Clears the object contents back to a default invalid state.
42
43 /// Get accessor for the user ID.
44 ///
45 /// \return
46 /// The user ID.
47 lldb::user_id_t GetID() const { return m_uid; }
48
49 /// Set accessor for the user ID.
50 ///
51 /// \param[in] uid
52 /// The new user ID.
53 void SetID(lldb::user_id_t uid) { m_uid = uid; }
54
55 /// Unary predicate function object that can search for a matching user ID.
56 ///
57 /// Function object that can be used on any class that inherits from UserID:
58 /// \code
59 /// iterator pos;
60 /// pos = std::find_if (coll.begin(), coll.end(), UserID::IDMatches(blockID));
61 /// \endcode
62 class IDMatches {
63 public:
64 /// Construct with the user ID to look for.
66
67 /// Unary predicate function object callback.
68 bool operator()(const UserID &rhs) const { return m_uid == rhs.GetID(); }
69
70 private:
71 // Member variables.
72 const lldb::user_id_t m_uid; ///< The user ID we are looking for
73 };
74
75protected:
76 // Member variables.
77 lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object.
78};
79
80inline bool operator==(const UserID &lhs, const UserID &rhs) {
81 return lhs.GetID() == rhs.GetID();
82}
83
84inline bool operator!=(const UserID &lhs, const UserID &rhs) {
85 return lhs.GetID() != rhs.GetID();
86}
87
88/// Stream the UserID object to a Stream.
89Stream &operator<<(Stream &strm, const UserID &uid);
90
91} // namespace lldb_private
92
93#endif // LLDB_UTILITY_USERID_H
Unary predicate function object that can search for a matching user ID.
Definition: UserID.h:62
IDMatches(lldb::user_id_t uid)
Construct with the user ID to look for.
Definition: UserID.h:65
const lldb::user_id_t m_uid
The user ID we are looking for.
Definition: UserID.h:72
bool operator()(const UserID &rhs) const
Unary predicate function object callback.
Definition: UserID.h:68
#define LLDB_INVALID_UID
Definition: lldb-defines.h:88
A class that represents a running process on the host machine.
bool operator!=(const Address &lhs, const Address &rhs)
Definition: Address.cpp:1029
Stream & operator<<(Stream &s, const Mangled &obj)
bool operator==(const Address &lhs, const Address &rhs)
Definition: Address.cpp:1023
uint64_t user_id_t
Definition: lldb-types.h:82
A mix in class that contains a generic user ID.
Definition: UserID.h:31
~UserID()=default
Destructor.
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
Definition: UserID.h:33
lldb::user_id_t m_uid
The user ID that uniquely identifies an object.
Definition: UserID.h:77
void Clear()
Clears the object state.
Definition: UserID.h:41
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
void SetID(lldb::user_id_t uid)
Set accessor for the user ID.
Definition: UserID.h:53