#include <UUID.h>
Collaboration diagram for ACE_Utils::UUID:
Public Member Functions | |
UUID (void) | |
Constructor. | |
UUID (const ACE_CString &uuidString) | |
Construct a UUID from a string representation of an UUID. | |
UUID (const UUID &right) | |
~UUID (void) | |
ACE_UINT32 | time_low (void) const |
Data Members for Class Attributes. | |
void | time_low (ACE_UINT32) |
ACE_UINT16 | time_mid (void) const |
void | time_mid (ACE_UINT16) |
ACE_UINT16 | time_hi_and_version (void) const |
void | time_hi_and_version (ACE_UINT16) |
u_char | clock_seq_hi_and_reserved (void) const |
void | clock_seq_hi_and_reserved (u_char) |
u_char | clock_seq_low (void) const |
void | clock_seq_low (u_char) |
UUID_Node * | node (void) const |
void | node (UUID_Node *) |
ACE_CString * | thr_id (void) |
void | thr_id (char *) |
ACE_CString * | pid (void) |
void | pid (char *) |
const ACE_CString * | to_string (void) |
Returns a string representation of the UUID. | |
void | from_string (const ACE_CString &uuid_string) |
Set the value using a string. | |
bool | operator== (const UUID &right) const |
Equality Operations. | |
bool | operator!= (const UUID &right) const |
Static Public Attributes | |
static UUID | NIL_UUID |
Private Member Functions | |
void | from_string_i (const ACE_CString &uuid_string) |
Relational Operations. | |
UUID & | operator= (const UUID &) |
Private Attributes | |
ACE_UINT32 | time_low_ |
Data Members for Class Attributes. | |
ACE_UINT16 | time_mid_ |
ACE_UINT16 | time_hi_and_version_ |
u_char | clock_seq_hi_and_reserved_ |
u_char | clock_seq_low_ |
UUID_Node * | node_ |
bool | node_release_ |
ACE_CString | thr_id_ |
ACE_CString | pid_ |
ACE_CString * | as_string_ |
Definition at line 75 of file UUID.h.
ACE_Utils::UUID::UUID | ( | void | ) |
Constructor.
Construct a nil UUID. Such a UUID has every one of it's data elements set to zero.
Definition at line 50 of file UUID.cpp.
References ACE_NEW, and node_.
00051 : time_low_ (0), 00052 time_mid_ (0), 00053 time_hi_and_version_ (0), 00054 clock_seq_hi_and_reserved_ (0), 00055 clock_seq_low_ (0), 00056 node_ (0), 00057 node_release_ (true), 00058 as_string_ (0) 00059 { 00060 ACE_NEW (node_, 00061 UUID_Node); 00062 }
ACE_Utils::UUID::UUID | ( | const ACE_CString & | uuidString | ) |
Construct a UUID from a string representation of an UUID.
Definition at line 65 of file UUID.cpp.
References ACE_NEW, from_string_i(), and node_.
00066 : time_low_ (0), 00067 time_mid_ (0), 00068 time_hi_and_version_ (0), 00069 clock_seq_hi_and_reserved_ (0), 00070 clock_seq_low_ (0), 00071 node_ (0), 00072 node_release_ (true), 00073 as_string_ (0) 00074 { 00075 ACE_NEW (node_, 00076 UUID_Node); 00077 00078 this->from_string_i (uuid_string); 00079 }
ACE_Utils::UUID::UUID | ( | const UUID & | right | ) |
Definition at line 81 of file UUID.cpp.
References ACE_NEW, and node_.
00082 : time_low_ (right.time_low_), 00083 time_mid_ (right.time_mid_), 00084 time_hi_and_version_ (right.time_hi_and_version_), 00085 clock_seq_hi_and_reserved_ (right.clock_seq_hi_and_reserved_), 00086 clock_seq_low_ (right.clock_seq_low_), 00087 as_string_ (0) 00088 { 00089 ACE_NEW (node_, 00090 UUID_Node (*right.node_)); 00091 }
ACE_Utils::UUID::~UUID | ( | void | ) |
Definition at line 93 of file UUID.cpp.
References as_string_, node_, and node_release_.
00094 { 00095 if (node_release_) 00096 delete node_; 00097 00098 if (as_string_ != 0) 00099 delete as_string_; 00100 }
ACE_INLINE void ACE_Utils::UUID::clock_seq_hi_and_reserved | ( | u_char | ) |
Definition at line 54 of file UUID.inl.
References clock_seq_hi_and_reserved_.
00055 { 00056 this->clock_seq_hi_and_reserved_ = clock_seq_hi_and_reserved; 00057 }
ACE_INLINE u_char ACE_Utils::UUID::clock_seq_hi_and_reserved | ( | void | ) | const |
Definition at line 48 of file UUID.inl.
References clock_seq_hi_and_reserved_.
Referenced by from_string_i(), ACE_Utils::UUID_Generator::generate_UUID(), and operator==().
00049 { 00050 return this->clock_seq_hi_and_reserved_; 00051 }
ACE_INLINE void ACE_Utils::UUID::clock_seq_low | ( | u_char | ) |
Definition at line 66 of file UUID.inl.
References clock_seq_low_.
00067 { 00068 this->clock_seq_low_ = clock_seq_low; 00069 }
ACE_INLINE u_char ACE_Utils::UUID::clock_seq_low | ( | void | ) | const |
Definition at line 60 of file UUID.inl.
References clock_seq_low_.
Referenced by from_string_i(), ACE_Utils::UUID_Generator::generate_UUID(), and operator==().
00061 { 00062 return this->clock_seq_low_; 00063 }
ACE_INLINE void ACE_Utils::UUID::from_string | ( | const ACE_CString & | uuid_string | ) |
Set the value using a string.
Definition at line 112 of file UUID.inl.
References from_string_i().
00113 { 00114 this->from_string_i (uuidString); 00115 }
void ACE_Utils::UUID::from_string_i | ( | const ACE_CString & | uuid_string | ) | [private] |
Relational Operations.
Special case for the nil UUID.
Support versions 1, 3, and 4 only
Definition at line 177 of file UUID.cpp.
References ACE_ASSERT, ACE_DEBUG, ACE_ERROR, ACE_String_Base< CHAR >::c_str(), clock_seq_hi_and_reserved(), clock_seq_hi_and_reserved_, clock_seq_low(), clock_seq_low_, ACE_String_Base< CHAR >::find(), ACE_String_Base< CHAR >::length(), LM_DEBUG, LM_ERROR, NIL_UUID, node(), node_, ACE_Utils::UUID_Node::node_ID(), ACE_Utils::UUID_Node::NODE_ID_SIZE, pid_, ACE_String_Base< CHAR >::substr(), thr_id_, time_hi_and_version(), time_hi_and_version_, time_low(), time_low_, time_mid(), time_mid_, and to_string().
Referenced by from_string(), and UUID().
00178 { 00179 if (uuid_string.length () < NIL_UUID.to_string ()->length ()) 00180 { 00181 ACE_ERROR ((LM_ERROR, 00182 "%N ACE_UUID::from_string_i - " 00183 "IllegalArgument (incorrect string length)\n")); 00184 return; 00185 } 00186 00187 /// Special case for the nil UUID. 00188 if (uuid_string == *NIL_UUID.to_string ()) 00189 { 00190 bool copy_constructor_not_supported = false; 00191 ACE_ASSERT (copy_constructor_not_supported); 00192 //*this = NIL_UUID; 00193 ACE_UNUSED_ARG (copy_constructor_not_supported); 00194 return; 00195 } 00196 00197 unsigned int time_low; 00198 unsigned int time_mid; 00199 unsigned int time_hi_and_version; 00200 unsigned int clock_seq_hi_and_reserved; 00201 unsigned int clock_seq_low; 00202 unsigned int node [UUID_Node::NODE_ID_SIZE]; 00203 char thr_pid_buf [BUFSIZ]; 00204 00205 if (uuid_string.length () == NIL_UUID.to_string ()->length ()) 00206 { 00207 // This might seem quite strange this being in ACE, but it 00208 // seems to be a bit difficult to write a facade for ::sscanf 00209 // because some compilers dont support vsscanf, including 00210 // MSVC. It appears that most platforms support sscanf though 00211 // so we need to use it directly. 00212 const int nScanned = 00213 #if defined (ACE_HAS_TR24731_2005_CRT) 00214 sscanf_s ( 00215 #else 00216 ::sscanf ( 00217 #endif /* ACE_HAS_TR24731_2005_CRT */ 00218 uuid_string.c_str (), 00219 "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x", 00220 &time_low, 00221 &time_mid, 00222 &time_hi_and_version, 00223 &clock_seq_hi_and_reserved, 00224 &clock_seq_low, 00225 &node[0], 00226 &node[1], 00227 &node[2], 00228 &node[3], 00229 &node[4], 00230 &node[5] 00231 ); 00232 00233 if (nScanned != 11) 00234 { 00235 ACE_DEBUG ((LM_DEBUG, 00236 "UUID::from_string_i - " 00237 "IllegalArgument (invalid string representation)\n")); 00238 return; 00239 } 00240 } 00241 else 00242 { 00243 const int nScanned = 00244 #if defined (ACE_HAS_TR24731_2005_CRT) 00245 sscanf_s (uuid_string.c_str (), 00246 "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x-%s", 00247 &time_low, 00248 &time_mid, 00249 &time_hi_and_version, 00250 &clock_seq_hi_and_reserved, 00251 &clock_seq_low, 00252 &node[0], 00253 &node[1], 00254 &node[2], 00255 &node[3], 00256 &node[4], 00257 &node[5], 00258 thr_pid_buf, 00259 BUFSIZ 00260 ); 00261 #else 00262 ::sscanf (uuid_string.c_str (), 00263 "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x-%s", 00264 &time_low, 00265 &time_mid, 00266 &time_hi_and_version, 00267 &clock_seq_hi_and_reserved, 00268 &clock_seq_low, 00269 &node[0], 00270 &node[1], 00271 &node[2], 00272 &node[3], 00273 &node[4], 00274 &node[5], 00275 thr_pid_buf 00276 ); 00277 #endif /* ACE_HAS_TR24731_2005_CRT */ 00278 00279 if (nScanned != 12) 00280 { 00281 ACE_DEBUG ((LM_DEBUG, 00282 "ACE_UUID::from_string_i - " 00283 "IllegalArgument (invalid string representation)\n")); 00284 return; 00285 } 00286 } 00287 00288 this->time_low_ = static_cast<ACE_UINT32> (time_low); 00289 this->time_mid_ = static_cast<ACE_UINT16> (time_mid); 00290 this->time_hi_and_version_ = static_cast<ACE_UINT16> (time_hi_and_version); 00291 this->clock_seq_hi_and_reserved_ = static_cast<u_char> (clock_seq_hi_and_reserved); 00292 this->clock_seq_low_ = static_cast<u_char> (clock_seq_low); 00293 00294 UUID_Node::Node_ID node_id; 00295 for (int i = 0; i < UUID_Node::NODE_ID_SIZE; ++i) 00296 node_id [i] = static_cast<u_char> (node[i]); 00297 00298 this->node_->node_ID (node_id); 00299 00300 // Support varient 10- only 00301 if ((this->clock_seq_hi_and_reserved_ & 0xc0) != 0x80 && (this->clock_seq_hi_and_reserved_ & 0xc0) != 0xc0) 00302 { 00303 ACE_DEBUG ((LM_DEBUG, 00304 "ACE_UUID::from_string_i - " 00305 "IllegalArgument (unsupported variant)\n")); 00306 return; 00307 } 00308 00309 /// Support versions 1, 3, and 4 only 00310 ACE_UINT16 V1 = this->time_hi_and_version_; 00311 00312 if ((V1 & 0xF000) != 0x1000 && 00313 (V1 & 0xF000) != 0x3000 && 00314 (V1 & 0xF000) != 0x4000) 00315 { 00316 ACE_DEBUG ((LM_DEBUG, 00317 "ACE_UUID::from_string_i - " 00318 "IllegalArgument (unsupported version)\n")); 00319 return; 00320 } 00321 00322 if ((this->clock_seq_hi_and_reserved_ & 0xc0) == 0xc0) 00323 { 00324 if (uuid_string.length () == NIL_UUID.to_string ()->length ()) 00325 { 00326 ACE_DEBUG ((LM_DEBUG, 00327 "ACE_UUID::from_string_i - " 00328 "IllegalArgument (Missing Thread and Process Id)\n")); 00329 return; 00330 } 00331 ACE_CString thr_pid_str (thr_pid_buf); 00332 ssize_t pos = static_cast<ssize_t> (thr_pid_str.find ('-')); 00333 if (pos == -1) 00334 ACE_DEBUG ((LM_DEBUG, 00335 "ACE_UUID::from_string_i - " 00336 "IllegalArgument (Thread and Process Id format incorrect)\n")); 00337 00338 this->thr_id_ = thr_pid_str.substr (0, pos); 00339 this->pid_ = thr_pid_str.substr (pos+1, thr_pid_str.length ()-pos-1); 00340 } 00341 }
ACE_INLINE void ACE_Utils::UUID::node | ( | UUID_Node * | ) |
Definition at line 78 of file UUID.inl.
References node(), node_, and node_release_.
00079 { 00080 if (node_release_) 00081 delete node_; 00082 00083 this->node_ = node; 00084 node_release_ = false; 00085 }
ACE_INLINE UUID_Node * ACE_Utils::UUID::node | ( | void | ) | const |
Definition at line 72 of file UUID.inl.
References node_.
Referenced by from_string_i(), ACE_Utils::UUID_Generator::generate_UUID(), node(), and operator==().
00073 { 00074 return this->node_; 00075 }
ACE_INLINE bool ACE_Utils::UUID::operator!= | ( | const UUID & | right | ) | const |
ACE_INLINE bool ACE_Utils::UUID::operator== | ( | const UUID & | right | ) | const |
Equality Operations.
Definition at line 118 of file UUID.inl.
References clock_seq_hi_and_reserved(), clock_seq_low(), node(), time_hi_and_version(), time_low(), and time_mid().
00119 { 00120 if ((this->time_low_ != right.time_low ()) || 00121 (this->time_mid_ != right.time_mid ()) || 00122 (this->time_hi_and_version_ != right.time_hi_and_version ()) || 00123 (this->clock_seq_hi_and_reserved_ != right.clock_seq_hi_and_reserved ()) || 00124 (this->clock_seq_low_ != right.clock_seq_low ()) || 00125 (*this->node_ != *right.node ())) 00126 return false; 00127 00128 return true; 00129 }
ACE_INLINE void ACE_Utils::UUID::pid | ( | char * | ) |
ACE_INLINE ACE_CString * ACE_Utils::UUID::pid | ( | void | ) |
Definition at line 100 of file UUID.inl.
References pid_.
Referenced by ACE_Utils::UUID_Generator::generate_UUID().
00101 { 00102 return &this->pid_; 00103 }
ACE_INLINE void ACE_Utils::UUID::thr_id | ( | char * | ) |
ACE_INLINE ACE_CString * ACE_Utils::UUID::thr_id | ( | void | ) |
Definition at line 88 of file UUID.inl.
References thr_id_.
Referenced by ACE_Utils::UUID_Generator::generate_UUID().
00089 { 00090 return &this->thr_id_; 00091 }
ACE_INLINE void ACE_Utils::UUID::time_hi_and_version | ( | ACE_UINT16 | ) |
Definition at line 42 of file UUID.inl.
References time_hi_and_version_.
00043 { 00044 this->time_hi_and_version_ = time_hi_and_version; 00045 }
ACE_INLINE ACE_UINT16 ACE_Utils::UUID::time_hi_and_version | ( | void | ) | const |
Definition at line 36 of file UUID.inl.
References time_hi_and_version_.
Referenced by from_string_i(), ACE_Utils::UUID_Generator::generate_UUID(), and operator==().
00037 { 00038 return this->time_hi_and_version_; 00039 }
ACE_INLINE void ACE_Utils::UUID::time_low | ( | ACE_UINT32 | ) |
ACE_INLINE ACE_UINT32 ACE_Utils::UUID::time_low | ( | void | ) | const |
Data Members for Class Attributes.
Definition at line 12 of file UUID.inl.
References time_low_.
Referenced by from_string_i(), ACE_Utils::UUID_Generator::generate_UUID(), and operator==().
00013 { 00014 return this->time_low_; 00015 }
ACE_INLINE void ACE_Utils::UUID::time_mid | ( | ACE_UINT16 | ) |
ACE_INLINE ACE_UINT16 ACE_Utils::UUID::time_mid | ( | void | ) | const |
Definition at line 24 of file UUID.inl.
References time_mid_.
Referenced by from_string_i(), ACE_Utils::UUID_Generator::generate_UUID(), and operator==().
00025 { 00026 return this->time_mid_; 00027 }
const ACE_CString * ACE_Utils::UUID::to_string | ( | void | ) |
Returns a string representation of the UUID.
Only compute the string representation once.
Definition at line 103 of file UUID.cpp.
References ACE_NEW_NORETURN, ACE_NEW_RETURN, as_string_, ACE_String_Base< CHAR >::c_str(), ACE_String_Base< CHAR >::length(), pid_, ACE_OS::sprintf(), and thr_id_.
Referenced by from_string_i().
00104 { 00105 /// Only compute the string representation once. 00106 if (as_string_ == 0) 00107 { 00108 // Get a buffer exactly the correct size. Use the nil UUID as a 00109 // gauge. Don't forget the trailing nul. 00110 size_t UUID_STRING_LENGTH = 36 + thr_id_.length () + pid_.length (); 00111 char *buf = 0; 00112 00113 if ((thr_id_.length () != 0) && (pid_.length () != 0)) 00114 { 00115 UUID_STRING_LENGTH += 2; //for '-' 00116 ACE_NEW_RETURN (buf, 00117 char[UUID_STRING_LENGTH + 1], 00118 0); 00119 00120 ACE_OS::sprintf (buf, 00121 "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x-%s-%s", 00122 this->time_low_, 00123 this->time_mid_, 00124 this->time_hi_and_version_, 00125 this->clock_seq_hi_and_reserved_, 00126 this->clock_seq_low_, 00127 (this->node_->node_ID ()) [0], 00128 (this->node_->node_ID ()) [1], 00129 (this->node_->node_ID ()) [2], 00130 (this->node_->node_ID ()) [3], 00131 (this->node_->node_ID ()) [4], 00132 (this->node_->node_ID ()) [5], 00133 thr_id_.c_str (), 00134 pid_.c_str () 00135 ); 00136 } 00137 else 00138 { 00139 ACE_NEW_RETURN (buf, 00140 char[UUID_STRING_LENGTH + 1], 00141 0); 00142 00143 ACE_OS::sprintf (buf, 00144 "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x", 00145 this->time_low_, 00146 this->time_mid_, 00147 this->time_hi_and_version_, 00148 this->clock_seq_hi_and_reserved_, 00149 this->clock_seq_low_, 00150 (this->node_->node_ID ()) [0], 00151 (this->node_->node_ID ()) [1], 00152 (this->node_->node_ID ()) [2], 00153 (this->node_->node_ID ()) [3], 00154 (this->node_->node_ID ()) [4], 00155 (this->node_->node_ID ()) [5] 00156 ); 00157 } 00158 00159 // We allocated 'buf' above dynamically, so we shouldn't use 00160 // ACE_NEW_RETURN here to avoid a possible memory leak. 00161 ACE_NEW_NORETURN (this->as_string_, 00162 ACE_CString (buf, UUID_STRING_LENGTH)); 00163 00164 // we first free the dynamically allocated 'buf'. 00165 delete [] buf; 00166 00167 // then we test that ACE_NEW succeded for 'as_string_' 00168 // if not, we return 0 (NULL) to indicate failure. 00169 if (this->as_string_ == 0 ) 00170 return 0; 00171 } 00172 00173 return as_string_; 00174 }
ACE_CString* ACE_Utils::UUID::as_string_ [private] |
The string representation of the UUID. This is created and updated only on demand.
Definition at line 150 of file UUID.h.
Referenced by to_string(), and ~UUID().
u_char ACE_Utils::UUID::clock_seq_hi_and_reserved_ [private] |
Definition at line 141 of file UUID.h.
Referenced by clock_seq_hi_and_reserved(), and from_string_i().
u_char ACE_Utils::UUID::clock_seq_low_ [private] |
UUID ACE_Utils::UUID::NIL_UUID [static] |
UUID_Node* ACE_Utils::UUID::node_ [private] |
bool ACE_Utils::UUID::node_release_ [private] |
ACE_CString ACE_Utils::UUID::pid_ [private] |
ACE_CString ACE_Utils::UUID::thr_id_ [private] |
ACE_UINT16 ACE_Utils::UUID::time_hi_and_version_ [private] |
ACE_UINT32 ACE_Utils::UUID::time_low_ [private] |
Data Members for Class Attributes.
Definition at line 138 of file UUID.h.
Referenced by from_string_i(), and time_low().
ACE_UINT16 ACE_Utils::UUID::time_mid_ [private] |