diff options
Diffstat (limited to 'source/Utility/UUID.cpp')
-rw-r--r-- | source/Utility/UUID.cpp | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/source/Utility/UUID.cpp b/source/Utility/UUID.cpp index b47f8b52f1c24..98d4c30cc7f11 100644 --- a/source/Utility/UUID.cpp +++ b/source/Utility/UUID.cpp @@ -21,11 +21,10 @@ namespace lldb_private { -UUID::UUID() : m_num_uuid_bytes(16) { ::memset(m_uuid, 0, sizeof(m_uuid)); } +UUID::UUID() { Clear(); } UUID::UUID(const UUID &rhs) { - m_num_uuid_bytes = rhs.m_num_uuid_bytes; - ::memcpy(m_uuid, rhs.m_uuid, sizeof(m_uuid)); + SetBytes(rhs.m_uuid, rhs.m_num_uuid_bytes); } UUID::UUID(const void *uuid_bytes, uint32_t num_uuid_bytes) { @@ -74,14 +73,7 @@ std::string UUID::GetAsString(const char *separator) const { } void UUID::Dump(Stream *s) const { - const uint8_t *u = (const uint8_t *)GetBytes(); - s->Printf("%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%" - "2.2X%2.2X%2.2X%2.2X", - u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7], u[8], u[9], u[10], - u[11], u[12], u[13], u[14], u[15]); - if (m_num_uuid_bytes == 20) { - s->Printf("-%2.2X%2.2X%2.2X%2.2X", u[16], u[17], u[18], u[19]); - } + s->PutCString(GetAsString().c_str()); } bool UUID::SetBytes(const void *uuid_bytes, uint32_t num_uuid_bytes) { @@ -109,7 +101,7 @@ bool UUID::SetBytes(const void *uuid_bytes, uint32_t num_uuid_bytes) { return false; } -size_t UUID::GetByteSize() { return m_num_uuid_bytes; } +size_t UUID::GetByteSize() const { return m_num_uuid_bytes; } bool UUID::IsValid() const { return m_uuid[0] || m_uuid[1] || m_uuid[2] || m_uuid[3] || m_uuid[4] || @@ -198,8 +190,7 @@ bool lldb_private::operator==(const lldb_private::UUID &lhs, bool lldb_private::operator!=(const lldb_private::UUID &lhs, const lldb_private::UUID &rhs) { - return ::memcmp(lhs.GetBytes(), rhs.GetBytes(), - sizeof(lldb_private::UUID::ValueType)) != 0; + return !(lhs == rhs); } bool lldb_private::operator<(const lldb_private::UUID &lhs, @@ -210,18 +201,15 @@ bool lldb_private::operator<(const lldb_private::UUID &lhs, bool lldb_private::operator<=(const lldb_private::UUID &lhs, const lldb_private::UUID &rhs) { - return ::memcmp(lhs.GetBytes(), rhs.GetBytes(), - sizeof(lldb_private::UUID::ValueType)) <= 0; + return !(lhs > rhs); } bool lldb_private::operator>(const lldb_private::UUID &lhs, const lldb_private::UUID &rhs) { - return ::memcmp(lhs.GetBytes(), rhs.GetBytes(), - sizeof(lldb_private::UUID::ValueType)) > 0; + return rhs < lhs; } bool lldb_private::operator>=(const lldb_private::UUID &lhs, const lldb_private::UUID &rhs) { - return ::memcmp(lhs.GetBytes(), rhs.GetBytes(), - sizeof(lldb_private::UUID::ValueType)) >= 0; + return !(lhs < rhs); } |