![]() |
Blamite Game Engine - Strings
00453.06.08.26.0624.blamite
A library containing general purpose utilities and classes for use in multiple projects.
|
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 | Replace (std::string orig, char to_replace, char replace_with) |
| Replaces all instances of a specific character with another charater in a 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, bool ignore_case=false) |
| Determines whether or not a string contains the specified substring. More... | |
| STRINGS_API bool | ContainsAny (std::string string, std::vector< std::string > contains, bool ignore_case=false) |
| Determines whether or not a string contains any of the specified substrings. 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... | |
| STRINGS_API std::string | Capitalize (std::string original_string, bool remove_spaces=false) |
| Capitalizes the first character within each word within a string. More... | |
| STRINGS_API std::string | BuildFromList (std::vector< std::string > list, std::string splitter=",") |
| Creates a separated list from a list of strings. More... | |
| STRINGS_API std::string | ParseStringFromXMLValue (std::string string) |
| Performs a number of modifications and tweaks to a string. More... | |
| STRINGS_API std::string | FormatStringForXML (std::string string, std::string prefix="") |
| Formats a string to be XML safe/friendly. More... | |
Utilities for working with and modifying strings.
| std::string BlamStrings::Utils::String::BuildFromList | ( | std::vector< std::string > | list, |
| std::string | splitter = "," |
||
| ) |
Creates a separated list from a list of strings.
This is essentially the reverse of the Split function, as it takes a list of strings and creates a separated list from them. For instance, if the provided list contains the items bitm, prt3, and sbsp, and the splitter was set to , then the resulting string would be bitm,prt3,sbsp.
| list | - The list of strings to create into a combined string. |
| splitter | - The separator used to separate each string. Defaults to ,. |
| std::string BlamStrings::Utils::String::Capitalize | ( | std::string | original_string, |
| bool | remove_spaces = false |
||
| ) |
Capitalizes the first character within each word within a string.
This will iterate through the string, replacing the first character within each word throughout the entire string. For example, the string test string hello would become Test String Hello. Additionally, if the remove_spaces parameter is set to true, then any spaces will be removed - in which case, the above string would become TestStringHello.
| original_string | - The string to capitalize. |
| remove_spaces | - If set to true, then any spaces will be removed from the string. |
Here is the call graph for this function:| bool BlamStrings::Utils::String::Contains | ( | std::string | string, |
| std::string | contains, | ||
| bool | ignore_case = false |
||
| ) |
Determines whether or not a string contains the specified substring.
| string | - The original string. |
| contains | - The substring to look for. |
| ignore_case | - Whether or not to ignore case sensitivity when searching. |
Here is the call graph for this function:
Here is the caller graph for this function:| bool BlamStrings::Utils::String::ContainsAny | ( | std::string | string, |
| std::vector< std::string > | contains, | ||
| bool | ignore_case = false |
||
| ) |
Determines whether or not a string contains any of the specified substrings.
| string | - The original string. |
| contains | - The list of substrings to look for. |
| ignore_case | - Whether or not to ignore case sensitivity when searching. |
Here is the call graph for this function:| bool BlamStrings::Utils::String::ContainsChar | ( | std::string | string, |
| char | contains | ||
| ) |
Determines whether or not a string contains the specified character.
| string | - The original string. |
| contains | - The character to look for. |
Here is the caller graph for this function:| 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.
| string | - The original string. |
| ends_with | - The string to test for. |
| case_sensetive | - Whether or not the check is case insensetive. Defaults to false. |
Here is the caller graph for this function:| 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.
| 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. |
Here is the call graph for this function:| std::string BlamStrings::Utils::String::FixDirectorySeparators | ( | std::string | string | ) |
Replaces any instance of \\ in a string with /.
Unneccessary in most cases.
| string | - The original string. |
Here is the call graph for this function:| 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 // /////////////////////////////////////////////
| lines | - The list of lines to display within the comment. |
| 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. Additionally, if the string starts with a number, then an underscore will be placed at the start of the string.
| original_string | - The display name string to reformat. |
Here is the call graph for this function:| std::string BlamStrings::Utils::String::FormatStringForXML | ( | std::string | string, |
| std::string | prefix = "" |
||
| ) |
| 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.
| 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. |
| std::string BlamStrings::Utils::String::ParseStringFromXMLValue | ( | std::string | string | ) |
Performs a number of modifications and tweaks to a string.
This function is often used in cases where strings are read from an XML document, such as XML string tables. It makes a number of modifications to the string to ensure that it displays properly when used, often by removing or replacing parts of the string that are present to make it more readable within an XML document. This typically includes things such as indentation, line breaks, and longer amounts of blank space.
It also replaces several special placeholders that can be used within XML documents to achieve results that would normally be removed during the parsing process. The full list of changes made includes:
\r\n) and LF (\n) line breaks are stripped from the string\n is parsed to a LF line breakexample text would become example text is converted to a space - this is performed after the removal of extra spaces, and as such, can be used when multiple adjacent spaces are desired| string | - The string to apply the modifications to. |
Here is the call graph for this function:
Here is the caller graph for this function:| std::string BlamStrings::Utils::String::Replace | ( | std::string | orig, |
| char | to_replace, | ||
| char | replace_with | ||
| ) |
Replaces all instances of a specific character with another charater in a string.
| orig | - The original string. |
| to_replace | - The character to replace. |
| replace_with | - The character to replace any matches of the original character with. |
| 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.
| orig | - The original string. |
| to_replace | - The substring to replace. |
| replace_with | - The string to replace any matches of the substring with. |
Here is the caller graph for this function:| 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"
| string | - The original string. |
| splitter | - The string to act as the splitter. |
Here is the caller graph for this function:| 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.
| string | - The original string. |
| starts_with | - The string to test for. |
| case_sensetive | - Whether or not the check is case insensetive. Defaults to false. |
Here is the caller graph for this function:| 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.
| 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. |
Here is the call graph for this function:| std::string BlamStrings::Utils::String::ToLower | ( | std::string | string | ) |
Transforms a string to all-lowercase.
| string | - The original string. |
Here is the caller graph for this function:| std::string BlamStrings::Utils::String::ToUpper | ( | std::string | string | ) |
Transforms a string to all-uppercase.
| string | - The original string. |