Elaztek Developer Hub
Blamite Game Engine - Strings  00386.06.16.23.0646.blamite
A library containing general purpose utilities and classes for use in multiple projects.
BlamStrings::Utils::String Namespace Reference

Utilities for working with and modifying strings. More...

Functions

STRINGS_API bool StartsWith (std::string string, std::string starts_with, bool case_insensetive=false)
 Determines whether or not a string starts with another string, case-insensetive. More...
 
STRINGS_API bool StartsWithAny (std::string string, std::vector< std::string > starts_with, bool case_insensetive=false)
 Determines whether or not a string starts with any one of multiple possible strings. More...
 
STRINGS_API bool EndsWith (std::string string, std::string ends_with, bool case_insensetive=false)
 Determines whether or not a string ends with another string, case-sensetive. More...
 
STRINGS_API bool EndsWithAny (std::string string, std::vector< std::string > ends_with, bool case_insensetive=false)
 Determines whether or not a string ends with any one of multiple possible strings. More...
 
STRINGS_API std::string Replace (std::string orig, std::string to_replace, std::string replace_with)
 Replaces part of a string with another string. More...
 
STRINGS_API std::string ToLower (std::string string)
 Transforms a string to all-lowercase. More...
 
STRINGS_API std::string ToUpper (std::string string)
 Transforms a string to all-uppercase. More...
 
STRINGS_API std::string FixDirectorySeparators (std::string string)
 Replaces any instance of \\ in a string with /. More...
 
STRINGS_API std::vector< std::string > Split (std::string string, std::string splitter)
 Splits a string around any instance of a substring. More...
 
STRINGS_API bool ContainsChar (std::string string, char contains)
 Determines whether or not a string contains the specified character. More...
 
STRINGS_API bool Contains (std::string string, std::string contains)
 Determines whether or not a string contains the specified substring. More...
 
STRINGS_API bool MemoryStringCompare (char *address, char *to_compare, int size)
 Checks the specified address in memory to see if it matches a given string, ignoring null terminators. More...
 
STRINGS_API std::string FormatStringForTagFieldID (std::string original_string)
 Reformats a standard display name string to be appropriate for a field ID. More...
 
STRINGS_API std::string FormatDecorativeHeaderComment (std::vector< std::string > lines)
 Generates a decorative header comment in the style used in some Blamite header/source files. More...
 

Detailed Description

Utilities for working with and modifying strings.

Function Documentation

◆ Contains()

bool BlamStrings::Utils::String::Contains ( std::string  string,
std::string  contains 
)

Determines whether or not a string contains the specified substring.

Parameters
string- The original string.
contains- The substring to look for.
Returns
Whether or not the string contains the specified substring.
+ Here is the caller graph for this function:

◆ ContainsChar()

bool BlamStrings::Utils::String::ContainsChar ( std::string  string,
char  contains 
)

Determines whether or not a string contains the specified character.

Parameters
string- The original string.
contains- The character to look for.
Returns
Whether or not the string contains the specified character.
+ Here is the caller graph for this function:

◆ EndsWith()

bool BlamStrings::Utils::String::EndsWith ( std::string  string,
std::string  ends_with,
bool  case_insensetive = false 
)

Determines whether or not a string ends with another string, case-sensetive.

Parameters
string- The original string.
ends_with- The string to test for.
case_sensetive- Whether or not the check is case insensetive. Defaults to false.
Returns
Whether or not the string ends with the specified suffix.
+ Here is the caller graph for this function:

◆ EndsWithAny()

bool BlamStrings::Utils::String::EndsWithAny ( std::string  string,
std::vector< std::string >  ends_with,
bool  case_insensetive = false 
)

Determines whether or not a string ends with any one of multiple possible strings.

Parameters
string- The original string.
ends_with- The list of strings to test for.
case_sensetive- Whether or not the check is case insensetive. Defaults to false.
Returns
Whether or not the string ends with any of the specified suffixes.
+ Here is the call graph for this function:

◆ FixDirectorySeparators()

std::string BlamStrings::Utils::String::FixDirectorySeparators ( std::string  string)

Replaces any instance of \\ in a string with /.

Unneccessary in most cases.

Parameters
string- The original string.
Returns
The original string with all path separators made uniform.
+ Here is the call graph for this function:

◆ FormatDecorativeHeaderComment()

std::string BlamStrings::Utils::String::FormatDecorativeHeaderComment ( std::vector< std::string >  lines)

Generates a decorative header comment in the style used in some Blamite header/source files.

The typical style used often displays as follows:

////////////////////////////////////////////////
// Blamite Game Engine - File Title          //
// Copyright (c) Elaztek Studios 2013-2022  //
/////////////////////////////////////////////
Parameters
lines- The list of lines to display within the comment.
Returns
A string containing the specified lines, formatted to display similar to the example comment.

◆ FormatStringForTagFieldID()

std::string BlamStrings::Utils::String::FormatStringForTagFieldID ( std::string  original_string)

Reformats a standard display name string to be appropriate for a field ID.

This will primarily strip out any special characters, as well as remove any spaces (replacing them with underscores) and converting the string to lowercase.

Note
Note that this will not check for any duplicate field IDs, those checks must be performed separately.
Parameters
original_string- The display name string to reformat.
Returns
An appropriate ID string based on the original input string.
+ Here is the call graph for this function:

◆ MemoryStringCompare()

bool BlamStrings::Utils::String::MemoryStringCompare ( char *  address,
char *  to_compare,
int  size 
)

Checks the specified address in memory to see if it matches a given string, ignoring null terminators.

One might be inclined to simply check the memory normally, but all strings are normally null-terminated. In certain cases, it may be useful to check for a specific set of bytes that are known to always contain text of a known length, that will always be followed by more data.

Parameters
address- Address of the start of the byte data.
to_compare- The string to check against.
size- The number of bytes within address to read as a string.
Returns
True if the bytes matched the provided string (w/o null terminator), False if the data didn't match.

◆ Replace()

std::string BlamStrings::Utils::String::Replace ( std::string  orig,
std::string  to_replace,
std::string  replace_with 
)

Replaces part of a string with another string.

Parameters
orig- The original string.
to_replace- The substring to replace.
replace_with- The string to replace any matches of the substring with.
Returns
The original string with any instances of the substring replaced.
+ Here is the caller graph for this function:

◆ Split()

std::vector< std::string > BlamStrings::Utils::String::Split ( std::string  string,
std::string  splitter 
)

Splits a string around any instance of a substring.

If string is "Bungie|Is|Cool", and splitter is "|", then the resulting string list would contain the following:

{["Bungie",}
</blockquote>
Similarly, if `string` was still "Bungie|Is|Cool", and `splitter` is set to "|Is|",
the resulting string list would be the following:
<blockquote>
```["Bungie", "Cool"

Parameters
string- The original string.
splitter- The string to act as the splitter.
Returns
A list of strings resulting from the split.
+ Here is the caller graph for this function:

◆ StartsWith()

bool BlamStrings::Utils::String::StartsWith ( std::string  string,
std::string  starts_with,
bool  case_insensetive = false 
)

Determines whether or not a string starts with another string, case-insensetive.

Parameters
string- The original string.
starts_with- The string to test for.
case_sensetive- Whether or not the check is case insensetive. Defaults to false.
Returns
Whether or not the string starts with the specified prefix.
+ Here is the caller graph for this function:

◆ StartsWithAny()

bool BlamStrings::Utils::String::StartsWithAny ( std::string  string,
std::vector< std::string >  starts_with,
bool  case_insensetive = false 
)

Determines whether or not a string starts with any one of multiple possible strings.

Parameters
string- The original string.
starts_with- The list of strings to test for.
case_sensetive- Whether or not the check is case insensetive. Defaults to false.
Returns
Whether or not the string starts with any of the specified prefixes.
+ Here is the call graph for this function:

◆ ToLower()

std::string BlamStrings::Utils::String::ToLower ( std::string  string)

Transforms a string to all-lowercase.

Parameters
string- The original string.
Returns
The original string with all characters changed to lowercase.
+ Here is the caller graph for this function:

◆ ToUpper()

std::string BlamStrings::Utils::String::ToUpper ( std::string  string)

Transforms a string to all-uppercase.

Parameters
string- The original string.
Returns
The original string with all characters changed to uppercase.
following
Use of this software is granted under one of the following two to be chosen freely by the user Boost Software License Version Marcin Kalicinski Permission is hereby free of to any person or organization obtaining a copy of the software and accompanying documentation covered by this and transmit the and to prepare derivative works of the and to permit third parties to whom the Software is furnished to do all subject to the following
Definition: license.txt:16