1 //===-- UUID.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 LLDB_UTILITY_UUID_H
11 #define LLDB_UTILITY_UUID_H
23 namespace lldb_private {
29 // Most UUIDs are 16 bytes, but some Linux build-ids (SHA1) are 20.
30 typedef uint8_t ValueType[20];
32 //------------------------------------------------------------------
33 // Constructors and Destructors
34 //------------------------------------------------------------------
36 UUID(const UUID &rhs);
37 UUID(const void *uuid_bytes, uint32_t num_uuid_bytes);
41 const UUID &operator=(const UUID &rhs);
45 void Dump(Stream *s) const;
47 const void *GetBytes() const;
49 size_t GetByteSize() const;
53 bool SetBytes(const void *uuid_bytes, uint32_t num_uuid_bytes = 16);
55 std::string GetAsString(const char *separator = nullptr) const;
57 size_t SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes = 16);
58 size_t SetFromCString(const char *c_str, uint32_t num_uuid_bytes = 16);
60 // Decode as many UUID bytes (up to 16) as possible from the C string "cstr"
61 // This is used for auto completion where a partial UUID might have been
63 //------------------------------------------------------------------
64 /// Decode as many UUID bytes (up to 16) as possible from the C
68 /// A NULL terminate C string that points at a UUID string value
69 /// (no leading spaces). The string must contain only hex
70 /// characters and optionally can contain the '-' sepearators.
72 /// @param[in] uuid_bytes
73 /// A buffer of bytes that will contain a full or patially
77 /// The original string, with all decoded bytes removed.
78 //------------------------------------------------------------------
79 static llvm::StringRef
80 DecodeUUIDBytesFromString(llvm::StringRef str, ValueType &uuid_bytes,
81 uint32_t &bytes_decoded,
82 uint32_t num_uuid_bytes = 16);
85 //------------------------------------------------------------------
86 // Classes that inherit from UUID can see and modify these
87 //------------------------------------------------------------------
88 uint32_t m_num_uuid_bytes; // Should be 16 or 20
92 bool operator==(const UUID &lhs, const UUID &rhs);
93 bool operator!=(const UUID &lhs, const UUID &rhs);
94 bool operator<(const UUID &lhs, const UUID &rhs);
95 bool operator<=(const UUID &lhs, const UUID &rhs);
96 bool operator>(const UUID &lhs, const UUID &rhs);
97 bool operator>=(const UUID &lhs, const UUID &rhs);
99 } // namespace lldb_private
101 #endif // LLDB_UTILITY_UUID_H