25 #ifndef __DOTS_INSTANCE_ID_H__
26 #define __DOTS_INSTANCE_ID_H__
31 #include <Safir/Dob/Typesystem/Internal/InternalOperations.h>
70 m_instanceId(Internal::Generate64BitHash(id)),
95 m_instanceIdStr(idStr)
98 if (!m_instanceIdStr.empty() && m_instanceId != Internal::Generate64BitHash(idStr))
100 std::wostringstream ostr;
101 ostr <<
"InstanceId two-argument constructor got an inconsistent id. Got ("
102 <<
id <<
", '" << idStr <<
"'), but the string evaluates to " << Internal::Generate64BitHash(idStr) <<
".";
116 void RemoveString() {m_instanceIdStr.clear(); m_CachedUtf8String.clear();}
125 return m_instanceId == other.m_instanceId;
135 return !(*
this==other);
146 return m_instanceId < other.m_instanceId;
192 if (m_instanceIdStr.empty())
197 if (m_CachedUtf8String.empty())
202 return static_cast<Int32>(m_CachedUtf8String.length() + 1);
214 if (!m_instanceIdStr.empty() && m_CachedUtf8String.empty())
218 return m_CachedUtf8String;
225 std::wstring m_instanceIdStr;
227 mutable std::string m_CachedUtf8String;
231 {
return out << instanceId.
ToString();}
InstanceId(const Dob::Typesystem::Int64 id)
Constructor.
Definition: InstanceId.h:81
Int32 Utf8StringLength() const
Get the length of the string when converted to UTF-8 encoding.
Definition: InstanceId.h:190
bool operator!=(const InstanceId &other) const
Inequality operator.
Definition: InstanceId.h:133
InstanceId(const Int64 id, const std::wstring &idStr)
Constructor.
Definition: InstanceId.h:93
static InstanceId GenerateRandom()
Returns a random instance id.
Definition: InstanceId.h:53
Meant to be used when something goes very wrong.
Definition: Exceptions.h:360
bool operator<(const InstanceId &other) const
Less-than operator.
Definition: InstanceId.h:144
Class containing the identity of an instance.
Definition: InstanceId.h:47
DOTS_CPP_API const std::wstring ToString() const
Return a string representation of the instance id.
const std::wstring & GetRawString() const
Get the string that was used to create this id.
Definition: InstanceId.h:182
void RemoveString()
Remove the included string from the instance id.
Definition: InstanceId.h:116
DotsC_Int64 Int64
64 bit integer type.
Definition: Defs.h:70
UnderlyingType GetRawValue() const
Get the raw 64 bit integer identifier.
Definition: InstanceId.h:173
#define __WFILE__
Definition: Exceptions.h:31
InstanceId()
Default constructor.
Definition: InstanceId.h:60
Int64 UnderlyingType
Definition: InstanceId.h:166
bool operator==(const InstanceId &other) const
Equality operator.
Definition: InstanceId.h:123
static std::wostream & operator<<(std::wostream &out, const ChannelId &channelId)
Definition: ChannelId.h:223
InstanceId(const std::wstring &id)
Constructor.
Definition: InstanceId.h:69
const std::string & Utf8String() const
Convert the string to UTF-8.
Definition: InstanceId.h:212
DotsC_Int32 Int32
32 bit integer type.
Definition: Defs.h:67
#define DOTS_CPP_API
Definition: Defs.h:33
DOTS_CPP_API const std::string ToUtf8(const std::wstring &wstr)
Convert a std::wstring to UTF8-encoded std::string.