]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Utility/UUID.h
MFV r337586: lua: Update to 5.3.5
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Utility / UUID.h
1 //===-- UUID.h --------------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLDB_UTILITY_UUID_H
11 #define LLDB_UTILITY_UUID_H
12
13 // C Includes
14 // C++ Includes
15 #include <stddef.h>
16 #include <stdint.h>
17 #include <string>
18
19 namespace llvm {
20   class StringRef;
21 }
22
23 namespace lldb_private {
24
25   class Stream;
26
27 class UUID {
28 public:
29   // Most UUIDs are 16 bytes, but some Linux build-ids (SHA1) are 20.
30   typedef uint8_t ValueType[20];
31
32   //------------------------------------------------------------------
33   // Constructors and Destructors
34   //------------------------------------------------------------------
35   UUID();
36   UUID(const UUID &rhs);
37   UUID(const void *uuid_bytes, uint32_t num_uuid_bytes);
38
39   ~UUID();
40
41   const UUID &operator=(const UUID &rhs);
42
43   void Clear();
44
45   void Dump(Stream *s) const;
46
47   const void *GetBytes() const;
48
49   size_t GetByteSize() const;
50
51   bool IsValid() const;
52
53   bool SetBytes(const void *uuid_bytes, uint32_t num_uuid_bytes = 16);
54
55   std::string GetAsString(const char *separator = nullptr) const;
56
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);
59
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
62   // typed in. It
63   //------------------------------------------------------------------
64   /// Decode as many UUID bytes (up to 16) as possible from the C
65   /// string \a cstr.
66   ///
67   /// @param[in] cstr
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.
71   ///
72   /// @param[in] uuid_bytes
73   ///     A buffer of bytes that will contain a full or patially
74   ///     decoded UUID.
75   ///
76   /// @return
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);
83
84 protected:
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
89   ValueType m_uuid;
90 };
91
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);
98
99 } // namespace lldb_private
100
101 #endif // LLDB_UTILITY_UUID_H