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"
14 #include "lldb/lldb-types.h"
15 namespace lldb_private {
19 namespace lldb_private {
21 //----------------------------------------------------------------------
22 /// @class UserID UserID.h "lldb/Core/UserID.h"
23 /// A mix in class that contains a generic user ID.
25 /// UserID is designed as a mix in class that can contain an integer based
26 /// unique identifier for a variety of objects in lldb.
28 /// The value for this identifier is chosen by each parser plug-in. A value
29 /// should be chosen that makes sense for each kind of object and should allow
30 /// 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 user ID.
73 /// Function object that can be used on any class that inherits from UserID:
76 /// pos = std::find_if (coll.begin(), coll.end(), UserID::IDMatches(blockID));
78 //------------------------------------------------------------------
81 //--------------------------------------------------------------
82 /// Construct with the user ID to look for.
83 //--------------------------------------------------------------
84 IDMatches(lldb::user_id_t uid) : m_uid(uid) {}
86 //--------------------------------------------------------------
87 /// Unary predicate function object callback.
88 //--------------------------------------------------------------
89 bool operator()(const UserID &rhs) const { return m_uid == rhs.GetID(); }
92 //--------------------------------------------------------------
94 //--------------------------------------------------------------
95 const lldb::user_id_t m_uid; ///< The user ID we are looking for
99 //------------------------------------------------------------------
101 //------------------------------------------------------------------
102 lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object.
105 inline bool operator==(const UserID &lhs, const UserID &rhs) {
106 return lhs.GetID() == rhs.GetID();
109 inline bool operator!=(const UserID &lhs, const UserID &rhs) {
110 return lhs.GetID() != rhs.GetID();
113 //--------------------------------------------------------------
114 /// Stream the UserID object to a Stream.
115 //--------------------------------------------------------------
116 Stream &operator<<(Stream &strm, const UserID &uid);
118 } // namespace lldb_private
120 #endif // liblldb_UserID_h_