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