This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unigine::String class

Header:#include <UnigineString.h>

Provides an interface to work with input and output data packed into internal (not C++ standard) String class.

For example, Unigine::String class can be used when you pass the data from UnigineScript to C++.

String Class

Members


String()

Default constructor that creates an empty string.

String(const String & s)

Copy constructor.

Arguments

  • const String & s - String to be copied.

String(const char * s)

Explicit constructor.

Arguments

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

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.

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.

const char * get()

Returns the pointer to the null-terminated string.

Return value

The null-terminated string.

double getDouble()

Returns the current string as a double value.

Return value

The value of the variable.

float getFloat()

Returns the current string as a float value.

Return value

The value of the variable.

int getInt()

Returns the current string as a integer value.

Return value

The value of the variable.

long long getLong()

Returns the current string as a long long value.

Return value

The value of the variable.

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, char c)

Appends the symbol.

Arguments

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

void append(char c)

Appends the symbol.

Arguments

  • char c - The symbol to append.

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

String basename()

Returns file name.

Return value

The string.

void clear()

Clears the string.

void destroy()

Destroys the string.

String dirname()

Returns directory name.

Return value

The string.

int empty()

Returns an empty flag.

Return value

1 if the string is empty; otherwise, 0.

String extension()

Returns extension name.

Return value

Extension name.

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

Returns a formatted string. For more details, see the description of String::format.

Arguments

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

Return value

The formatted string.

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.

String memory(size_t memory)

Returns memory amount string.

Arguments

  • size_t memory - Amount of memory.

Return value

String representation.

String & operator+=(const String & s)

String addition.

Arguments

  • const String & s - The second string.

String & operator+=(const char * s)

Symbol addition.

Arguments

  • const char * s - The symbol.

String & operator+=(char c)

Symbol addition.

Arguments

  • char c - The symbol.

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.

char & operator[](int index)

Array access.

Arguments

  • int index - Array item index.

Return value

The array item.

char operator[](int index)

Constant array access.

Arguments

  • int index - Array item index.

Return value

The array item.

String pathname()

Returns directory name.

Return value

Directory name.

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

Initializes a formatted string.

Arguments

  • const char * format - Format 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.

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

Replaces one string to another.

Arguments

  • const char * before - String before.
  • const char * after - String after.

Return value

The string.

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

Scans a formatted string.

Arguments

  • const char * format - Format string.

Return value

Number of arguments successfully read, or EOF if failure occurs.

int size()

Returns the size of the string.

Return value

The size of the string.

String substr(int pos, int size)

Returns the sub-string.

Arguments

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

Return value

Sub-string string.

String trim(const char * symbols)

Removes the specified symbols from the beginning and the ending.

Arguments

  • const char * symbols - Symbols to remove.

Return value

The string.

int utf8strlen()

Returns the wide-character length of string.

Return value

Length of the wide-character string.

String utf8substr(int pos, int size)

Returns the wide-character sub-string.

Arguments

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

Return value

Sub-string string.

int utf8ToUnicode(wchar_t * dest, int size)

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

Return value

Length of the wide-character string.

int utf8ToUnicode(unsigned int * dest, int size)

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

void vprintf(const char * format, va_list argptr)

Initializes a formatted string.

Arguments

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

int vscanf(const char * format, va_list argptr)

Scans a formatted string.

Arguments

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

Return value

Number of arguments successfully read, or EOF if failure occurs.
Last update: 2017-12-21
Build: ()