Getting Started
Migrating to UNIGINE 2.0
C++ API Migration
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins

Unigine::String Class

String class.

To use this class, include the UnigineString.h file.

Unigine::String Class

Members


String ()

Default constructor that creates an empty string.

String (const String & s)

Copy constructor.

Arguments

  • const String & s - String.

explicit String (const char * s)

Explicit constructor.

Arguments

  • const char * s - Pointer to the null-terminated string.

explicit String (const wchar_t * s)

Explicit constructor for a wide-character string.

Arguments

  • const wchar_t * s - Pointer to the wide-character null-terminated string.

explicit String (const unsigned int * s)

Explicit constructor for a wide-character string.

Arguments

  • const unsigned int * s - Pointer to the wide-character null-terminated string.

~String ()

Destructor.

UNIGINE_INLINE const char * get () const

Returns the pointer to the null-terminated string.

Return value

The null-terminated string.

UNIGINE_INLINE int size () const

Returns the size of the string.

Return value

The size of the string.

UNIGINE_INLINE int empty () const

Returns the 1 if the string is empty; otherwise, 0 is returned.

Return value

The empty flag.

void clear ()

Clears the string.

void destroy ()

Destroys the string.

void append (char c)

Appends the symbol.

Arguments

  • char c - The symbol

void append (const char * s, int size)

Appends the string.

Arguments

  • const char * s - The null-terminated string to append.
  • int size - The length of the string.

void append (const String & s, int size)

Appends the string.

Arguments

  • const String & s - The source string to append.
  • int size - The length of the string.

void append (int pos, char c)

Appends the symbol.

Arguments

  • int pos - Insertion position.
  • char c - The symbol

void append (int pos, const char * s, int size)

Appends the string.

Arguments

  • int pos - Insertion position.
  • const char * s - The null-terminated string to append.
  • int size - The length of the string.

void append (int pos, const String & s, int size)

Inserts the string at the given position.

Arguments

  • int pos - Insertion position.
  • const String & s - The source string to insert.
  • int size - The length of the string.

void remove ()

Removes the last symbol of the string.

void remove (int pos, int size)

Removes symbols at the given position from the string.

Arguments

  • int pos - Removal position.
  • int size - The number of symbols to remove.

void vprintf (const char * format, va_list argptr)

Initializes a formatted string.

Arguments

  • const char * format - Format string.
  • va_list argptr - Arguments pointer.

void printf (const char * format, ...)

Initializes a formatted string.

Arguments

  • const char * format - Format string.
  • ... - Arguments pointer, multiple allowed.

void int vscanf (const char * format, va_list argptr)

Scans a formatted string.

Arguments

  • const char * format - Format string.
  • va_list argptr - Arguments pointer.

int scanf (const char * format, ...)

Scans a formatted string.

Arguments

  • const char * format - Format string.
  • ... - Arguments pointer, multiple allowed.

String String trim (const char * symbols) const

Removes the specified symbols from the beginning and the ending.

Arguments

  • const char * symbols - Symbols to remove.

Return value

The string.

String replace (const char * before, const char * after) const

Replaces one string to another.

Arguments

  • const char * before - The before string.
  • const char * after - The after string.

Return value

The string.

String substr (int pos, int size) const

Return the sub-string.

Arguments

  • int pos - Starting position.
  • int size - Sub-string length.

Return value

Sub-string string.

String dirname () const

Return directory name.

Return value

The string.

String basename () const

Return file name.

Return value

The string.

String pathname () const

Return directory name.

Return value

The string.

String extension () const

Return extension name.

Return value

The string.

int utf8ToUnicode (wchar_t * dest, int size) const

Converts a string into the wide-character string.

Arguments

  • wchar_t * dest - Pointer to the wide-character string.
  • int size - Size of wide-character string in simbols.

Return value

Length of the wide-character string.

int utf8ToUnicode (unsigned int * dest, int size) const

Converts a string into the wide-character string.

Arguments

  • unsigned int * dest - Pointer to the wide-character string.
  • int size - Size of wide-character string in simbols.

Return value

Length of the wide-character string.

int utf8strlen () const

Return the wide-character length of string.

Return value

Length of the wide-character string.

String utf8substr (int pos, int size) const

Return the wide-character sub-string.

Arguments

  • int pos - Starting position.
  • int size - Sub-string length.

Return value

Sub-string string.

int getInt () const

Return the current string as a integer value.

Return value

The value of the variable.

long long getLong () const

Return the current string as a long long value.

Return value

The value of the variable.

float getFloat () const

Return the current string as a float value.

Return value

The value of the variable.

double getDouble () const

Return the current string as a double value.

Return value

The value of the variable.

String & operator= (const char * s)

Assignment operator for the string.

Arguments

  • const char * s - The null-terminated string.

String & operator= (const String & s)

Assignment operator for the string.

Arguments

  • const String & s - The value of the string.

String & operator+= (char c)

Symbol addition.

Arguments

  • char c - The symbol.

String & operator+= (const char * s)

String addition.

Arguments

  • const char * s - The null-terminated string.

String & operator+= (const String & s)

String addition.

Arguments

  • const String & s - The second string.

UNIGINE_INLINE char & operator[] (int index)

Array access.

Arguments

  • int index - Array item index.

Return value

The array item.

UNIGINE_INLINE char operator[] (int index) const

Constant array access.

Arguments

  • int index - Array item index.

Return value

The array item.

static int static String memory (size_t memory)

Returns memory amount string.

Arguments

  • size_t memory - Amount of memory.

Return value

String representation.

static String format (const char * format, va_list argptr)

Returns a formatted string. A format string is composed of zero or more ordinary characters (excluding %) that are copied directly to the result string and control sequences, each of which results in fetching its own parameter. Each control sequence consists of a percent sign (%) followed by one or more of these elements, in order:
  • An optional number, a width specifier, that says how many characters (minimum) this conversion should result in.
  • An optional precision specifier that says how many decimal digits should be displayed for floating-point numbers.
  • A type specifier that says what type the argument data should be treated as. Possible types:
  • c: the argument is treated as an integer and presented as a character with that ASCII value.
  • d or i: the argument is treated as an integer and presented as a (signed) decimal number.
  • o: the argument is treated as an integer and presented as an octal number.
  • u: the argument is treated as an integer and presented as an unsigned decimal number.
  • x: the argument is treated as an integer and presented as a hexadecimal number (with lowercase letters).
  • X: the argument is treated as an integer and presented as a hexadecimal number (with uppercase letters).
  • f: the argument is treated as a float and presented as a floating-point number.
  • g: the same as e or f, the shortest one is selected.
  • G: the same as E or F, the shortest one is selected.
  • e: the argument is treated as using the scientific notation with lowercase 'e' (e.g. 1.2e+2).
  • E: the argument is treated as using the scientific notation with uppercase 'E' (e.g. 1.2E+2).
  • s: the argument is treated as and presented as a string.
  • p: the argument is treated as and presented as a pointer address.
  • %: a literal percent character. No argument is required.

Arguments

  • const char * format - Format string.
  • va_list argptr - Arguments pointer.

Return value

The formatted string.

static String format (const char * format, ...)

Returns a formatted string. For more details see the description above.

Arguments

  • const char * format - Format string.
  • ... - Arguments pointer, multiple allowed.

Return value

The formatted string.
Last update: 2017-07-03