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