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