Functions for dealing with strings.
Definition at line 18 of file VuoStringUtilities.hh.
Static Public Member Functions | |
static bool | beginsWith (string wholeString, string beginning) |
Returns true if wholeString begins with beginning . More... | |
static bool | endsWith (string wholeString, string ending) |
Returns true if wholeString ends with ending . More... | |
static string | substrAfter (string wholeString, string beginning) |
Returns the substring of wholeString that follows beginning , or an empty string if wholeString does not begin with beginning . More... | |
static string | substrBefore (string wholeString, string ending) |
Returns the substring of wholeString that precedes ending , or an empty string if wholeString does not end with ending . More... | |
static string | replaceAll (string wholeString, char originalChar, char replacementChar) |
Returns a string constructed by replacing all instances of originalChar with replacementChar in wholeString . More... | |
static size_t | replaceAll (string &wholeString, string originalSubstring, string replacementSubstring) |
Replaces all instances of originalSubstring with replacementSubstring in wholeString. More... | |
static vector< string > | split (const string &wholeString, char delimiter) |
Splits wholeString into parts, as separated by delimiter. More... | |
static string | join (vector< string > partialStrings, char delimiter) |
Combines partialStrings, separated by delimiter, into one string. More... | |
static string | join (vector< string > partialStrings, string delimiter) |
Combines partialStrings, separated by delimiter, into one string. More... | |
static string | join (set< string > partialStrings, string delimiter) |
Combines partialStrings, separated by delimiter, into one string. More... | |
static string | trim (string originalString) |
Returns a new string with the whitespace removed from the beginning and end. More... | |
static string | buildCompositionIdentifier (const string &parentCompositionIdentifier, const string &nodeIdentifier) |
Returns a string that starts with parentCompositionIdentifier and ends with nodeIdentifier. More... | |
static string | buildPortIdentifier (const string &nodeIdentifier, const string &portName) |
Returns a string that starts with nodeIdentifier and ends with portName. More... | |
static string | prefixSymbolName (string symbolName, string moduleKey) |
Returns a string that starts with moduleKey and ends with symbolName. More... | |
static bool | isValidCharInIdentifier (char ch) |
Check whether a character is valid for an identifier, i.e., matches [A-Za-z0-9_]. More... | |
static string | transcodeToIdentifier (string str) |
Transforms a string into a valid identifier: More... | |
static string | transcodeToGraphvizIdentifier (const string &originalString) |
Escapes backslashes, quotes, curly braces, angle brackets, and pipes in the string, making it a valid identifier in the Graphviz DOT language. More... | |
static string | transcodeFromGraphvizIdentifier (const string &graphvizIdentifier) |
Removes escapes for backslashes, quotes, curly braces, angle brackets, and pipes in the Graphviz identifier, making it a normal string. More... | |
static string | formUniqueIdentifier (set< string > &takenIdentifiers, const string &preferredIdentifier, const string &identifierPrefix="") |
Returns preferredIdentifier if it's available (not already in usedIdentifiers), otherwise creates an identifier that is available by adding a suffix to identifierPrefix (if provided) or preferredIdentifier. More... | |
static string | formUniqueIdentifier (std::function< bool(const string &)> isIdentifierAvailable, const string &preferredIdentifier, const string &identifierPrefix="") |
Returns preferredIdentifier if it's available (according to isIdentifierAvailable), otherwise creates an identifier that is available by adding a suffix to identifierPrefix (if provided) or preferredIdentifier. More... | |
static string | generateHtmlFromMarkdown (const string &markdownString) |
Converts markdownString (a Markdown document) to HTML. More... | |
static string | generateHtmlFromMarkdownLine (const string &markdownString) |
Converts markdownString (a single line of Markdown text) to HTML. More... | |
static string | convertToCamelCase (const string &originalString, bool capitalizeFirstLetter, bool forceFirstLetterToLower, bool forceInterveningLettersToLower, bool allowSeparatorDots=false) |
Collapses a string into camel case by removing non-alphanumeric characters and adjusting capitalization. More... | |
static string | expandCamelCase (string camelCaseString) |
Inserts spaces at CamelCase transitions within the input camelCaseString , capitalizes the first letter of the string, and returns the result. More... | |
static string | makeFromCFString (const void *cfs) |
Creates a string from a CFStringRef . More... | |
static string | makeRandomHash (int length) |
Returns a random sequence of alphanumeric characters. More... | |
static long | hash (const string &s) |
Generates an integer hash value for the string. More... | |
static string | calculateSHA256 (const string &s) |
Returns the SHA-256 hash of the string s , as a string of hex digits. More... | |
Static Public Attributes | |
static const std::locale | locale |
For hashing strings. More... | |
static const std::collate< char > & | collate = std::use_facet<std::collate<char> >(VuoStringUtilities::locale) |
For hashing strings. More... | |
|
static |
Returns true if wholeString
begins with beginning
.
Definition at line 24 of file VuoStringUtilities.cc.
|
static |
Returns a string that starts with parentCompositionIdentifier and ends with nodeIdentifier.
The glue between them is a non-identifier character so that the string can be unambiguously split later.
This needs to be kept in sync with VuoCompilerNode::generateSubcompositionIdentifierValue().
Definition at line 176 of file VuoStringUtilities.cc.
|
static |
Returns a string that starts with nodeIdentifier and ends with portName.
The glue between them is a non-identifier character so that the string can be unambiguously split later.
Definition at line 185 of file VuoStringUtilities.cc.
|
static |
Returns the SHA-256 hash of the string s
, as a string of hex digits.
VuoException |
Definition at line 578 of file VuoStringUtilities.cc.
|
static |
Collapses a string into camel case by removing non-alphanumeric characters and adjusting capitalization.
Also removes non-alpha leading characters.
originalString | The input. |
forceFirstLetterToUpper | If true, make the string UpperCamelCase. Otherwise, leave the first letter as-is. |
forceFirstLetterToLower | If true, make the string lowerCamelCase. Otherwise, leave the first letter as-is. |
forceInterveningLettersToLower | If true, make letters within words lowercase. Otherwise, leave them as-is. |
allowSeparatorDots | If true, intermediate dots (. ) are preserved. Leading, consecutive intermediate, and trailing dots are omitted. Letters following dots are not forced to uppercase. |
Definition at line 408 of file VuoStringUtilities.cc.
|
static |
Returns true if wholeString
ends with ending
.
Definition at line 32 of file VuoStringUtilities.cc.
|
static |
Inserts spaces at CamelCase transitions within the input camelCaseString
, capitalizes the first letter of the string, and returns the result.
Also renders standalone variable names (e.g., "x") and some common abbreviations (e.g., "rgb") in all-caps.
Definition at line 462 of file VuoStringUtilities.cc.
|
static |
Returns preferredIdentifier if it's available (not already in usedIdentifiers), otherwise creates an identifier that is available by adding a suffix to identifierPrefix (if provided) or preferredIdentifier.
The returned identifier is added to usedIdentifiers.
Definition at line 321 of file VuoStringUtilities.cc.
|
static |
Returns preferredIdentifier if it's available (according to isIdentifierAvailable), otherwise creates an identifier that is available by adding a suffix to identifierPrefix (if provided) or preferredIdentifier.
Definition at line 339 of file VuoStringUtilities.cc.
|
static |
Converts markdownString
(a Markdown document) to HTML.
The returned HTML includes a paragraph wrapper around each line of text.
Definition at line 361 of file VuoStringUtilities.cc.
|
static |
Converts markdownString
(a single line of Markdown text) to HTML.
The returned HTML does not include a paragraph wrapper.
Definition at line 382 of file VuoStringUtilities.cc.
|
inlinestatic |
Generates an integer hash value for the string.
Definition at line 56 of file VuoStringUtilities.hh.
|
static |
Check whether a character is valid for an identifier, i.e., matches [A-Za-z0-9_].
Definition at line 259 of file VuoStringUtilities.cc.
|
static |
Combines partialStrings, separated by delimiter, into one string.
Definition at line 138 of file VuoStringUtilities.cc.
|
static |
Combines partialStrings, separated by delimiter, into one string.
Definition at line 114 of file VuoStringUtilities.cc.
|
static |
Combines partialStrings, separated by delimiter, into one string.
Definition at line 123 of file VuoStringUtilities.cc.
|
static |
Creates a string from a CFStringRef
.
Definition at line 531 of file VuoStringUtilities.cc.
|
static |
Returns a random sequence of alphanumeric characters.
Definition at line 556 of file VuoStringUtilities.cc.
|
static |
Returns a string that starts with moduleKey and ends with symbolName.
Useful for adding a unique prefix to a symbol name.
Definition at line 194 of file VuoStringUtilities.cc.
|
static |
Replaces all instances of originalSubstring with replacementSubstring in wholeString.
Returns the number of instances replaced.
Definition at line 85 of file VuoStringUtilities.cc.
|
static |
Returns a string constructed by replacing all instances of originalChar
with replacementChar
in wholeString
.
Definition at line 68 of file VuoStringUtilities.cc.
|
static |
Splits wholeString into parts, as separated by delimiter.
Definition at line 101 of file VuoStringUtilities.cc.
|
static |
Returns the substring of wholeString
that follows beginning
, or an empty string if wholeString
does not begin with beginning
.
Definition at line 44 of file VuoStringUtilities.cc.
|
static |
Returns the substring of wholeString
that precedes ending
, or an empty string if wholeString
does not end with ending
.
Definition at line 56 of file VuoStringUtilities.cc.
|
static |
Removes escapes for backslashes, quotes, curly braces, angle brackets, and pipes in the Graphviz identifier, making it a normal string.
Definition at line 292 of file VuoStringUtilities.cc.
|
static |
Escapes backslashes, quotes, curly braces, angle brackets, and pipes in the string, making it a valid identifier in the Graphviz DOT language.
Definition at line 267 of file VuoStringUtilities.cc.
|
static |
Transforms a string into a valid identifier:
Definition at line 205 of file VuoStringUtilities.cc.
|
static |
Returns a new string with the whitespace removed from the beginning and end.
This function trims ASCII spaces, tabs, and linebreaks, but not other Unicode whitespace characters.
Definition at line 157 of file VuoStringUtilities.cc.
|
static |
For hashing strings.
Definition at line 62 of file VuoStringUtilities.hh.
|
static |
For hashing strings.
Definition at line 61 of file VuoStringUtilities.hh.