Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Infinity::Util::StringUtils Class Reference

Utility functions for string manipulation and parsing. More...

#include <StringUtils.hpp>

Public Types

enum  ExecutableNameDelineation { LAST_PERIOD , DOUBLE_COLON }
 Specifies how to split executable/component full names. More...
 

Static Public Member Functions

static std::string combineExecutableGroupName (const std::string &group, const std::string &name)
 Combines group and name into a full executable identifier.
 
static std::array< std::string, 2 > splitExecutableFullname (std::string executableFullName, ExecutableNameDelineation delineation=LAST_PERIOD)
 Splits a full executable name into group and name parts.
 
static std::vector< std::string > split (std::string &str, char delimiter)
 Splits a string by a single character delimiter.
 
static std::vector< std::string > split (std::string &str, std::string &delimiter)
 Splits a string by a multi-character delimiter.
 

Detailed Description

Utility functions for string manipulation and parsing.

StringUtils provides common string operations used throughout the Infinity Engine, with particular focus on parsing component identifiers and splitting delimited strings. These utilities are primarily used for handling ProceduralComponent naming conventions and configuration parsing.

Key functionality:

  • Combining and splitting executable/component full names
  • Parsing group.name identifiers (e.g., "MyCompany.Components.MeshGenerator")
  • Generic string splitting with various delimiters
  • Component ID formatting and parsing
Note
All methods are static - no instance creation needed.

Member Enumeration Documentation

◆ ExecutableNameDelineation

Specifies how to split executable/component full names.

Enumerator
LAST_PERIOD 

Split at the last period (e.g., "Group.SubGroup.Name" -> ["Group.SubGroup", "Name"])

DOUBLE_COLON 

Split at double colon (e.g., "Group::Name" -> ["Group", "Name"])

Member Function Documentation

◆ combineExecutableGroupName()

static std::string Infinity::Util::StringUtils::combineExecutableGroupName ( const std::string &  group,
const std::string &  name 
)
static

Combines group and name into a full executable identifier.

Creates a fully qualified name by joining group and name with a period. Used for generating ComponentID strings and executable identifiers.

Parameters
groupThe group/namespace part (e.g., "MyCompany.Components").
nameThe name part (e.g., "MeshGenerator").
Returns
Combined full name (e.g., "MyCompany.Components.MeshGenerator").
"ProceduralTools.Terrain",
"HeightmapGenerator"
);
// Result: "ProceduralTools.Terrain.HeightmapGenerator"
static std::string combineExecutableGroupName(const std::string &group, const std::string &name)
Combines group and name into a full executable identifier.

◆ split() [1/2]

static std::vector< std::string > Infinity::Util::StringUtils::split ( std::string &  str,
char  delimiter 
)
static

Splits a string by a single character delimiter.

Parses a string into substrings separated by the specified delimiter character.

Parameters
strString to split.
delimiterCharacter to split on.
Returns
Vector of substrings.
std::string path = "models/terrain/heightmap.png";
auto parts = StringUtils::split(path, '/');
// parts = ["models", "terrain", "heightmap.png"]
std::string csv = "apple,banana,cherry";
auto items = StringUtils::split(csv, ',');
// items = ["apple", "banana", "cherry"]
static std::vector< std::string > split(std::string &str, char delimiter)
Splits a string by a single character delimiter.

◆ split() [2/2]

static std::vector< std::string > Infinity::Util::StringUtils::split ( std::string &  str,
std::string &  delimiter 
)
static

Splits a string by a multi-character delimiter.

Parses a string into substrings separated by the specified delimiter string.

Parameters
strString to split.
delimiterString delimiter to split on.
Returns
Vector of substrings.
std::string data = "part1::part2::part3";
std::string delim = "::";
auto parts = StringUtils::split(data, delim);
// parts = ["part1", "part2", "part3"]

◆ splitExecutableFullname()

static std::array< std::string, 2 > Infinity::Util::StringUtils::splitExecutableFullname ( std::string  executableFullName,
ExecutableNameDelineation  delineation = LAST_PERIOD 
)
static

Splits a full executable name into group and name parts.

Parses a fully qualified executable name into its constituent group and name components using the specified delineation strategy.

Parameters
executableFullNameThe full name to split (e.g., "Group.SubGroup.Name").
delineationHow to split the name (LAST_PERIOD or DOUBLE_COLON).
Returns
Array with [0] = group, [1] = name.
Note
LAST_PERIOD splits at the final period, keeping all previous parts as group.
DOUBLE_COLON splits at "::" delimiter.
// Using LAST_PERIOD (default)
"MyCompany.Components.MeshGenerator"
);
// parts[0] = "MyCompany.Components"
// parts[1] = "MeshGenerator"
// Using DOUBLE_COLON
"MyNamespace::MyComponent",
);
// parts2[0] = "MyNamespace"
// parts2[1] = "MyComponent"
@ DOUBLE_COLON
Split at double colon (e.g., "Group::Name" -> ["Group", "Name"])
Definition StringUtils.hpp:39
static std::array< std::string, 2 > splitExecutableFullname(std::string executableFullName, ExecutableNameDelineation delineation=LAST_PERIOD)
Splits a full executable name into group and name parts.