… | |
… | |
93 | |
93 | |
94 | struct UUID |
94 | struct UUID |
95 | { |
95 | { |
96 | uint64 seq; |
96 | uint64 seq; |
97 | |
97 | |
|
|
98 | enum { MAX_LEN = 3 + 16 + 1 + 1 }; // <1. + hex + > + \0 |
|
|
99 | |
98 | static UUID cur; // last uuid generated |
100 | static UUID cur; // last uuid generated |
99 | static void init (); |
101 | static void init (); |
100 | static UUID gen (); |
102 | static UUID gen (); |
101 | |
103 | |
102 | UUID () { } |
104 | UUID () { } |
103 | UUID (uint64 seq) : seq(seq) { } |
105 | UUID (uint64 seq) : seq(seq) { } |
104 | operator uint64() { return seq; } |
106 | operator uint64() { return seq; } |
105 | void operator =(uint64 seq) { this->seq = seq; } |
107 | void operator =(uint64 seq) { this->seq = seq; } |
106 | |
108 | |
107 | typedef char BUF [32]; |
|
|
108 | |
|
|
109 | bool parse (const char *s) |
109 | bool parse (const char *s); |
110 | { |
110 | char *append (char *buf) const; |
111 | return sscanf (s, "<1.%" SCNx64 ">", &seq) == 1; |
|
|
112 | } |
|
|
113 | |
|
|
114 | const char *c_str (char *buf, int len) const |
|
|
115 | { |
|
|
116 | snprintf (buf, len, "<1.%" PRIx64 ">", seq); |
|
|
117 | |
|
|
118 | return buf; |
|
|
119 | } |
|
|
120 | |
|
|
121 | const char *c_str () const |
111 | char *c_str () const; |
122 | { |
|
|
123 | static BUF buf; |
|
|
124 | |
|
|
125 | return c_str (buf, sizeof (buf)); |
|
|
126 | } |
|
|
127 | }; |
112 | }; |
128 | |
113 | |
129 | //+GPL |
114 | //+GPL |
130 | |
115 | |
131 | /* Definition for WILL_APPLY values. Replaces having harcoded values |
116 | /* Definition for WILL_APPLY values. Replaces having harcoded values |