41 using namespace scc::crypto;
46 return os.write(u.
val().c_str(), u.
val().size());
53 const std::string
Uuid::zero =
"00000000-0000-0000-0000-000000000000";
55 void Uuid::assign(
const std::string& s)
57 std::stringstream str(s);
59 std::vector<std::string> v;
61 while (std::getline(str, tok,
'-'))
66 if (v.size() != 5) { m_uuid =
zero;
return; }
68 if (v[0].size() != 8) { m_uuid =
zero;
return; }
69 if (v[1].size() != 4) { m_uuid =
zero;
return; }
70 if (v[2].size() != 4) { m_uuid =
zero;
return; }
71 if (v[3].size() != 4) { m_uuid =
zero;
return; }
72 if (v[4].size() != 12) { m_uuid =
zero;
return; }
78 if ( ((b<
'0')||(b>
'9')) && ((b<
'a')||(b>
'f')) && ((b<
'A')||(b>
'F')) )
80 m_uuid =
zero;
return;
89 std::for_each(m_uuid.begin(), m_uuid.end(), [](
char& c)
97 std::vector<char> u(16);
109 std::stringstream uuid;
111 typedef std::vector<char> CharVec;
113 uuid << Hex::bin_to_hex(CharVec(&u[0], &u[4]));
115 uuid << Hex::bin_to_hex(CharVec(&u[4], &u[6]));
117 uuid << Hex::bin_to_hex(CharVec(&u[6], &u[8]));
119 uuid << Hex::bin_to_hex(CharVec(&u[8], &u[10]));
121 uuid << Hex::bin_to_hex(CharVec(&u[10], &u[16]));
void PrintTo(const Bignum &, std::ostream *)
Googletest printer.
static void rand_bytes(void *, int len)
Generate random bytes.
Universally unique identifier (uuid).
std::string val() const
Return the uuid value.
static const std::string zero
Zero uuid is 00000000-0000-0000-000000000000.
std::string generate()
Generate a new uuid.
Binary to hex string converter.
std::ostream & operator<<(std::ostream &, const scc::net::InetAddr &)
Print the socket address details to an output stream.
Universally Unique Identifier (uuid).