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 //===----------------------------------------------------------------------===//
11 #ifndef liblldb_UserID_h_
12 #define liblldb_UserID_h_
14 #include "lldb/lldb-private.h"
16 namespace lldb_private {
18 //----------------------------------------------------------------------
19 /// @class UserID UserID.h "lldb/Core/UserID.h"
20 /// @brief A mix in class that contains a generic user ID.
22 /// UserID is desinged as a mix in class that can contain an integer
23 /// based unique identifier for a varietly of objects in lldb.
25 /// The value for this identifier is chosen by each parser plug-in. A
26 /// value should be chosen that makes sense for each kind of object
27 /// should and allows quick access to further and more in depth parsing.
29 /// Symbol table entries can use this to store the original symbol table
30 /// index, functions can use it to store the symbol table index or the
32 //----------------------------------------------------------------------
35 //------------------------------------------------------------------
36 /// Construct with optional user ID.
37 //------------------------------------------------------------------
38 UserID (lldb::user_id_t uid = LLDB_INVALID_UID) : m_uid(uid) {}
40 //------------------------------------------------------------------
42 //------------------------------------------------------------------
47 //------------------------------------------------------------------
48 /// Clears the object state.
50 /// Clears the object contents back to a default invalid state.
51 //------------------------------------------------------------------
53 Clear () { m_uid = LLDB_INVALID_UID; }
55 //------------------------------------------------------------------
56 /// Get accessor for the user ID.
60 //------------------------------------------------------------------
62 GetID () const { return m_uid; }
64 //------------------------------------------------------------------
65 /// Set accessor for the user ID.
69 //------------------------------------------------------------------
71 SetID (lldb::user_id_t uid) { m_uid = uid; }
73 //------------------------------------------------------------------
74 /// Unary predicate function object that can search for a matching
77 /// Function object that can be used on any class that inherits
81 /// pos = std::find_if (coll.begin(), coll.end(), UserID::IDMatches(blockID));
83 //------------------------------------------------------------------
87 //--------------------------------------------------------------
88 /// Construct with the user ID to look for.
89 //--------------------------------------------------------------
90 IDMatches (lldb::user_id_t uid) : m_uid(uid) {}
92 //--------------------------------------------------------------
93 /// Unary predicate function object callback.
94 //--------------------------------------------------------------
96 operator () (const UserID& rhs) const { return m_uid == rhs.GetID(); }
99 //--------------------------------------------------------------
101 //--------------------------------------------------------------
102 const lldb::user_id_t m_uid; ///< The user ID we are looking for
107 //------------------------------------------------------------------
109 //------------------------------------------------------------------
110 lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object.
113 inline bool operator== (const UserID& lhs, const UserID& rhs)
115 return lhs.GetID() == rhs.GetID();
118 inline bool operator!= (const UserID& lhs, const UserID& rhs)
120 return lhs.GetID() != rhs.GetID();
123 //--------------------------------------------------------------
124 /// Stream the UserID object to a Stream.
125 //--------------------------------------------------------------
126 Stream& operator << (Stream& strm, const UserID& uid);
128 } // namespace lldb_private
130 #endif // liblldb_UserID_h_