Safir SDK Core
Loading...
Searching...
No Matches
Safir::Dob::Typesystem::InstanceId Class Reference

Class containing the identity of an instance. More...

#include <Safir/Dob/Typesystem/InstanceId.h>

Public Member Functions

 InstanceId ()
 Default constructor.
 
 InstanceId (const std::wstring &id)
 Constructor.
 
 InstanceId (const Dob::Typesystem::Int64 id)
 Constructor.
 
 InstanceId (const Int64 id, const std::wstring &idStr)
 Constructor.
 
void RemoveString ()
 Remove the included string from the instance id.
 
bool operator== (const InstanceId &other) const
 Equality operator.
 
bool operator!= (const InstanceId &other) const
 Inequality operator.
 
bool operator< (const InstanceId &other) const
 Less-than operator.
 
DOTS_CPP_API const std::wstring ToString () const
 Return a string representation of the instance id.
 

Static Public Member Functions

static InstanceId GenerateRandom ()
 Returns a random instance id.
 

Internal functions.

typedef Int64 UnderlyingType
 
UnderlyingType GetRawValue () const
 Get the raw 64 bit integer identifier.
 
const std::wstring & GetRawString () const
 Get the string that was used to create this id.
 
Int32 Utf8StringLength () const
 Get the length of the string when converted to UTF-8 encoding.
 
const std::string & Utf8String () const
 Convert the string to UTF-8.
 

Detailed Description

Class containing the identity of an instance.

Note: This class should be header-only, since otherwise we introduce all sorts of warnings for libraries that use this type.

Member Typedef Documentation

◆ UnderlyingType

Constructor & Destructor Documentation

◆ InstanceId() [1/4]

Safir::Dob::Typesystem::InstanceId::InstanceId ( )

Default constructor.

Creates an unspecified instance id.

Referenced by GenerateRandom().

Here is the caller graph for this function:

◆ InstanceId() [2/4]

Safir::Dob::Typesystem::InstanceId::InstanceId ( const std::wstring & id)

Constructor.

Creates a instance id from the given string.

Parameters
id[in] - String identifying the instance.

◆ InstanceId() [3/4]

Safir::Dob::Typesystem::InstanceId::InstanceId ( const Dob::Typesystem::Int64 id)
explicit

Constructor.

Creates an instance id using a 64 bit integer.

Parameters
id[in] - The 64bit integer id of the instance.

◆ InstanceId() [4/4]

Safir::Dob::Typesystem::InstanceId::InstanceId ( const Int64 id,
const std::wstring & idStr )

Constructor.

Creates a instance id from the given data.

Parameters
id[in] - Identifier identifying the instance.
idStr[in] - String identifying the instance.

References __WFILE__.

Member Function Documentation

◆ GenerateRandom()

static InstanceId Safir::Dob::Typesystem::InstanceId::GenerateRandom ( )
static

Returns a random instance id.

References InstanceId().

Here is the call graph for this function:

◆ GetRawString()

const std::wstring & Safir::Dob::Typesystem::InstanceId::GetRawString ( ) const

Get the string that was used to create this id.

If no string was used this method returns an empty string.

Returns
The string (if any) that was used to create this id.

◆ GetRawValue()

UnderlyingType Safir::Dob::Typesystem::InstanceId::GetRawValue ( ) const

Get the raw 64 bit integer identifier.

Returns
The raw 64 bit identifier.

Referenced by Safir::Dob::Typesystem::hash_value(), and Safir::Dob::Typesystem::hash_value().

Here is the caller graph for this function:

◆ operator!=()

bool Safir::Dob::Typesystem::InstanceId::operator!= ( const InstanceId & other) const

Inequality operator.

Parameters
other[in] - The InstanceId to compare with.

◆ operator<()

bool Safir::Dob::Typesystem::InstanceId::operator< ( const InstanceId & other) const

Less-than operator.

This is provided to allow InstanceIds to be stored in STL containers that need strict weak ordering.

Parameters
other[in] - The InstanceId to compare with.

◆ operator==()

bool Safir::Dob::Typesystem::InstanceId::operator== ( const InstanceId & other) const

Equality operator.

Parameters
other[in] - The InstanceId to compare with.

◆ RemoveString()

void Safir::Dob::Typesystem::InstanceId::RemoveString ( )

Remove the included string from the instance id.

This is meant to be used when this type is used as a member of a Dob object. Using this call before the object gets serialized to binary or xml (i.e. also before sending it anywhere) means that the string will not be included when the object is sent.

Referenced by Safir::Dob::Typesystem::EntityId::RemoveString().

Here is the caller graph for this function:

◆ ToString()

DOTS_CPP_API const std::wstring Safir::Dob::Typesystem::InstanceId::ToString ( ) const

Return a string representation of the instance id.

If the string that created the instance id is available this is the string that will be returned, otherwise it is the number that will be returned.

The purpose of this function is for debug output and such. The resulting string can not reliably be used in the "string constructor" for InstanceId to recreate the same InstanceId.

Returns
The instance id as a string.

Referenced by Safir::Dob::Typesystem::operator<<().

Here is the caller graph for this function:

◆ Utf8String()

const std::string & Safir::Dob::Typesystem::InstanceId::Utf8String ( ) const

Convert the string to UTF-8.

Returns an empty string if there is no string.

Returns
UTF-8 representation of the string.

References Safir::Dob::Typesystem::Utilities::ToUtf8().

Here is the call graph for this function:

◆ Utf8StringLength()

Int32 Safir::Dob::Typesystem::InstanceId::Utf8StringLength ( ) const

Get the length of the string when converted to UTF-8 encoding.

Includes one byte for a null termination.

Returns
The length of the string of the id when converted to UTF-8

References Safir::Dob::Typesystem::Utilities::ToUtf8().

Here is the call graph for this function: