C4 Engine
C4 Engine API Documentation

StringTable::GetString

Defined in:  C4StringTable.h
Retrieves a particular string from a string table.
Prototype

const char *GetString(const StringID& stringID) const;

Parameters
stringID The identifier of the string to retrieve.
Description
The GetString function locates the string having the identifier specified by the stringID parameter inside a string table and returns a pointer to it. If the string does not exist, then the return value is a pointer to a special missing string. It is never the case that nullptr is returned. The StringTable::MissingString function can be used to determine whether the missing string was returned.

The StringID object passed to the GetString function holds between one and five 32-bit identifiers that are usually specified as four-character codes, and they are passed to the StringID constructor as a comma-separated list. These identifiers represent the unique path to the string in the hierarchical structure of the string table.

A string at the top level of the string table having an ID of 'abcd' would be retrieved using the following code.
const char *string = stringTable->GetString(StringID('abcd'));
As another example, a string located three levels deep would be retrieved using the following code.
const char *string = stringTable->GetString(StringID('abcd', 'efgh', 'ijkl'));
See Also

StringTable::MissingString