This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
API
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Учебные материалы

Unigine::StringStack class

Header: #include <UnigineString.h>

A string that is stored in a stack. By default, a StringStack variable reserves 256 bytes on the stack. Memory is allocated dynamically only when the data size exceeds the specified capacity.

Notice
If you know in advance that the data size will be large (for example, when reading a text from a file), use String instead.

Such strings are typically used in the following cases:

  • When you construct a string and use it only ones.
    Source code (C++)
    #include "AppWorldLogic.h"
    #include <UnigineString.h>
    #include <UnigineVector.h>
    #include <UnigineFileSystem.h>
    
    using namespace Unigine;
    
    StringStack<> AppWorldLogic::get_first_string() { return "This is a "; }
    StringStack<> AppWorldLogic::get_second_string() { return "string"; }
    
    void AppWorldLogic::my_file_write(FilePtr file, const char *s)
    {
    	file->writeString("Sample Text\n");
    	file->writeString(s);
    }
    
    int AppWorldLogic::init()
    {
    	// get a string
    	StringStack<> str = get_first_string();
    	// construct the string
    	str += get_second_string();
    
    	// somehow use the constructed string
    	FilePtr file = File::create();
    
    	file->open("file.txt", "wb");
    	if (file->isOpened())
    	{
    		my_file_write(file, str);
    		file->close();
    	}
    
    	return 1;
    }
  • When you perform operations on strings, the results are always stored in the stack.
    Source code (C++)
    const char *one = "one";
    const String two = get_second_string();
    // add one string to another
    StringStack<> s0 = one + two;
    StringStack<> s1 = two + two;
    
    const String file_name = file->getName();
    // get an extension if any
    StringStack<> ext = file_name.extension();
    Notice
    Pay attention to the type of the operation result to optimally use it and avoid issues.

StringStack Class

Members


static StringStackPtr create ( ) #

Default constructor that creates an empty string of the default size (256 characters).

static StringStackPtr create ( const String & s ) #

Copy constructor. Creates a string that stores a given string.

Arguments

  • const String & s - String to be copied.

static StringStackPtr create ( const StringStack<Capacity> & s ) #

Copy constructor.

Arguments

  • const StringStack<Capacity> & s - String stack of a specified size.

static StringStackPtr create ( const char * s ) #

Copy constructor.

Arguments

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

void destroy ( ) #

Destroys the string.

void StringStack<Capacity> ( StringStack<OtherCapacity> && s ) #

Copies a given string to the current string.

Arguments

  • StringStack<OtherCapacity> && s - String of a given size to be copied.

StringStack<Capacity> & operator= ( const StringStack<Capacity> & s ) #

Assignment operator for the string.

Arguments

  • const StringStack<Capacity> & s - String.

StringStack<Capacity> & operator= ( const char * s ) #

Assignment operator for the string.

Arguments

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

StringStack<Capacity> & operator= ( StringStack<OtherCapacity> && s ) #

Assignment operator for the string.

Arguments

  • StringStack<OtherCapacity> && s - String of the given size.

StringStack<Capacity> & operator= ( const String & s ) #

Assignment operator for the string.

Arguments

Last update: 02.08.2023
Build: ()