LiteralId Class Reference Data Types

#include <apibaseid.h>

Inheritance diagram for LiteralId:

详细描述

LiteralId is used as base class of Id . It may only be used for strings such as string literals which have a longer lifetime than the LiteralId object itself. The benefit is that LiteralId is a literal type and has a trivial destructor.

公共成员函数

constexpr  LiteralId ()
  LiteralId (const LiteralId &)=default
MAXON_IMPLICIT   LiteralId (const Id &)=delete
LiteralId operator= (const LiteralId &)=default
LiteralId operator= (const Id &)=delete
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   比较 (const LiteralId &other) const
constexpr HashInt   GetHashCode () const
Bool   IsEmpty () const
Bool   IsPopulated () const
const Char GetCString () const
Int   GetCStringLength () const
String   ToString (const FormatStatement *formatStatement=nullptr) const
CString   ToCString () const
Block < const Char ToBlock () const
const Id Get () const
  operator const Id & () const
Bool   UsesRefCountedCString () const
template<UInt N>
constexpr  LiteralId (bool dummy, const Char (&str)[N])
constexpr  LiteralId (bool dummy, const LiteralId & src )
template<typename T , typename = typename T::DeclarationHelper>
constexpr  LiteralId (bool dummy, const T &decl)

静态公共成员函数

static constexpr HashInt   GetHashCode (const Char *str)

静态公共属性

static const Int   MAX_LENGTH_EXPONENT
static const UInt   LOW_HASH_MASK
static const Int   MAX_LENGTH

Protected Member Functions

constexpr  LiteralId (const Char *value, UInt hash)
  LiteralId ( ENUM_DONT_INITIALIZE )

Protected Attributes

const Char _value
UInt   _hash

Static Protected Attributes

static const Int   RC_STRING_BIT
static const UInt   RC_STRING_MASK
static const UInt   HASH_MASK

Friends

class  EntityBase

构造函数 & 析构函数文档编制

◆  LiteralId() [1/9]

constexpr LiteralId ( )
constexpr

◆  LiteralId() [2/9]

LiteralId ( const LiteralId )
default

◆  LiteralId() [3/9]

MAXON_IMPLICIT LiteralId ( const Id )
delete

◆  LiteralId() [4/9]

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

◆  LiteralId() [5/9]

constexpr LiteralId ( bool  dummy ,
const Char (&)  str [N] 
)
constexpr

◆  LiteralId() [6/9]

constexpr LiteralId ( bool  dummy ,
const LiteralId src  
)
constexpr

◆  LiteralId() [7/9]

constexpr LiteralId ( bool  dummy ,
const T &  decl  
)
constexpr

◆  LiteralId() [8/9]

constexpr LiteralId ( const Char value ,
UInt   hash  
)
constexpr protected

◆  LiteralId() [9/9]

LiteralId ( ENUM_DONT_INITIALIZE   )
explicit protected

成员函数文档编制

◆  operator=() [1/2]

LiteralId & operator= ( const LiteralId )
default

◆  operator=() [2/2]

LiteralId & operator= ( const Id )
delete

◆  operator==()

Bool operator== ( const LiteralId other ) const

◆  operator<()

Bool operator< ( const LiteralId other ) const

◆  MAXON_OPERATOR_COMPARISON()

MAXON_OPERATOR_COMPARISON ( LiteralId   )

◆  Compare()

COMPARERESULT 比较 ( const LiteralId other ) const

Compares two Id objects using the lexicographic order.

参数
[in] other 其它 Id 对象。
返回
See COMPARERESULT.

◆  GetHashCode() [1/2]

constexpr HashInt GetHashCode ( ) const
constexpr

◆  IsEmpty()

Bool IsEmpty ( ) const

Checks if the Id is empty.

返回
True if the Id contains a nullptr as c-string.

◆  IsPopulated()

Bool IsPopulated ( ) const

Checks if this Id contains anything.

返回
True if the ID contains a c-string.

◆  GetCString()

const Char * GetCString ( ) const

Returns the internal c-string. No copy is made.

返回
Internal string.

◆  GetCStringLength()

Int GetCStringLength ( ) const

Returns the length of the internal c-string. This function doesn't have to scan the string, because the length is directly available in the Id .

返回
Length of internal string.

◆  ToString()

String ToString ( const FormatStatement formatStatement = nullptr ) const

Returns a readable string of the content.

参数
[in] formatStatement Nullptr or additional formatting instruction. Currently no additional formatting instructions are supported.
返回
The converted result.

◆  ToCString()

CString ToCString ( ) const

◆  Get()

const Id & Get ( ) const

◆  operator const Id &()

operator const Id & ( ) const

◆  UsesRefCountedCString()

Bool UsesRefCountedCString ( ) const

Returns true if this Id uses a RefCountedCString . Otherwise, the Id uses a global c-string which is assumed to persist at least as long as the Id .

返回
True if the Id uses a RefCountedCString .

◆  GetHashCode() [2/2]

static constexpr HashInt GetHashCode ( const Char str )
static constexpr

Friends And Related Function Documentation

◆  EntityBase

friend class EntityBase friend

Member Data Documentation

◆  MAX_LENGTH_EXPONENT

const Int MAX_LENGTH_EXPONENT static

◆  LOW_HASH_MASK

const UInt LOW_HASH_MASK static

Mask for the lower bits of the hash (the part which corresponds to the hash code of the string).

◆  RC_STRING_BIT

const Int RC_STRING_BIT
static protected

Bit position in _hash of the bit which is set when the Id uses a RefCountedCString .

◆  RC_STRING_MASK

const UInt RC_STRING_MASK
static protected

Mask to get the RC_STRING_BIT from _hash.

◆  HASH_MASK

const UInt HASH_MASK
static protected

Mask to get the hash code from _hash.

◆  MAX_LENGTH

const Int MAX_LENGTH static

◆  _value

const Char * _value
protected

C-string identifier. If the RC_STRING_BIT is set in _hash, this actually points to the _string part of a RefCountedCString .

◆  _hash

UInt _hash
protected

Combination of hash code (lower bits), then a bit at RC_STRING_BIT and finally the string length (MAX_LENGTH_EXPONENT bits). Use HASH_MASK to mask out the RC_STRING_BIT .