InternedId Class Reference Data Types

#include <datatypelib.h>

Inheritance diagram for InternedId:

详细描述

InternedId represents an Id which has been interned into a pool of unique Id objects. I.e., there are no two different Id objects with an equal id string, so for equality comparison you can compare pointers instead of whole strings.

You can use MAXON_INTERNED_ID and MAXON_INTERNED_ID_LOCAL to define interned ids which will be initialized automatically at module initialization.

InternedId uses reference counting, so where possible use {const InternedId &} instead of InternedId to avoid unnecesssary reference counting.

公共成员函数

  InternedId ()
  InternedId ( InternedId && src )
InternedId operator= ( InternedId && src )
  InternedId (const InternedId & src )
InternedId operator= (const InternedId & src )
  ~InternedId ()
Result < void >  Init (const Id &i)
Result < void >  Init (const CString &str)
Result < void >  Init (const String &str)
Result < void >  Init (const Char *str)
Result < void >  Init (const Block < const Char > &str)
  operator const Id & () const
const Id Get () const
const Id GetPointer () const
Bool   operator== (const InternedId &other) const
Bool   operator!= (const InternedId &other) const
Bool   operator< (const InternedId &other) const
  MAXON_OPERATOR_INEQUALITY ( InternedId )
Bool   operator== (const Id &other) const
Bool   operator!= (const Id &other) const
COMPARERESULT   比较 (const InternedId &other) const
HashInt   GetHashCode () const
const Char GetCString () const
Int   GetCStringLength () const
Block < const Char ToBlock () const
String   ToString (const FormatStatement *fmt=nullptr) const
Bool   IsPopulated () const
Bool   IsEmpty () const
void  重置 ()

静态公共成员函数

template<typename INPUTTYPE >
static Result < InternedId 创建 (INPUTTYPE &&inputId)
static const InternedId NullValue ()

静态公共属性

static const InternedId   NULL_VALUE

Static Private Member Functions

static void  Free (const Id *ptr)

Private Attributes

const Id _id

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

◆  InternedId() [1/3]

InternedId ( )

Constructs an empty InternedId . You have to initialize it afterwards using Init() .

◆  InternedId() [2/3]

InternedId ( InternedId &&  src )

◆  InternedId() [3/3]

InternedId ( const InternedId src )

◆  ~InternedId()

~ InternedId ( )

成员函数文档编制

◆  operator=() [1/2]

InternedId & operator= ( InternedId &&  src )

◆  operator=() [2/2]

InternedId & operator= ( const InternedId src )

◆  Create()

static Result < InternedId > Create ( INPUTTYPE &&  inputId )
static

创建新的 InternedId for the given inputId. All types for which there is an InternedId::Init function are supported.

参数
[in] inputId The id to intern.
Template Parameters
INPUTTYPE The type of inputId. All types for which there is an InternedId::Init function are supported.
返回
The inputId converted to InternedId .

◆  Init() [1/5]

Result <void> Init ( const Id i )

Initializes an InternedId with a given Id .

参数
[in] i The id to intern.
返回
OK on success.

◆  Init() [2/5]

Result <void> Init ( const CString str )

Initializes an InternedId with a given CString .

参数
[in] str The string to intern.
返回
OK on success.

◆  Init() [3/5]

Result <void> Init ( const String str )

Initializes an InternedId with a given String .

参数
[in] str The string to intern.
返回
OK on success.

◆  Init() [4/5]

Result <void> Init ( const Char str )

Initializes an InternedId with a given C-style string.

参数
[in] str The string to intern.
返回
OK on success.

◆  Init() [5/5]

Result <void> Init ( const Block < const Char > &  str )

Initializes an InternedId with a given block of characters.

参数
[in] str The string to intern, no null termination required.
返回
OK on success.

◆  operator const Id &()

operator const Id & ( ) const

Returns the interned Id . The returned object is unique, i.e., there is no other interned Id with an equal string.

返回
Interned Id .

◆  Get()

const Id & Get ( ) const

Returns the interned Id . The returned object is unique, i.e., there is no other interned Id with an equal string.

返回
Interned Id .

◆  GetPointer()

const Id * GetPointer ( ) const

Returns a pointer to the interned Id . The pointer is unique, i.e., there is no other pointer to an interned Id with an equal string. The Id uses a special reference-counting, so you must only use the returned pointer as long as the owning InternedId is valid.

返回
Unique pointer to the interned Id .

◆  operator==() [1/2]

Bool operator== ( const InternedId other ) const

◆  operator!=() [1/2]

Bool operator!= ( const InternedId other ) const

◆  operator<()

Bool operator< ( const InternedId other ) const

◆  MAXON_OPERATOR_INEQUALITY()

MAXON_OPERATOR_INEQUALITY ( InternedId   )

◆  operator==() [2/2]

Bool operator== ( const Id other ) const

◆  operator!=() [2/2]

Bool operator!= ( const Id other ) const

◆  Compare()

COMPARERESULT 比较 ( const InternedId other ) const

Compares two InternedId objects using the lexicographic order.

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

◆  GetHashCode()

HashInt GetHashCode ( ) const

◆  GetCString()

const Char * GetCString ( ) const

◆  GetCStringLength()

Int GetCStringLength ( ) const

◆  ToBlock()

Block <const Char > ToBlock ( ) const

◆  NullValue()

static const InternedId & NullValue ( )
static

◆  ToString()

String ToString ( const FormatStatement fmt = nullptr ) const

◆  IsPopulated()

Bool IsPopulated ( ) const

◆  IsEmpty()

Bool IsEmpty ( ) const

◆  Reset()

void Reset ( )

◆  Free()

static void Free ( const Id ptr )
static private

Member Data Documentation

◆  NULL_VALUE

const InternedId NULL_VALUE static

◆  _id

const Id * _id
private

Pointer to the interned id.