]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Core/UUID.h
Update llvm to trunk r256945.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Core / 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 liblldb_UUID_h_
11 #define liblldb_UUID_h_
12
13 // C Includes
14 // C++ Includes
15 #include <string>
16
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/lldb-private.h"
20
21 namespace lldb_private {
22
23 class UUID
24 {
25 public:
26     // Most UUIDs are 16 bytes, but some Linux build-ids (SHA1) are 20.
27     typedef uint8_t ValueType[20];
28
29     //------------------------------------------------------------------
30     // Constructors and Destructors
31     //------------------------------------------------------------------
32     UUID ();
33     UUID (const UUID& rhs);
34     UUID (const void *uuid_bytes, uint32_t num_uuid_bytes);
35
36     ~UUID ();
37
38     const UUID&
39     operator=(const UUID& rhs);
40
41     void
42     Clear ();
43
44     void
45     Dump (Stream *s) const;
46
47     const void *
48     GetBytes() const;
49
50     size_t
51     GetByteSize();
52
53     bool
54     IsValid () const;
55
56     bool
57     SetBytes (const void *uuid_bytes, uint32_t num_uuid_bytes = 16);
58
59     std::string
60     GetAsString(const char *separator = nullptr) const;
61
62     size_t
63     SetFromCString (const char *c_str, uint32_t num_uuid_bytes = 16);
64
65     // Decode as many UUID bytes (up to 16) as possible from the C string "cstr"
66     // This is used for auto completion where a partial UUID might have been
67     // typed in. It 
68     //------------------------------------------------------------------
69     /// Decode as many UUID bytes (up to 16) as possible from the C
70     /// string \a cstr.
71     ///
72     /// @param[in] cstr
73     ///     A NULL terminate C string that points at a UUID string value
74     ///     (no leading spaces). The string must contain only hex
75     ///     characters and optionally can contain the '-' sepearators.
76     ///
77     /// @param[in] uuid_bytes
78     ///     A buffer of bytes that will contain a full or patially
79     ///     decoded UUID.
80     ///
81     /// @param[out] end
82     ///     If \a end is not nullptr, it will be filled in with the a
83     ///     pointer to the character after the last successfully decoded
84     ///     byte.
85     ///
86     /// @return
87     ///     Returns the number of bytes that were successfully decoded
88     ///     which should be 16 if a full UUID value was properly decoded.
89     //------------------------------------------------------------------
90     static size_t
91     DecodeUUIDBytesFromCString (const char *cstr, ValueType &uuid_bytes, const char **end, uint32_t num_uuid_bytes = 16);
92     
93 protected:
94     //------------------------------------------------------------------
95     // Classes that inherit from UUID can see and modify these
96     //------------------------------------------------------------------
97     uint32_t m_num_uuid_bytes; // Should be 16 or 20
98     ValueType m_uuid;
99 };
100
101 bool operator == (const UUID &lhs, const UUID &rhs);
102 bool operator != (const UUID &lhs, const UUID &rhs);
103 bool operator <  (const UUID &lhs, const UUID &rhs);
104 bool operator <= (const UUID &lhs, const UUID &rhs);
105 bool operator >  (const UUID &lhs, const UUID &rhs);
106 bool operator >= (const UUID &lhs, const UUID &rhs);
107
108 } // namespace lldb_private
109
110 #endif  // liblldb_UUID_h_