Represents a globally unique identifier (GUID). A GUID is a 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required. Such an identifier has a very low probability of being duplicated.
- Namespace
- xtd
- Library
- xtd.core
- Examples
- The following code example demonstrates the use of xtd::guid struct.
#include <xtd/console>
#include <xtd/guid>
auto main() -> int {
for (auto counter = 0; counter < 10; ++counter)
}
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
static guid new_guid() noexcept
Initializes a new instance of the xtd::guid structure.
- Examples
- system_exception.cpp.
|
static const guid | empty |
| Gets A read-only instance of the xtd::guid structure whose value is all zeros.
|
|
|
| guid ()=default |
| Initializes a new instance of the xtd::guid structure.
|
|
| guid (const std::vector< xtd::byte > &data) |
| Initializes a new instance of the xtd::guid structure by using the specified array of bytes.
|
|
| guid (const std::initializer_list< xtd::byte > &data) |
| Initializes a new instance of the xtd::guid structure by using the specified array of bytes.
|
|
| guid (int32 a, int16 b, int16 c, const std::vector< xtd::byte > &d) |
| Initializes a new instance of the xtd::guid structure by using the specified integers and byte array.
|
|
| guid (uint32 a, uint16 b, uint16 c, const std::vector< xtd::byte > &d) |
| Initializes a new instance of the xtd::guid structure by using the specified unsigned integers and byte array.
|
|
| guid (int32 a, int16 b, int16 c, xtd::byte d, xtd::byte e, xtd::byte f, xtd::byte g, xtd::byte h, xtd::byte i, xtd::byte j, xtd::byte k) noexcept |
| Initializes a new instance of the xtd::guid structure by using the specified integers and bytes.
|
|
| guid (uint32 a, uint16 b, uint16 c, xtd::byte d, xtd::byte e, xtd::byte f, xtd::byte g, xtd::byte h, xtd::byte i, xtd::byte j, xtd::byte k) noexcept |
| Initializes a new instance of the xtd::guid structure by using the specified unsigned integers and bytes.
|
|
| guid (const string &guid) |
| Initializes a new instance of the xtd::guid structure by using the value represented by the specified string.
|
|
|
int32 | compare_to (const guid &value) const noexcept override |
| Compares the current instance with another object of the same type.
|
|
bool | equals (const guid &g) const noexcept override |
| Indicates whether the current object is equal to another object of the same type.
|
|
const std::vector< xtd::byte > & | to_byte_array () const noexcept |
| Returns a 16-element byte array that contains the value of this instance.
|
|
xtd::string | to_string () const noexcept override |
| Returns a string representation of the value of this instance in registry format.
|
|
string | to_string (const string &format) const |
| Returns a string representation of the value of this xtd::guid instance, according to the provided format specifier.
|
|
string | to_string (const string &format, const std::locale &loc) const override |
| Returns a string representation of the value of this xtd::guid instance, according to the provided format specifier, and locale.
|
|
virtual bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object.
|
|
template<typename object_a_t , typename object_b_t > |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are considered equal.
|
|
|
| object ()=default |
| Create a new instance of the ultimate base class object.
|
|
virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type.
|
|
virtual type_object | get_type () const noexcept |
| Gets the type of the current instance.
|
|
template<typename object_t > |
xtd::uptr< object_t > | memberwise_clone () const |
| Creates a shallow copy of the current object.
|
|
template<typename object_a_t , typename object_b_t > |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are considered equal.
|
|
template<typename object_a_t , typename object_b_t > |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are the same instance.
|
|
◆ guid() [1/8]
Initializes a new instance of the xtd::guid structure.
◆ guid() [2/8]
xtd::guid::guid |
( |
const std::vector< xtd::byte > & |
data | ) |
|
|
explicit |
Initializes a new instance of the xtd::guid structure by using the specified array of bytes.
- Parameters
-
bytes | A 16-element byte array containing values with which to initialize the GUID. |
- Exceptions
-
◆ guid() [3/8]
xtd::guid::guid |
( |
const std::initializer_list< xtd::byte > & |
data | ) |
|
|
explicit |
Initializes a new instance of the xtd::guid structure by using the specified array of bytes.
- Parameters
-
bytes | A 16-element byte array containing values with which to initialize the GUID. |
- Exceptions
-
◆ guid() [4/8]
Initializes a new instance of the xtd::guid structure by using the specified integers and byte array.
- Parameters
-
a | The first 4 bytes of the GUID. |
b | The next 2 bytes of the GUID. |
c | The next 2 bytes of the GUID. |
d | The remaining 8 bytes of the GUID. |
- Exceptions
-
Initializes a new instance of the xtd::guid structure by using the specified integers and byte array.
- Parameters
-
a | The first 4 bytes of the GUID. |
b | The next 2 bytes of the GUID. |
c | The next 2 bytes of the GUID. |
d | The remaining 8 bytes of the GUID. |
- Exceptions
-
◆ guid() [5/8]
Initializes a new instance of the xtd::guid structure by using the specified unsigned integers and byte array.
- Parameters
-
a | The first 4 bytes of the GUID. |
b | The next 2 bytes of the GUID. |
c | The next 2 bytes of the GUID. |
d | The remaining 8 bytes of the GUID. |
- Exceptions
-
Initializes a new instance of the xtd::guid structure by using the specified integers and byte array.
- Parameters
-
a | The first 4 bytes of the GUID. |
b | The next 2 bytes of the GUID. |
c | The next 2 bytes of the GUID. |
d | The remaining 8 bytes of the GUID. |
- Exceptions
-
◆ guid() [6/8]
xtd::guid::guid |
( |
int32 |
a, |
|
|
int16 |
b, |
|
|
int16 |
c, |
|
|
xtd::byte |
d, |
|
|
xtd::byte |
e, |
|
|
xtd::byte |
f, |
|
|
xtd::byte |
g, |
|
|
xtd::byte |
h, |
|
|
xtd::byte |
i, |
|
|
xtd::byte |
j, |
|
|
xtd::byte |
k |
|
) |
| |
|
noexcept |
Initializes a new instance of the xtd::guid structure by using the specified integers and bytes.
- Parameters
-
a | The first 4 bytes of the GUID. |
b | The next 2 bytes of the GUID. |
c | The next 2 bytes of the GUID. |
d | The next byte of the GUID. |
e | The next byte of the GUID. |
f | The next byte of the GUID. |
g | The next byte of the GUID. |
h | The next byte of the GUID. |
i | The next byte of the GUID. |
j | The next byte of the GUID. |
k | The next byte of the GUID. |
◆ guid() [7/8]
xtd::guid::guid |
( |
uint32 |
a, |
|
|
uint16 |
b, |
|
|
uint16 |
c, |
|
|
xtd::byte |
d, |
|
|
xtd::byte |
e, |
|
|
xtd::byte |
f, |
|
|
xtd::byte |
g, |
|
|
xtd::byte |
h, |
|
|
xtd::byte |
i, |
|
|
xtd::byte |
j, |
|
|
xtd::byte |
k |
|
) |
| |
|
noexcept |
Initializes a new instance of the xtd::guid structure by using the specified unsigned integers and bytes.
- Parameters
-
a | The first 4 bytes of the GUID. |
b | The next 2 bytes of the GUID. |
c | The next 2 bytes of the GUID. |
d | The next byte of the GUID. |
e | The next byte of the GUID. |
f | The next byte of the GUID. |
g | The next byte of the GUID. |
h | The next byte of the GUID. |
i | The next byte of the GUID. |
j | The next byte of the GUID. |
k | The next byte of the GUID. |
◆ guid() [8/8]
xtd::guid::guid |
( |
const string & |
guid | ) |
|
|
explicit |
Initializes a new instance of the xtd::guid structure by using the value represented by the specified string.
- Parameters
-
guid | A string that contains a GUID in one of the following formats ("d" represents a hexadecimal digit whose case is ignored): 32 contiguous digits: dddddddddddddddddddddddddddddddd -or- Groups of 8, 4, 4, 4, and 12 digits with hyphens between the groups. The entire GUID can optionally be enclosed in matching braces or parentheses: dddddddd-dddd-dddd-dddd-dddddddddddd -or- {dddddddd-dddd-dddd-dddd-dddddddddddd} -or- (dddddddd-dddd-dddd-dddd-dddddddddddd) -or- Groups of 8, 4, and 4 digits, and a subset of eight groups of 2 digits, with each group prefixed by "0x" or "0X", and separated by commas. The entire GUID, as well as the subset, is enclosed in matching braces: {0xdddddddd, 0xdddd, 0xdddd,{0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd}} All braces, commas, and "0x" prefixes are required. All embedded spaces are ignored. All leading zeros in a group are ignored. The digits shown in a group are the maximum number of meaningful digits that can appear in that group. You can specify from 1 to the number of digits shown for a group. The specified digits are assumed to be the low-order digits of the group. |
- Exceptions
-
◆ compare_to()
int32 xtd::guid::compare_to |
( |
const guid & |
value | ) |
const |
|
overridevirtualnoexcept |
Compares the current instance with another object of the same type.
- Parameters
-
obj | An object to compare with this instance. |
- Returns
- A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has these meanings:
Value | Condition |
Less than zero | This instance is less than obj. |
Zero | This instance is equal to obj. |
Greater than zero | This instance is greater than obj. |
Implements xtd::icomparable< guid >.
◆ equals() [1/3]
bool xtd::guid::equals |
( |
const guid & |
| ) |
const |
|
overridevirtualnoexcept |
Indicates whether the current object is equal to another object of the same type.
- Parameters
-
obj | An object to compare with this object. |
- Returns
true
if the current object is equal to the other parameter; otherwise, false
.
Implements xtd::iequatable< guid >.
◆ to_byte_array()
const std::vector< xtd::byte > & xtd::guid::to_byte_array |
( |
| ) |
const |
|
noexcept |
Returns a 16-element byte array that contains the value of this instance.
- Returns
- A 16-element byte array.
◆ to_string() [1/3]
Returns a string representation of the value of this instance in registry format.
- Returns
- The value of this xtd::guid, formatted by using the "D" format specifier as follows: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx where the value of the GUID is represented as a series of lowercase hexadecimal digits in groups of 8, 4, 4, 4, and 12 digits and separated by hyphens. An example of a return value is "382c74c3-721d-4f34-80e5-57657b6cbc27". To convert the hexadecimal digits from a through f to uppercase, call the string::to_string method on the returned string.
Reimplemented from xtd::object.
◆ to_string() [2/3]
Returns a string representation of the value of this xtd::guid instance, according to the provided format specifier.
- Parameters
-
format | A single format specifier that indicates how to format the value of this xtd::guid. The format parameter can be "N", "D", "B", "P", or "X". If format is null or an empty string (""), "D" is used. |
- Returns
- The value of this xtd::guid, represented as a series of lowercase hexadecimal digits in the specified format.
- Exceptions
-
◆ to_string() [3/3]
string xtd::guid::to_string |
( |
const string & |
format, |
|
|
const std::locale & |
loc |
|
) |
| const |
|
overridevirtual |
Returns a string representation of the value of this xtd::guid instance, according to the provided format specifier, and locale.
- Parameters
-
format | A single format specifier that indicates how to format the value of this xtd::guid. The format parameter can be "N", "D", "B", "P", or "X". If format is null or an empty string (""), "D" is used. |
loc | An std::locale object that contains locale information (see std::locale). |
- Returns
- The value of this xtd::guid, represented as a series of lowercase hexadecimal digits in the specified format.
- Exceptions
-
Implements xtd::iformatable.
◆ new_guid()
static guid xtd::guid::new_guid |
( |
| ) |
|
|
staticnoexcept |
Initializes a new instance of the xtd::guid structure.
- Returns
- A new GUID object.
◆ equals() [2/3]
virtual bool xtd::object::equals |
( |
const object & |
obj | ) |
const |
|
virtualnoexcept |
Determines whether the specified object is equal to the current object.
- Parameters
-
obj | The object to compare with the current object. |
- Returns
- true if the specified object is equal to the current object. otherwise, false.
- Examples
- The following code example compares the current instance with another object.
#include <xtd/console>
auto main() -> int {
auto object1 = new_ptr<object>();
auto object2 = new_ptr<object>();
auto object3 = object2;
object3 = object1;
}
Reimplemented from xtd::object.
◆ equals() [3/3]
template<typename object_a_t , typename object_b_t >
static bool xtd::object::equals |
( |
const object_a_t & |
object_a, |
|
|
const object_b_t & |
object_b |
|
) |
| |
|
inlinestaticnoexcept |
Determines whether the specified object instances are considered equal.
- Parameters
-
object_a | The first object to compare. |
object_b | The second object to compare. |
- Returns
- true if object_a is the same instance as object_b or if both are null references or if object_a(object_b) returns true. otherwise, false.
- Examples
- The following code example compares different objects.
#include <xtd/console>
auto main() -> int {
string s1 = "Tom";
string s2 = "Carol";
s1 = "Tom";
s2 = "Tom";
s1 = "";
s2 = "Tom";
s1 = "Carol";
s2 = "";
s1 = "";
s2 = "";
}
virtual bool equals(const object &obj) const noexcept
Determines whether the specified object is equal to the current object.
◆ empty
const guid xtd::guid::empty |
|
static |
Gets A read-only instance of the xtd::guid structure whose value is all zeros.
- Returns
- xtd::guid A read-only instance of the xtd::guid structure whose value is all zeros.
The documentation for this struct was generated from the following file: