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