DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
DotNetDupe::System::Guid Class Reference

Represents a 128-bit globally unique identifier (GUID). More...

#include <Guid.h>

Inheritance diagram for DotNetDupe::System::Guid:

Public Member Functions

 Guid ()
 Initializes a new instance of the Guid structure initialized to all zeros.
 Guid (const Array< uint8_t > &b)
 Initializes a new instance of the Guid structure using the specified array of bytes.
 Guid (const String &g)
 Initializes a new instance of the Guid structure using the value represented by the specified string.
bool operator!= (const Guid &other) const
 Determines whether two Guid instances have differing values.
bool operator== (const Guid &other) const
 Determines whether two Guid instances have identical values.
Array< uint8_t > ToByteArray () const
 Returns a 16-element byte array that contains the value of this instance.
String ToString () const
 Returns a string representation of the value of this instance in standard "D" format (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
Public Member Functions inherited from DotNetDupe::System::Object
virtual ~Object ()=default
 Virtual destructor ensuring polymorphic cleanup.
virtual bool Equals (const Object &obj) const
 Determines whether the specified Object is equal to the current Object.
virtual int GetHashCode () const
 Serves as the default hash function.
bool operator== (const Object &obj) const
 Determines reference equality between two objects.
char * ToStringA () const
 Returns narrow-character string representation.
wchar_t * ToStringW () const
 Returns wide-character string representation.

Static Public Member Functions

static Guid NewGuid ()
 Initializes a new instance of the Guid structure (RFC 4122 Version 4 random UUID).
Static Public Member Functions inherited from DotNetDupe::System::Object
static bool Equals (const Object &obj1, const Object &obj2)
 Static helper determining whether two object instances are equal.

Static Public Attributes

static const Guid Empty = Guid()
 A read-only instance of the Guid structure whose value is all zeros.

Detailed Description

Represents a 128-bit globally unique identifier (GUID).

Provides RFC 4122 version 4 generation, parsing from 32-hex or hyphenated strings, binary conversion, and comparison operations. Immutable value object. Thread-safe for all concurrent const operations.

Note
Conforms to RFC 4122 and ECMA-335 Partition IV Section 5.7 (System.Guid).
See also
String, BitConverter

Definition at line 22 of file Guid.h.

Constructor & Destructor Documentation

◆ Guid() [1/3]

DotNetDupe::System::Guid::Guid ( )

Initializes a new instance of the Guid structure initialized to all zeros.

Definition at line 15 of file Guid.cpp.

Referenced by NewGuid(), operator!=(), and operator==().

◆ Guid() [2/3]

DotNetDupe::System::Guid::Guid ( const Array< uint8_t > & b)

Initializes a new instance of the Guid structure using the specified array of bytes.

Parameters
bA 16-element byte array containing values with which to initialize the GUID.

Definition at line 21 of file Guid.cpp.

References DotNetDupe::System::ArgumentException::ArgumentException(), and DotNetDupe::System::Array< T >::GetLength().

◆ Guid() [3/3]

DotNetDupe::System::Guid::Guid ( const String & g)

Initializes a new instance of the Guid structure using the value represented by the specified string.

Parameters
gString that contains a GUID in "D", "N", or "B" format.

Normalize string by stripping enclosing braces and hyphens.

Guard: Validate normalized hex string contains exactly 32 hexadecimal characters.

Parse 16 two-character hexadecimal octets into internal byte array.

Definition at line 28 of file Guid.cpp.

References DotNetDupe::System::FormatException::FormatException(), DotNetDupe::System::String::GetLength(), DotNetDupe::System::String::GetRawString(), DotNetDupe::System::String::Replace(), and DotNetDupe::System::String::Substring().

Member Function Documentation

◆ NewGuid()

Guid DotNetDupe::System::Guid::NewGuid ( )
static

Initializes a new instance of the Guid structure (RFC 4122 Version 4 random UUID).

Returns
A new Guid initialized with pseudo-random Version 4 octets.

Generate 16 pseudo-random octets.

Set Version 4 bits (0100b) in byte 6 and RFC 4122 variant bits (10b) in byte 8.

Return constructed Version 4 Guid instance.

Definition at line 49 of file Guid.cpp.

References Guid().

◆ operator!=()

bool DotNetDupe::System::Guid::operator!= ( const Guid & other) const

Determines whether two Guid instances have differing values.

Parameters
otherThe Guid instance to compare with the current instance.
Returns
True if any octet differs; otherwise, false.

Definition at line 87 of file Guid.cpp.

References Guid().

◆ operator==()

bool DotNetDupe::System::Guid::operator== ( const Guid & other) const

Determines whether two Guid instances have identical values.

Parameters
otherThe Guid instance to compare with the current instance.
Returns
True if all 16 octets match; otherwise, false.

Definition at line 83 of file Guid.cpp.

References Guid().

◆ ToByteArray()

Array< uint8_t > DotNetDupe::System::Guid::ToByteArray ( ) const

Returns a 16-element byte array that contains the value of this instance.

Returns
A 16-element byte array containing the GUID bytes.

Definition at line 64 of file Guid.cpp.

◆ ToString()

String DotNetDupe::System::Guid::ToString ( ) const

Returns a string representation of the value of this instance in standard "D" format (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

Returns
A string representation formatted according to RFC 4122.

Definition at line 72 of file Guid.cpp.

References DotNetDupe::System::String::String().

Member Data Documentation

◆ Empty

const Guid DotNetDupe::System::Guid::Empty = Guid()
static

A read-only instance of the Guid structure whose value is all zeros.

Definition at line 40 of file Guid.h.


The documentation for this class was generated from the following files: