IdBuilder Class Reference

#include <corenodes_helpers.h>

Detailed Description

IdBuilder can be used to build identifiers for instantiations of generic core nodes. For example the generic multiplication core node "net.maxon.corenode.mul" has instantiations for several data types such as "net.maxon.corenode.mul<int64>" for the type Int64. The id of the instantiation can be obtained with an IdBuilder by writing {IdBuilder("net.maxon.corenode.mul").Append<Int>()} as in this example code:

CoreNodeInstancePtr mul = g.AddChild(Id(), IdBuilder("net.maxon.corenode.mul").Append<Int>()) iferr_return;

The constructor and Append functions of IdBuilder don't return errors, a potential out-of-memory error is postponed to the final call of ToId() or ToCString().

Public Member Functions

 IdBuilder (const Char *base)
 
 IdBuilder (Block< const Char > base)
 
 IdBuilder (const LiteralId &base)
 
IdBuilder && Append (const DataType &type)
 
template<typename... T>
IdBuilder && Append ()
 
template<Bool B, typename... T>
IdBuilder && Append ()
 
template<typename IDCLASS = Id>
Result< IDCLASS > ToId () const
 
Result< CStringToCString () const
 
String ToString (const FormatStatement *formatStatement=nullptr) const
 

Static Public Member Functions

template<typename... INSTANTIATIONTYPE, typename BASETYPE >
static corenodes::IdBuilder Create (BASETYPE baseId)
 

Private Member Functions

 IdBuilder ()=default
 
IdBuilder && AppendImpl ()
 
template<typename... T>
IdBuilder && AppendImpl (const DataType &type, T... types)
 
void AppendString (const Char *str)
 
void AppendString (Block< const Char > str)
 
void AppendParam (const Char *str)
 
void AppendChar (Char ch)
 

Private Attributes

CString _name
 

Friends

class IdOrBuilder
 

Constructor & Destructor Documentation

◆ IdBuilder() [1/4]

IdBuilder ( const Char base)
explicit

Constructs a new IdBuilder where base is the part of the id before the instantiation suffix.

Parameters
[in]baseThe base identifier for this IdBuilder.

◆ IdBuilder() [2/4]

IdBuilder ( Block< const Char base)
explicit

Constructs a new IdBuilder where base is the part of the id before the instantiation suffix.

Parameters
[in]baseThe base identifier for this IdBuilder.

◆ IdBuilder() [3/4]

IdBuilder ( const LiteralId base)
explicit

Constructs a new IdBuilder where base is the part of the id before the instantiation suffix.

Parameters
[in]baseThe base identifier for this IdBuilder.

◆ IdBuilder() [4/4]

IdBuilder ( )
privatedefault

Member Function Documentation

◆ Create()

static corenodes::IdBuilder Create ( BASETYPE  baseId)
static

Constructs a new IdBuilder based on #baseId with type instantiation suffixes.

See also
IdBuilder constructors and templated Append as static Create is a combination of both.
Template Parameters
INSTANTIATIONTYPEThe instantiation types to append.
BASETYPEThe type of #baseId (for calling constructor).
Parameters
[in]baseIdThe base identifier for this IdBuilder.
Returns
OK on success.

◆ Append() [1/3]

IdBuilder&& Append ( const DataType type)

Appends the identifier of type to the instantiation suffix of this IdBuilder. Angular brackets and commas are appended as needed.

Parameters
[in]typeThe type to append.
Returns
This IdBuilder.

◆ Append() [2/3]

IdBuilder&& Append ( )

Appends the identifiers of the given types to the instantiation suffix of this IdBuilder. Angular brackets and commas are appended as needed.

Template Parameters
TThe types to append.
Returns
This IdBuilder.

◆ Append() [3/3]

IdBuilder&& Append ( )

Appends the identifiers of the given types to the instantiation suffix of this IdBuilder. Angular brackets and commas are appended as needed.

Template Parameters
BA Bool value to append (not the type, the value).
TThe remaining types to append.
Returns
This IdBuilder.

◆ ToId()

Result<IDCLASS> ToId ( ) const

Returns the constructed identifier of this IdBuilder as an Id. If an error happened during construction, this is reported by the call to this function. Method supports both Id and InternedId types.

IdBuilder builder{LiteralId{"portId"}};
InternedId builtIid = builder.ToId<InternedId>() iferr_return;
// or
Id builtId = builder.ToId() iferr_return;
#define iferr_return
Definition: resultbase.h:1519
Returns
The constructed identifier.

◆ ToCString()

Result<CString> ToCString ( ) const

Returns the constructed identifier of this IdBuilder as a CString. If an error happened during construction, this is reported by the call to this function.

Returns
The constructed identifier.

◆ ToString()

String ToString ( const FormatStatement formatStatement = nullptr) const

Returns a String representation of this @CLASS.

Parameters
[in]formatStatementNullptr or additional formatting instruction.
Returns
String representation of this @CLASS.

◆ AppendImpl() [1/2]

IdBuilder&& AppendImpl ( )
private

◆ AppendImpl() [2/2]

IdBuilder&& AppendImpl ( const DataType type,
T...  types 
)
private

◆ AppendString() [1/2]

void AppendString ( const Char str)
private

◆ AppendString() [2/2]

void AppendString ( Block< const Char str)
private

◆ AppendParam()

void AppendParam ( const Char str)
private

◆ AppendChar()

void AppendChar ( Char  ch)
private

Friends And Related Function Documentation

◆ IdOrBuilder

friend class IdOrBuilder
friend

Member Data Documentation

◆ _name

CString _name
private