Functions for dealing with strings.
Definition at line 18 of file VuoStringUtilities.hh.
Static Public Member Functions | |
static bool | beginsWith (const string &wholeString, const string &beginning) |
Returns true if wholeString begins with beginning . | |
static bool | beginsWith (const char *wholeString, const char *beginning) |
Returns true if wholeString begins with beginning . | |
static bool | endsWith (const string &wholeString, const string &ending) |
Returns true if wholeString ends with ending . | |
static string | substrAfter (const string &wholeString, const string &beginning) |
Returns the substring of wholeString that follows beginning , or an empty string if wholeString does not begin with beginning . | |
static string | substrBefore (const string &wholeString, const string &ending) |
Returns the substring of wholeString that precedes ending , or an empty string if wholeString does not end with ending . | |
static string | replaceAll (const string &wholeString, char originalChar, char replacementChar) |
Returns a string constructed by replacing all instances of originalChar with replacementChar in wholeString . | |
static size_t | replaceAll (string &wholeString, const string &originalSubstring, const string &replacementSubstring) |
Replaces all instances of originalSubstring with replacementSubstring in wholeString. | |
static vector< string > | split (const string &wholeString, char delimiter) |
Splits wholeString into parts, as separated by delimiter. | |
static string | join (const vector< string > &partialStrings, char delimiter) |
Combines partialStrings, separated by delimiter, into one string. | |
static string | join (const vector< string > &partialStrings, const string &delimiter) |
Combines partialStrings, separated by delimiter, into one string. | |
static string | join (const set< string > &partialStrings, const string &delimiter) |
Combines partialStrings, separated by delimiter, into one string. | |
static string | trim (const string &originalString) |
Returns a new string with the whitespace removed from the beginning and end. | |
static void | doForEachLine (const string &multiLineString, std::function< void(const char *)> doForLine) |
Iiterates through the lines in multiLineString and calls doForLine for each one. | |
static string | buildCompositionIdentifier (const string &parentCompositionIdentifier, const string &nodeIdentifier) |
Returns a string that starts with parentCompositionIdentifier and ends with nodeIdentifier. | |
static string | buildPortIdentifier (const string &nodeIdentifier, const string &portName) |
Returns a string that starts with nodeIdentifier and ends with portName. | |
static string | prefixSymbolName (const string &symbolName, const string &moduleKey) |
Returns a string that starts with moduleKey and ends with symbolName. | |
static bool | isValidCharInIdentifier (char ch) |
Check whether a character is valid for an identifier, i.e., matches [A-Za-z0-9_]. | |
static string | transcodeToIdentifier (const string &str) |
Transforms a string into a valid identifier: | |
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. | |
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. | |
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. | |
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. | |
static string | generateHtmlFromMarkdown (const string &markdownString) |
Converts markdownString (a Markdown document) to HTML. | |
static string | generateHtmlFromMarkdownLine (const string &markdownString) |
Converts markdownString (a single line of Markdown text) to HTML. | |
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. | |
static string | expandCamelCase (const string &camelCaseString) |
Inserts spaces at CamelCase transitions within the input camelCaseString , capitalizes the first letter of the string, and returns the result. | |
static string | makeFromCFString (const void *cfs) |
Creates a string from a CFStringRef . | |
static string | makeRandomHash (int length) |
Returns a random sequence of alphanumeric characters. | |
static long | hash (const string &s) |
Generates an integer hash value for the string. | |
static string | calculateSHA256 (const string &s) |
Returns the SHA-256 hash of the string s , as a string of hex digits. | |
Static Public Attributes | |
static const std::locale | locale |
For hashing strings. | |
static const std::collate< char > & | collate = std::use_facet<std::collate<char> >(VuoStringUtilities::locale) |
For hashing strings. | |
Returns true if wholeString
begins with beginning
.
Definition at line 32 of file VuoStringUtilities.cc.
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 220 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 229 of file VuoStringUtilities.cc.
Returns the SHA-256 hash of the string s
, as a string of hex digits.
VuoException |
Definition at line 632 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 462 of file VuoStringUtilities.cc.
|
static |
Iiterates through the lines in multiLineString and calls doForLine for each one.
Definition at line 181 of file VuoStringUtilities.cc.
Returns true if wholeString
ends with ending
.
Definition at line 40 of file VuoStringUtilities.cc.
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 516 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 375 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 393 of file VuoStringUtilities.cc.
Converts markdownString
(a Markdown document) to HTML.
The returned HTML includes a paragraph wrapper around each line of text.
Definition at line 415 of file VuoStringUtilities.cc.
Converts markdownString
(a single line of Markdown text) to HTML.
The returned HTML does not include a paragraph wrapper.
Definition at line 436 of file VuoStringUtilities.cc.
Generates an integer hash value for the string.
Definition at line 58 of file VuoStringUtilities.hh.
Check whether a character is valid for an identifier, i.e., matches [A-Za-z0-9_].
Definition at line 313 of file VuoStringUtilities.cc.
|
static |
Combines partialStrings, separated by delimiter, into one string.
Definition at line 146 of file VuoStringUtilities.cc.
Combines partialStrings, separated by delimiter, into one string.
Definition at line 122 of file VuoStringUtilities.cc.
|
static |
Combines partialStrings, separated by delimiter, into one string.
Definition at line 131 of file VuoStringUtilities.cc.
Creates a string from a CFStringRef
.
Definition at line 585 of file VuoStringUtilities.cc.
Returns a random sequence of alphanumeric characters.
Definition at line 610 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 238 of file VuoStringUtilities.cc.
|
static |
Returns a string constructed by replacing all instances of originalChar
with replacementChar
in wholeString
.
Definition at line 76 of file VuoStringUtilities.cc.
|
static |
Replaces all instances of originalSubstring with replacementSubstring in wholeString.
Returns the number of instances replaced.
Definition at line 93 of file VuoStringUtilities.cc.
Splits wholeString into parts, as separated by delimiter.
Definition at line 109 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 52 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 64 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 346 of file VuoStringUtilities.cc.
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 321 of file VuoStringUtilities.cc.
Transforms a string into a valid identifier:
Definition at line 249 of file VuoStringUtilities.cc.
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 165 of file VuoStringUtilities.cc.
|
static |
For hashing strings.
Definition at line 64 of file VuoStringUtilities.hh.
|
static |
For hashing strings.
Definition at line 63 of file VuoStringUtilities.hh.