sincerely Singaporean

If you have not done so, read this full tutorial on how to use SGEXTN to build an application.

SGXIdentifier

see header file

see source file

class SGXIdentifier;

part of SGEXTN module SG_Core

pseudo-GUID identifier

detailed description

list of all including inherited members

implementation details

preprocessor file inclusion directive: #include ‹SGXIdentifier.h›

CMake target for BuildLah: SGEXTN::SG_Core

see this link for more information about BuildLah

parent class: (none)

children classes: (none)

instance member functions

SGXIdentifier(const SGXString& s, bool ifValid, int* errCode);

SGXIdentifier(bool ifValid);

SGXIdentifier(unsigned int a, unsigned int b, unsigned int c, unsigned int d, bool ifValid, int* errCode);

[[nodiscard]] bool exists() const;

[[nodiscard]] SGXString getStringForPrinting() const;

[[nodiscard]] int hash() const;

[[nodiscard]] bool operator!=(SGXIdentifier x) const;

[[nodiscard]] bool operator‹(SGXIdentifier x) const;

[[nodiscard]] bool operator==(SGXIdentifier x) const;

[[nodiscard]] bool operator›(SGXIdentifier x) const;

static member variables

static const SGXIdentifier nullIdentifier;

static member functions

static bool registerIdentifier(SGXIdentifier x);

static bool unregisterIdentifier(SGXIdentifier x);

Detailed Description

SGXIdentifier looks like a GUID and can function like a GUID in most scenarios. However, it technically is not a GUID because it does not comply with any GUID standard, and SGEXTN does not guarantee non collision when SGXIdentifier from different databases are merged. SGXIdentifier provides an internal registration system to make accidental collision impossible.

Implementation Details

a sequence of 4 unsigned ints, randomly generated or read from file on initialisation.

SGXIdentifier(const SGXString& s, bool ifValid, int* errCode);

Generates a SGXIdentifier from the string representation s, this can be used for generating SGXIdentifier objects consistently from a set of data. If ifValid is true, it is checked if the SGXIdentifier is already registered. In that case, if the constructed SGXIdentifier is the null identifier, the int pointed to by errCode is set to 2. If the constructed SGXIdentifier overlaps with an existing registered SGXIdentifier, the int pointed to by errCode is set to 1. Otherwise the int pointed to by errCode is set to 0. Pass errCode as nullptr if you do not need existence checking.

Setting ifValid to true does not register the generated SGXIdentifier, it has to be registered using SGXIdentifier::registerIdentifier separately.

This only works if s was generated using SGXIdentifier::getStringForPrinting. If s does not represent a valid SGXIdentifier in the defined format, a null identifier is constructed.

SGXIdentifier(bool ifValid);

Generates a new random SGXIdentifier. If ifValid is true, it is guaranteed that the generated SGXIdentifier does not collide with any existing registered SGXIdentifier.

Setting ifValid to true does not register the generated SGXIdentifier, it has to be registered using SGXIdentifier::registerIdentifier separately.

SGXIdentifier(unsigned int a, unsigned int b, unsigned int c, unsigned int d, bool ifValid, int* errCode);

Generates a SGXIdentifier storing information from a, b, c, d, this can be used for generating SGXIdentifier objects consistently from a set of data. If ifValid is true, it is checked if the SGXIdentifier is already registered. In that case, if the constructed SGXIdentifier is the null identifier, the int pointed to by errCode is set to 2. If the constructed SGXIdentifier overlaps with an existing registered SGXIdentifier, the int pointed to by errCode is set to 1. Otherwise the int pointed to by errCode is set to 0. Pass errCode as nullptr if you do not need existence checking.

Setting ifValid to true does not register the generated SGXIdentifier, it has to be registered using SGXIdentifier::registerIdentifier separately.

[[nodiscard]] bool exists() const;

Returns if the SGXIdentifier has already been registered.

There is no need to use SGXIdentifier::exists before SGXIdentifier::registerIdentifier or SGXIdentifier::unregisterIdentifier as the check is done internally.

[[nodiscard]] SGXString getStringForPrinting() const;

Converts the SGXIdentifier to text.

This can be used for file names

This is not really human readable. Do not make the user read SGXIdentifier values, instead get them to name whatever their data is.

[[nodiscard]] int hash() const;

Hash function defined for SGLHash.

[[nodiscard]] bool operator!=(SGXIdentifier x) const;

Returns if this SGXIdentifier is not the same as x.

[[nodiscard]] bool operator‹(SGXIdentifier x) const;

Lesser than operator with x defined for SGLLesserThan and SGLMoreThan.

[[nodiscard]] bool operator==(SGXIdentifier x) const;

Returns if this SGXIdentifier is the same as x.

[[nodiscard]] bool operator›(SGXIdentifier x) const;

More than operator with x defined for SGLLesserThan and SGLMoreThan.

static const SGXIdentifier nullIdentifier;

Null identifier, or SGXIdentifier with all bits at zero.

static bool registerIdentifier(SGXIdentifier x);

Registers the SGXIdentifier x. The function returns false if the SGXIdentifier is already registered (nothing is done) and true otherwise.

Attempting to register a SGXIdentifier that is already registered does NOT cause a crash or undefined behaviour, it just gives a return value of false.

static bool unregisterIdentifier(SGXIdentifier x);

Unregisters the SGXIdentifier x. The function returns false if the SGXIdentifier was never registered (nothing is done) and true otherwise.

Attempting to deregister a SGXIdentifier that has never been registered does NOT cause a crash or undefined behaviour, it just gives a return value of false.

©2025 05524F.sg (Singapore)

contact 05524F / report a bug / make a suggestion

about 05524F SINGAPORE values

list of 05524F projects