scsl 1.0.1
Shimmering Clarity Standard Library
|
String-related utility functions. More...
Functions | |
void | TrimLeadingWhitespace (std::string &s) |
void | TrimTrailingWhitespace (std::string &s) |
void | TrimWhitespace (std::string &s) |
std::string | TrimLeadingWhitespaceDup (std::string s) |
std::string | TrimTrailingWhitespaceDup (std::string s) |
std::string | TrimWhitespaceDup (std::string s) |
std::vector< std::string > | SplitKeyValuePair (std::string line, std::string delimiter) |
std::vector< std::string > | SplitKeyValuePair (std::string line, char delimiter) |
std::vector< std::string > | SplitN (std::string s, std::string delimiter, size_t maxCount=0) |
std::vector< std::string > | WrapText (std::string &line, size_t lineLength) |
void | WriteTabIndented (std::ostream &os, std::vector< std::string > lines, int tabStop, bool indentFirst) |
void | WriteTabIndented (std::ostream &os, std::string line, size_t maxLength, int tabStop, bool indentFirst) |
std::ostream & | VectorToString (std::ostream &os, const std::vector< std::string > &svec) |
std::string | VectorToString (const std::vector< std::string > &svec) |
String-related utility functions.
std::vector< std::string > scsl::scstring::SplitKeyValuePair | ( | std::string | line, |
char | delimiter | ||
) |
Split a line into key and value pairs. If the delimiter isn't found, the line is returned as the first element in the pair, and the second element will be empty.
line | A string representing a line in a file. |
delimiter | The character delimiter between the key and value. |
std::vector< std::string > scsl::scstring::SplitKeyValuePair | ( | std::string | line, |
std::string | delimiter | ||
) |
Split a line into key and value pairs. If the delimiter isn't found, the line is returned as the first element in the pair, and the second element will be empty.
line | A string representing a line in a file. |
delimiter | The string delimiter between the key and value. |
std::vector< std::string > scsl::scstring::SplitN | ( | std::string | s, |
std::string | delimiter, | ||
size_t | maxCount = 0 |
||
) |
Split a string into parts based on the delimiter.
s | The string that should be split. |
delimiter | The string that delimits the parts of the string. |
maxCount | The maximum number of parts to split. If 0, there is no limit to the number of parts. |
void scsl::scstring::TrimLeadingWhitespace | ( | std::string & | s | ) |
Remove any whitespace At the beginning of the string. The string is modified in-place.
std::string scsl::scstring::TrimLeadingWhitespaceDup | ( | std::string | s | ) |
Remove any whitespace At the beginning of the string. The original string isn't modified, and a copy is returned.
void scsl::scstring::TrimTrailingWhitespace | ( | std::string & | s | ) |
Remove any whitespace At the end of the string. The string is modified in-place.
std::string scsl::scstring::TrimTrailingWhitespaceDup | ( | std::string | s | ) |
Remove any whitespace At the end of the string. The original string isn't modified, and a copy is returned.
void scsl::scstring::TrimWhitespace | ( | std::string & | s | ) |
Remove any whitespace At the beginning and end of the string. The string is modified in-place.
std::string scsl::scstring::TrimWhitespaceDup | ( | std::string | s | ) |
Remove any whitespace At the beginning and end of the string. The original string isn't modified, and a copy is returned.
std::string scsl::scstring::VectorToString | ( | const std::vector< std::string > & | svec | ) |
Return a string represention of a string vector in the form [size]{"foo", "bar", ...}.
std::ostream & scsl::scstring::VectorToString | ( | std::ostream & | os, |
const std::vector< std::string > & | svec | ||
) |
Write a string vector to the output stream in the same format as VectorToString.
std::vector< std::string > scsl::scstring::WrapText | ( | std::string & | line, |
size_t | lineLength | ||
) |
WrapText is a very simple wrapping function that breaks the line into lines of At most lineLength characters. It does this by breaking the line into individual words (splitting on whitespace).
void scsl::scstring::WriteTabIndented | ( | std::ostream & | os, |
std::string | line, | ||
size_t | maxLength, | ||
int | tabStop, | ||
bool | indentFirst | ||
) |
Wrap a line, then output it to a stream.
os | The output stream to write to. |
line | The line to wrap and output. |
maxLength | The maximum length of each section of text. |
tabStop | The number of tabs to indent. |
indentFirst | Whether the first line should be indented. |
void scsl::scstring::WriteTabIndented | ( | std::ostream & | os, |
std::vector< std::string > | lines, | ||
int | tabStop, | ||
bool | indentFirst | ||
) |
Write out a vector of lines indented with tabs.
os | The output stream to write to. |
lines | The lines of text to write. |
tabStop | The number of tabs to indent. |
indentFirst | Whether the first line should be indented. |