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 
15 namespace lldb_private {
16 class 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.
31 struct 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 
75 protected:
76  // Member variables.
77  lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object.
78 };
79 
80 inline bool operator==(const UserID &lhs, const UserID &rhs) {
81  return lhs.GetID() == rhs.GetID();
82 }
83 
84 inline bool operator!=(const UserID &lhs, const UserID &rhs) {
85  return lhs.GetID() != rhs.GetID();
86 }
87 
88 /// Stream the UserID object to a Stream.
89 Stream &operator<<(Stream &strm, const UserID &uid);
90 
91 } // namespace lldb_private
92 
93 #endif // LLDB_UTILITY_USERID_H
lldb_private::UserID::Clear
void Clear()
Clears the object state.
Definition: UserID.h:41
lldb_private::UserID::IDMatches
Unary predicate function object that can search for a matching user ID.
Definition: UserID.h:62
lldb_private::UserID::IDMatches::m_uid
const lldb::user_id_t m_uid
The user ID we are looking for.
Definition: UserID.h:72
lldb-defines.h
lldb_private::UserID
Definition: UserID.h:31
LLDB_INVALID_UID
#define LLDB_INVALID_UID
Definition: lldb-defines.h:92
lldb_private::UserID::SetID
void SetID(lldb::user_id_t uid)
Set accessor for the user ID.
Definition: UserID.h:53
lldb_private::UserID::IDMatches::IDMatches
IDMatches(lldb::user_id_t uid)
Construct with the user ID to look for.
Definition: UserID.h:65
lldb_private::operator==
bool operator==(const Address &lhs, const Address &rhs)
Definition: Address.cpp:999
lldb_private::UserID::IDMatches::operator()
bool operator()(const UserID &rhs) const
Unary predicate function object callback.
Definition: UserID.h:68
lldb_private::operator!=
bool operator!=(const Address &lhs, const Address &rhs)
Definition: Address.cpp:1005
lldb_private::UserID::GetID
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
lldb-types.h
lldb_private::operator<<
Stream & operator<<(Stream &s, const SourceLocationSpec &loc)
Dump a SourceLocationSpec object to a stream.
Definition: SourceLocationSpec.cpp:40
lldb_private::UserID::~UserID
~UserID()=default
Destructor.
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::UserID::UserID
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
Definition: UserID.h:33
lldb_private::UserID::m_uid
lldb::user_id_t m_uid
The user ID that uniquely identifies an object.
Definition: UserID.h:77