Open Search
    InternedId Class Reference

    #include <datatypelib.h>

    Inheritance diagram for InternedId:

    Detailed Description

    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.

    Classes

    struct  FastCompare
     

    Public Types

    using PrivateInfo = Tuple< UniqueHash >
     

    Public Member Functions

     InternedId ()
     
     InternedId (InternedId &&src)
     
    InternedIdoperator= (InternedId &&src)
     
     InternedId (const InternedId &src)
     
    InternedIdoperator= (const InternedId &src)
     
     ~InternedId ()
     
    Result< void > Init (const Id &i)
     
    Result< void > Init (const CString &str)
     
    Result< void > Init (CString &&str)
     
    Result< void > Init (const String &str)
     
    Result< void > Init (const Char *str, Bool copyString=true)
     
    Result< void > Init (const Block< const Char > &str)
     
     operator const Id & () const
     
    const IdGet () const
     
    const IdGetPointer () 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 Compare (const InternedId &other) const
     
    HashInt GetHashCode () const
     
    const UniqueHashGetUniqueHashCode () const
     
    const CharGetCString () const
     
    Int GetCStringLength () const
     
    Block< const CharToBlock () const
     
    String ToString (const FormatStatement *fmt=nullptr) const
     
    CString ToCString () const
     
    Bool IsPopulated () const
     
    Bool IsEmpty () const
     
    void Reset ()
     

    Static Public Member Functions

    template<typename INPUTTYPE >
    static Result< InternedIdCreate (INPUTTYPE &&inputId)
     
    static MAXON_ATTRIBUTE_FORCE_INLINE const InternedIdNullValue ()
     
    static void PrivateAddReference (const Id *ptr)
     

    Static Public Attributes

    static const InternedId NULL_VALUE
     

    Private Member Functions

    void Release ()
     

    Static Private Member Functions

    static Bool IsReferenced (const Id *ptr)
     
    static void Free (const Id *ptr)
     

    Private Attributes

    const Id_id
     

    Static Private Attributes

    static constexpr Int INFO_OFFSET
     

    Friends

    class SystemImpl
     
    class ObjectModel
     

    Member Typedef Documentation

    ◆ PrivateInfo

    Constructor & Destructor Documentation

    ◆ InternedId() [1/3]

    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 ( )

    Member Function Documentation

    ◆ operator=() [1/2]

    InternedId& operator= ( InternedId &&  src)

    ◆ operator=() [2/2]

    InternedId& operator= ( const InternedId src)

    ◆ Create()

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

    Creates a new InternedId for the given inputId. All types for which there is an InternedId::Init function are supported.

    Parameters
    [in]inputIdThe id to intern.
    Template Parameters
    INPUTTYPEThe type of inputId. All types for which there is an InternedId::Init function are supported.
    Returns
    The inputId converted to InternedId.

    ◆ Init() [1/6]

    Result<void> Init ( const Id i)

    Initializes an InternedId with a given Id.

    Parameters
    [in]iThe id to intern.
    Returns
    OK on success.

    ◆ Init() [2/6]

    Result<void> Init ( const CString str)

    Initializes an InternedId with a given CString.

    Parameters
    [in]strThe string to intern.
    Returns
    OK on success.

    ◆ Init() [3/6]

    Result<void> Init ( CString &&  str)

    Initializes an InternedId with a given CString.

    Parameters
    [in]strThe string to intern. The string is empty afterwards!
    Returns
    OK on success.

    ◆ Init() [4/6]

    Result<void> Init ( const String str)

    Initializes an InternedId with a given String.

    Parameters
    [in]strThe string to intern.
    Returns
    OK on success.

    ◆ Init() [5/6]

    Result<void> Init ( const Char str,
    Bool  copyString = true 
    )

    Initializes an InternedId with a given C-style string.

    Parameters
    [in]strThe string to intern.
    [in]copyStringIf true (the default value), a copy of str is made at first (as a RefCountedCString).
    Returns
    OK on success.

    ◆ Init() [6/6]

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

    Initializes an InternedId with a given block of characters.

    Parameters
    [in]strThe string to intern, no null termination required.
    Returns
    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.

    Returns
    Interned Id.

    ◆ Get()

    const Id& Get ( void  ) const

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

    Returns
    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.

    Returns
    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 Compare ( const InternedId other) const

    Compares two InternedId objects using the lexicographic order.

    Parameters
    [in]otherOther InternedId object.
    Returns
    See COMPARERESULT.

    ◆ GetHashCode()

    HashInt GetHashCode ( ) const

    ◆ GetUniqueHashCode()

    const UniqueHash& GetUniqueHashCode ( ) const

    Returns the 128-bit hash value of this @CLASS. The implementation ensures uniform distribution, so for practical purposes you can safely assume that two objects are equal if their hash values are equal.

    Returns
    Hash value of this @CLASS.

    ◆ GetCString()

    const Char* GetCString ( ) const

    ◆ GetCStringLength()

    Int GetCStringLength ( ) const

    ◆ ToBlock()

    Block<const Char> ToBlock ( ) const

    ◆ NullValue()

    static MAXON_ATTRIBUTE_FORCE_INLINE const InternedId& NullValue ( )
    static

    ◆ ToString()

    String ToString ( const FormatStatement fmt = nullptr) const

    ◆ ToCString()

    CString ToCString ( ) const

    ◆ IsPopulated()

    Bool IsPopulated ( void  ) const

    ◆ IsEmpty()

    Bool IsEmpty ( ) const

    ◆ Reset()

    void Reset ( void  )

    ◆ PrivateAddReference()

    static void PrivateAddReference ( const Id ptr)
    static

    ◆ IsReferenced()

    static Bool IsReferenced ( const Id ptr)
    staticprivate

    ◆ Release()

    void Release ( void  )
    private

    ◆ Free()

    static void Free ( const Id ptr)
    staticprivate

    Friends And Related Function Documentation

    ◆ SystemImpl

    friend class SystemImpl
    friend

    ◆ ObjectModel

    friend class ObjectModel
    friend

    Member Data Documentation

    ◆ NULL_VALUE

    const InternedId NULL_VALUE
    static

    ◆ _id

    const Id* _id
    private

    Pointer to the interned id.

    ◆ INFO_OFFSET

    constexpr Int INFO_OFFSET
    staticconstexprprivate