StringName

An optimized string type for unique names.

Description

StringNames are immutable strings designed for general-purpose representation of unique names (also called "string interning"). StringName ensures that only one instance of a given name exists (so two StringNames with the same value are the same object). Comparing them is much faster than with regular Strings, because only the pointers are compared, not the whole strings.

You will usually just pass a String to methods expecting a StringName and it will be automatically converted, but you may occasionally want to construct a StringName ahead of time with StringName or the literal syntax &"example".

See also NodePath, which is a similar concept specifically designed to store pre-parsed node paths.

Constructors

StringName

StringName ( )

StringName

StringName ( StringName from )

StringName

StringName ( String from )

Methods

int

hash ( ) const

Operators

bool

operator != ( String right )

bool

operator != ( StringName right )

bool

operator ( StringName right )

bool

operator ( StringName right )

bool

operator == ( String right )

bool

operator == ( StringName right )

bool

operator > ( StringName right )

bool

operator >= ( StringName right )

Constructor Descriptions

Constructs an empty StringName.


Constructs a StringName as a copy of the given StringName.


Creates a new StringName from the given String. StringName("example") is equivalent to &"example".

Method Descriptions

  • int hash ( ) const

Returns the 32-bit hash value representing the StringName's contents.

Operator Descriptions