1 //===-- UserID.h ------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_UserID_h_
11 #define liblldb_UserID_h_
13 #include "lldb/lldb-defines.h" // for LLDB_INVALID_UID
14 #include "lldb/lldb-types.h" // for user_id_t
15 namespace lldb_private {
19 namespace lldb_private {
21 //----------------------------------------------------------------------
22 /// @class UserID UserID.h "lldb/Core/UserID.h"
23 /// @brief A mix in class that contains a generic user ID.
25 /// UserID is designed as a mix in class that can contain an integer
26 /// based unique identifier for a variety of objects in lldb.
28 /// The value for this identifier is chosen by each parser plug-in. A
29 /// value should be chosen that makes sense for each kind of object
30 /// and should allow quick access to further and more in depth parsing.
32 /// Symbol table entries can use this to store the original symbol table
33 /// index, functions can use it to store the symbol table index or the
35 //----------------------------------------------------------------------
37 //------------------------------------------------------------------
38 /// Construct with optional user ID.
39 //------------------------------------------------------------------
40 UserID(lldb::user_id_t uid = LLDB_INVALID_UID) : m_uid(uid) {}
42 //------------------------------------------------------------------
44 //------------------------------------------------------------------
47 //------------------------------------------------------------------
48 /// Clears the object state.
50 /// Clears the object contents back to a default invalid state.
51 //------------------------------------------------------------------
52 void Clear() { m_uid = LLDB_INVALID_UID; }
54 //------------------------------------------------------------------
55 /// Get accessor for the user ID.
59 //------------------------------------------------------------------
60 lldb::user_id_t GetID() const { return m_uid; }
62 //------------------------------------------------------------------
63 /// Set accessor for the user ID.
67 //------------------------------------------------------------------
68 void SetID(lldb::user_id_t uid) { m_uid = uid; }
70 //------------------------------------------------------------------
71 /// Unary predicate function object that can search for a matching
74 /// Function object that can be used on any class that inherits
78 /// pos = std::find_if (coll.begin(), coll.end(), UserID::IDMatches(blockID));
80 //------------------------------------------------------------------
83 //--------------------------------------------------------------
84 /// Construct with the user ID to look for.
85 //--------------------------------------------------------------
86 IDMatches(lldb::user_id_t uid) : m_uid(uid) {}
88 //--------------------------------------------------------------
89 /// Unary predicate function object callback.
90 //--------------------------------------------------------------
91 bool operator()(const UserID &rhs) const { return m_uid == rhs.GetID(); }
94 //--------------------------------------------------------------
96 //--------------------------------------------------------------
97 const lldb::user_id_t m_uid; ///< The user ID we are looking for
101 //------------------------------------------------------------------
103 //------------------------------------------------------------------
104 lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object.
107 inline bool operator==(const UserID &lhs, const UserID &rhs) {
108 return lhs.GetID() == rhs.GetID();
111 inline bool operator!=(const UserID &lhs, const UserID &rhs) {
112 return lhs.GetID() != rhs.GetID();
115 //--------------------------------------------------------------
116 /// Stream the UserID object to a Stream.
117 //--------------------------------------------------------------
118 Stream &operator<<(Stream &strm, const UserID &uid);
120 } // namespace lldb_private
122 #endif // liblldb_UserID_h_