![]() |
Safir SDK Core
|
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. | |
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.
Safir::Dob::Typesystem::InstanceId::InstanceId | ( | ) |
Default constructor.
Creates an unspecified instance id.
Referenced by GenerateRandom().
Safir::Dob::Typesystem::InstanceId::InstanceId | ( | const std::wstring & | id | ) |
Constructor.
Creates a instance id from the given string.
id | [in] - String identifying the instance. |
|
explicit |
Constructor.
Creates an instance id using a 64 bit integer.
id | [in] - The 64bit integer id of the instance. |
Safir::Dob::Typesystem::InstanceId::InstanceId | ( | const Int64 | id, |
const std::wstring & | idStr ) |
Constructor.
Creates a instance id from the given data.
id | [in] - Identifier identifying the instance. |
idStr | [in] - String identifying the instance. |
References __WFILE__.
|
static |
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.
UnderlyingType Safir::Dob::Typesystem::InstanceId::GetRawValue | ( | ) | const |
Get the raw 64 bit integer identifier.
Referenced by Safir::Dob::Typesystem::hash_value(), and Safir::Dob::Typesystem::hash_value().
bool Safir::Dob::Typesystem::InstanceId::operator!= | ( | const InstanceId & | other | ) | const |
Inequality operator.
other | [in] - The InstanceId to compare with. |
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.
other | [in] - The InstanceId to compare with. |
bool Safir::Dob::Typesystem::InstanceId::operator== | ( | const InstanceId & | other | ) | const |
Equality operator.
other | [in] - The InstanceId to compare with. |
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().
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.
Referenced by Safir::Dob::Typesystem::operator<<().
const std::string & Safir::Dob::Typesystem::InstanceId::Utf8String | ( | ) | const |
Convert the string to UTF-8.
Returns an empty string if there is no string.
References Safir::Dob::Typesystem::Utilities::ToUtf8().
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.
References Safir::Dob::Typesystem::Utilities::ToUtf8().