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-private.h"
15 namespace lldb_private {
17 //----------------------------------------------------------------------
18 /// @class UserID UserID.h "lldb/Core/UserID.h"
19 /// @brief A mix in class that contains a generic user ID.
21 /// UserID is designed as a mix in class that can contain an integer
22 /// based unique identifier for a variety of objects in lldb.
24 /// The value for this identifier is chosen by each parser plug-in. A
25 /// value should be chosen that makes sense for each kind of object
26 /// and should allow quick access to further and more in depth parsing.
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
31 //----------------------------------------------------------------------
33 //------------------------------------------------------------------
34 /// Construct with optional user ID.
35 //------------------------------------------------------------------
36 UserID(lldb::user_id_t uid = LLDB_INVALID_UID) : m_uid(uid) {}
38 //------------------------------------------------------------------
40 //------------------------------------------------------------------
43 //------------------------------------------------------------------
44 /// Clears the object state.
46 /// Clears the object contents back to a default invalid state.
47 //------------------------------------------------------------------
48 void Clear() { m_uid = LLDB_INVALID_UID; }
50 //------------------------------------------------------------------
51 /// Get accessor for the user ID.
55 //------------------------------------------------------------------
56 lldb::user_id_t GetID() const { return m_uid; }
58 //------------------------------------------------------------------
59 /// Set accessor for the user ID.
63 //------------------------------------------------------------------
64 void SetID(lldb::user_id_t uid) { m_uid = uid; }
66 //------------------------------------------------------------------
67 /// Unary predicate function object that can search for a matching
70 /// Function object that can be used on any class that inherits
74 /// pos = std::find_if (coll.begin(), coll.end(), UserID::IDMatches(blockID));
76 //------------------------------------------------------------------
79 //--------------------------------------------------------------
80 /// Construct with the user ID to look for.
81 //--------------------------------------------------------------
82 IDMatches(lldb::user_id_t uid) : m_uid(uid) {}
84 //--------------------------------------------------------------
85 /// Unary predicate function object callback.
86 //--------------------------------------------------------------
87 bool operator()(const UserID &rhs) const { return m_uid == rhs.GetID(); }
90 //--------------------------------------------------------------
92 //--------------------------------------------------------------
93 const lldb::user_id_t m_uid; ///< The user ID we are looking for
97 //------------------------------------------------------------------
99 //------------------------------------------------------------------
100 lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object.
103 inline bool operator==(const UserID &lhs, const UserID &rhs) {
104 return lhs.GetID() == rhs.GetID();
107 inline bool operator!=(const UserID &lhs, const UserID &rhs) {
108 return lhs.GetID() != rhs.GetID();
111 //--------------------------------------------------------------
112 /// Stream the UserID object to a Stream.
113 //--------------------------------------------------------------
114 Stream &operator<<(Stream &strm, const UserID &uid);
116 } // namespace lldb_private
118 #endif // liblldb_UserID_h_