This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
Tutorials

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 once.
    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: 2024-08-16
Build: ()