23 class _GUID_from_text :
public GUID 25 unsigned read_hex(
char c);
26 unsigned read_byte(
const char * ptr);
27 unsigned read_word(
const char * ptr);
28 unsigned read_dword(
const char * ptr);
29 void read_bytes(
unsigned char * out,
unsigned num,
const char * ptr);
32 _GUID_from_text(
const char * text);
35 unsigned _GUID_from_text::read_hex(
char c)
37 if (c>=
'0' && c<=
'9')
return (
unsigned)c -
'0';
38 else if (c>=
'a' && c<=
'f')
return 0xa + (unsigned)c -
'a';
39 else if (c>=
'A' && c<=
'F')
return 0xa + (unsigned)c -
'A';
43 unsigned _GUID_from_text::read_byte(
const char * ptr)
45 return (read_hex(ptr[0])<<4) | read_hex(ptr[1]);
47 unsigned _GUID_from_text::read_word(
const char * ptr)
49 return (read_byte(ptr)<<8) | read_byte(ptr+2);
52 unsigned _GUID_from_text::read_dword(
const char * ptr)
54 return (read_word(ptr)<<16) | read_word(ptr+4);
57 void _GUID_from_text::read_bytes(uint8_t * out,
unsigned num,
const char * ptr)
61 *out = read_byte(ptr);
67 _GUID_from_text::_GUID_from_text(
const char * text)
69 if (*text==
'{') text++;
73 const char * t = strchr(text,
'}');
75 else max = text + strlen(text);
82 if (text+8>max)
break;
83 Data1 = read_dword(text);
85 while(*text==
'-') text++;
86 if (text+4>max)
break;
87 Data2 = read_word(text);
89 while(*text==
'-') text++;
90 if (text+4>max)
break;
91 Data3 = read_word(text);
93 while(*text==
'-') text++;
94 if (text+4>max)
break;
95 read_bytes(Data4,2,text);
97 while(*text==
'-') text++;
98 if (text+12>max)
break;
99 read_bytes(Data4+2,6,text);
107 return _GUID_from_text( text );
112 static const char table[16] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F'};
113 PFC_ASSERT((val & ~0xF) == 0);
117 static void print_hex(
unsigned val,
char * &out,
unsigned bytes)
122 unsigned char c = (
unsigned char)((val >> ((bytes - 1 - n) << 3)) & 0xFF);
130 print_guid::print_guid(
const GUID & p_guid)
155 const unsigned char * in = (
const unsigned char *) buffer;
164 if (FAILED(CoCreateGuid( & out ) ) )
crash();
175 const GUID pfc::guid_null = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
void nixGetRandomData(void *outPtr, size_t outBytes)
static void print_hex(unsigned val, char *&out, unsigned bytes)
GUID GUID_from_text(const char *text)
static char print_hex_digit(unsigned val)
void print_hex_raw(const void *buffer, unsigned bytes, char *p_out)