mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Update uuid.cpp
code review from Tron better method for uuid toString
This commit is contained in:
parent
665fc092aa
commit
324acaf896
|
|
@ -140,26 +140,6 @@ static void create_uuid_state(uuid_state *st)
|
|||
get_pseudo_node_identifier(&st->node);
|
||||
}
|
||||
|
||||
/*
|
||||
* dav_format_opaquelocktoken - generates a text representation
|
||||
* of an opaquelocktoken
|
||||
*/
|
||||
static void format_token(char *target, const xuuid_t *u)
|
||||
{
|
||||
// first loop, figure out the size needed.
|
||||
size_t len = (size_t)snprintf(NULL, 0, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
u->time_low, u->time_mid, u->time_hi_and_version,
|
||||
u->clock_seq_hi_and_reserved, u->clock_seq_low,
|
||||
u->node[0], u->node[1], u->node[2],
|
||||
u->node[3], u->node[4], u->node[5]);
|
||||
|
||||
snprintf(target, len, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
u->time_low, u->time_mid, u->time_hi_and_version,
|
||||
u->clock_seq_hi_and_reserved, u->clock_seq_low,
|
||||
u->node[0], u->node[1], u->node[2],
|
||||
u->node[3], u->node[4], u->node[5]);
|
||||
}
|
||||
|
||||
/* convert a pair of hex digits to an integer value [0,255] */
|
||||
static int dav_parse_hexpair(const char *s)
|
||||
{
|
||||
|
|
@ -421,9 +401,16 @@ namespace Torque
|
|||
|
||||
String UUID::toString() const
|
||||
{
|
||||
char buffer[ 1024 ];
|
||||
format_token( buffer, ( xuuid_t* ) this );
|
||||
return buffer;
|
||||
const xuuid_t* u = (xuuid_t*)this;
|
||||
StringBuilder str;
|
||||
|
||||
str.format("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
u->time_low, u->time_mid, u->time_hi_and_version,
|
||||
u->clock_seq_hi_and_reserved, u->clock_seq_low,
|
||||
u->node[0], u->node[1], u->node[2],
|
||||
u->node[3], u->node[4], u->node[5]);
|
||||
|
||||
return str.end();
|
||||
}
|
||||
|
||||
bool UUID::fromString( const char* str )
|
||||
|
|
|
|||
Loading…
Reference in a new issue