Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:59

0001 //===-- UserID.h ------------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_UTILITY_USERID_H
0010 #define LLDB_UTILITY_USERID_H
0011 
0012 #include "lldb/lldb-defines.h"
0013 #include "lldb/lldb-types.h"
0014 
0015 namespace lldb_private {
0016 class Stream;
0017 
0018 /// \class UserID UserID.h "lldb/Core/UserID.h"
0019 /// A mix in class that contains a generic user ID.
0020 ///
0021 /// UserID is designed as a mix in class that can contain an integer based
0022 /// unique identifier for a variety of objects in lldb.
0023 ///
0024 /// The value for this identifier is chosen by each parser plug-in. A value
0025 /// should be chosen that makes sense for each kind of object and should allow
0026 /// quick access to further and more in depth parsing.
0027 ///
0028 /// Symbol table entries can use this to store the original symbol table
0029 /// index, functions can use it to store the symbol table index or the
0030 /// DWARF offset.
0031 struct UserID {
0032   /// Construct with optional user ID.
0033   UserID(lldb::user_id_t uid = LLDB_INVALID_UID) : m_uid(uid) {}
0034 
0035   /// Destructor.
0036   ~UserID() = default;
0037 
0038   /// Clears the object state.
0039   ///
0040   /// Clears the object contents back to a default invalid state.
0041   void Clear() { m_uid = LLDB_INVALID_UID; }
0042 
0043   /// Get accessor for the user ID.
0044   ///
0045   /// \return
0046   ///     The user ID.
0047   lldb::user_id_t GetID() const { return m_uid; }
0048 
0049   /// Set accessor for the user ID.
0050   ///
0051   /// \param[in] uid
0052   ///     The new user ID.
0053   void SetID(lldb::user_id_t uid) { m_uid = uid; }
0054 
0055   /// Unary predicate function object that can search for a matching user ID.
0056   ///
0057   /// Function object that can be used on any class that inherits from UserID:
0058   /// \code
0059   /// iterator pos;
0060   /// pos = std::find_if (coll.begin(), coll.end(), UserID::IDMatches(blockID));
0061   /// \endcode
0062   class IDMatches {
0063   public:
0064     /// Construct with the user ID to look for.
0065     IDMatches(lldb::user_id_t uid) : m_uid(uid) {}
0066 
0067     /// Unary predicate function object callback.
0068     bool operator()(const UserID &rhs) const { return m_uid == rhs.GetID(); }
0069 
0070   private:
0071     // Member variables.
0072     const lldb::user_id_t m_uid; ///< The user ID we are looking for
0073   };
0074 
0075 protected:
0076   // Member variables.
0077   lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object.
0078 };
0079 
0080 inline bool operator==(const UserID &lhs, const UserID &rhs) {
0081   return lhs.GetID() == rhs.GetID();
0082 }
0083 
0084 inline bool operator!=(const UserID &lhs, const UserID &rhs) {
0085   return lhs.GetID() != rhs.GetID();
0086 }
0087 
0088 /// Stream the UserID object to a Stream.
0089 Stream &operator<<(Stream &strm, const UserID &uid);
0090 
0091 } // namespace lldb_private
0092 
0093 #endif // LLDB_UTILITY_USERID_H