Id Class Reference

#include <apibaseid.h>

Inheritance diagram for Id:

Detailed Description

Id represents an identifier consisting of a c-string. Such identifiers are used mainly to identify entities such as interfaces, components, classes, registries, entries, modules or published objects.

Public Member Functions

constexpr Id ()
 
 Id (const volatile Char *str)
 
template<UInt N>
constexpr Id (const Char(&str)[N])
 
 Id (Id &&other)
 
 Id (const Id &other)
 
template<typename T , typename = typename T::DeclarationHelper>
 Id (const T &ref)
 
 ~Id ()
 
void Reset ()
 
 MAXON_OPERATOR_MOVE_ASSIGNMENT (Id)
 
Idoperator= (const Id &other)
 
ResultMem Init (const Char *str, Bool copyString)
 
ResultMem Init (const CString &str)
 
ResultMem Init (const String &str)
 
void Init (const InternedId &id)
 
- Public Member Functions inherited from LiteralId
constexpr LiteralId ()
 
template<UInt N>
constexpr LiteralId (const Char(&str)[N])
 
Bool operator== (const LiteralId &other) const
 
Bool operator< (const LiteralId &other) const
 
 MAXON_OPERATOR_COMPARISON (LiteralId)
 
COMPARERESULT Compare (const LiteralId &other) const
 
UInt GetHashCode () const
 
Bool IsEmpty () const
 
Bool IsPopulated () const
 
const CharGetCString () const
 
Int GetCStringLength () const
 
String ToString (const FormatStatement *formatStatement) const
 
CString ToCString () const
 
Block< const CharToBlock () const
 
const IdGet () const
 
Bool UsesRefCountedCString () const
 

Static Public Member Functions

static const IdNullValue ()
 

Private Member Functions

 Id (const CString &)=delete
 
const RefCountedCStringGetRCString () const
 

Additional Inherited Members

- Static Public Attributes inherited from LiteralId
static const Int MAX_LENGTH_EXPONENT
 
static const UInt LOW_HASH_MASK
 
static const Int MAX_LENGTH
 
- Protected Member Functions inherited from LiteralId
constexpr LiteralId (const Char *value, UInt hash)
 
 LiteralId (ENUM_DONT_INITIALIZE)
 
- Static Protected Member Functions inherited from LiteralId
static UInt GetHashCode (const Char *str)
 
template<UInt N>
static constexpr UInt GetHashCode (const Char(&str)[N], UInt h=0, UInt i=0)
 
- Protected Attributes inherited from LiteralId
const Char_value
 
UInt _hash
 
- Static Protected Attributes inherited from LiteralId
static const Int RC_STRING_BIT
 
static const UInt RC_STRING_MASK
 
static const UInt HASH_MASK
 

Constructor & Destructor Documentation

◆ Id() [1/7]

constexpr Id ( )

Constructs a null Id. The internal c-string will be nullptr.

◆ Id() [2/7]

Id ( const volatile Char str)
explicit

Constructs an Id for a given c-string. str is used directly for the internal c-string pointer. It is assumed that the c-string exists at least as long as the constructed Id.

Parameters
[in]strIdentifier as c-string, may be nullptr. This will always be used directly, i.e., no copy is made.

◆ Id() [3/7]

constexpr Id ( const Char(&)  str[N])
explicit

◆ Id() [4/7]

Id ( Id &&  other)

Constructs an Id by moving the values from another Id.

Parameters
[in]otherAnother Id to move from.

◆ Id() [5/7]

Id ( const Id other)

Copy constructs an Id from another Id.

Parameters
[in]otherAnother Id to copy from.

◆ Id() [6/7]

Id ( const T &  ref)
explicit

◆ ~Id()

~Id ( )

Destructs the Id. If the Id uses a RefCountedCString, the reference will be removed.

◆ Id() [7/7]

Id ( const CString )
explicitprivatedelete

Member Function Documentation

◆ NullValue()

static const Id& NullValue ( )
static

◆ Reset()

void Reset ( void  )

Resets the Id. Afterwards, its internal c-string will be nullptr.

◆ MAXON_OPERATOR_MOVE_ASSIGNMENT()

MAXON_OPERATOR_MOVE_ASSIGNMENT ( Id  )

◆ operator=()

Id& operator= ( const Id other)

◆ Init() [1/4]

ResultMem Init ( const Char str,
Bool  copyString 
)

Sets this Id to a new value. If copyString is false, str is used directly for the internal c-string pointer, and it is assumed that the c-string exists at least as long as this Id. Otherwise, if copyString is true, a RefCountedCString is created for str and used for the internal c-string.

Parameters
[in]strIdentifier as c-string, may be nullptr.
[in]copyStringIf true, a copy of str is made at first (as a RefCountedCString).
Returns
False if a copy had to be made, but the allocation failed. True otherwise.

◆ Init() [2/4]

ResultMem Init ( const CString str)

Sets this Id to str. A RefCountedCString is created for str and used for the internal c-string.

Parameters
[in]strIdentifier as CString.
Returns
False if the allocation for the RefCountedCString failed. True otherwise.

◆ Init() [3/4]

ResultMem Init ( const String str)

Sets this Id to str.

Parameters
[in]strIdentifier as String.
Returns
False if the allocation failed. True otherwise.

◆ Init() [4/4]

void Init ( const InternedId id)

Sets this Id to id.

Parameters
[in]idInterned Id.

◆ GetRCString()

const RefCountedCString* GetRCString ( ) const
private