Claw
1.7.3
|
Everything about text processing. More...
Classes | |
class | kmp |
Exact pattern finding with the Knuth-Morris-Pratt's algorithm. More... |
Functions | |
template<typename StreamType , typename StringType > | |
StreamType & | getline (StreamType &is, StringType &str) |
A portable version of std::getline( is, str, '\n' ) that removes a tailing '\r'. | |
template<typename StringType > | |
void | trim_left (StringType &str, const typename StringType::value_type *const s=" ") |
Remove characters at the begining of a string. | |
template<typename StringType > | |
void | trim_right (StringType &str, const typename StringType::value_type *const s=" ") |
Remove characters at the end of a string. | |
template<typename StringType > | |
void | trim (StringType &str, const typename StringType::value_type *const s=" ") |
Remove characters at the begining end at the end of a string. | |
template<typename StringType > | |
void | squeeze (StringType &str, const typename StringType::value_type *const s) |
Squeeze successive characters of a string into one character. | |
template<typename StringType > | |
std::size_t | replace (StringType &str, const StringType &e1, const StringType &e2) |
Replace a set of characters by other characters. | |
template<typename T , typename StringType > | |
bool | is_of_type (const StringType &str) |
Test if the content of a string is immediately convertible to a type. | |
template<typename Sequence > | |
void | split (Sequence &sequence, const typename Sequence::value_type &str, const typename Sequence::value_type::value_type sep) |
Split a string into several substrings, according to a given separator. | |
template<typename Sequence > | |
void | split (Sequence &sequence, typename Sequence::value_type::const_iterator first, typename Sequence::value_type::const_iterator last, const typename Sequence::value_type::value_type sep) |
Split a string into several substrings, according to a given separator. | |
template<typename InputIterator , typename OutputIterator > | |
void | c_escape (InputIterator first, InputIterator last, OutputIterator out) |
Find escaped symbols in a sequence of characters and replace them by their c-equivalent. | |
template<typename StringType > | |
bool | glob_match (const StringType &pattern, const StringType &text, const typename StringType::value_type any_sequence= '*', const typename StringType::value_type zero_or_one= '?', const typename StringType::value_type any= '.') |
Check if a string matches a given pattern. | |
template<typename StringType > | |
bool | glob_potential_match (const StringType &pattern, const StringType &text, const typename StringType::value_type any_sequence= '*', const typename StringType::value_type zero_or_one= '?', const typename StringType::value_type any= '.') |
Check if a string may match a given pattern. |
Everything about text processing.
void claw::text::c_escape | ( | InputIterator | first, |
InputIterator | last, | ||
OutputIterator | out | ||
) |
Find escaped symbols in a sequence of characters and replace them by their c-equivalent.
first | Iterator on the beginning of the string to escape. |
last | Iterator just past the end of the string to escape. |
out | Iterator on the beginning of the output string. |
Definition at line 261 of file string_algorithm.tpp.
References claw::find_first_not_of().
StreamType & claw::text::getline | ( | StreamType & | is, |
StringType & | str | ||
) |
A portable version of std::getline( is, str, '\n' ) that removes a tailing '\r'.
is | The stream in which we read. |
str | The line read from the stream. |
Definition at line 46 of file string_algorithm.tpp.
Referenced by split().
bool claw::text::glob_match | ( | const StringType & | pattern, |
const StringType & | text, | ||
const typename StringType::value_type | any_sequence = '*' , |
||
const typename StringType::value_type | zero_or_one = '?' , |
||
const typename StringType::value_type | any = '.' |
||
) |
Check if a string matches a given pattern.
pattern | The pattern. |
text | The text to check. |
any_sequence | A value representing any sequence of values, empty or not. |
zero_or_one | A value representing any value or no value. |
any | A value representing any value. |
Definition at line 338 of file string_algorithm.tpp.
References claw::glob_match().
bool claw::text::glob_potential_match | ( | const StringType & | pattern, |
const StringType & | text, | ||
const typename StringType::value_type | any_sequence = '*' , |
||
const typename StringType::value_type | zero_or_one = '?' , |
||
const typename StringType::value_type | any = '.' |
||
) |
Check if a string may match a given pattern.
pattern | The pattern. |
text | The text to check. |
any_sequence | A value representing any sequence of values, empty or not. |
zero_or_one | A value representing any value or no value. |
any | A value representing any value. |
Definition at line 360 of file string_algorithm.tpp.
References claw::glob_potential_match().
bool claw::text::is_of_type | ( | const StringType & | str | ) |
Test if the content of a string is immediately convertible to a type.
str | The string to test. |
Definition at line 180 of file string_algorithm.tpp.
std::size_t claw::text::replace | ( | StringType & | str, |
const StringType & | e1, | ||
const StringType & | e2 | ||
) |
Replace a set of characters by other characters.
str | The string to modify. |
e1 | The characters to remove. |
e2 | The characters replacing the ones in e1. |
Each character e1[i] will be replaced with e2[i]. If e1 is smaller than e2, the latter will be completed by repeating its last character.
Example : std::string s("word aaa bbb abab"); claw::replace( s, "ab", "ba" ); std::cout << s << std::end; // result is "word bbb aaa baba"
Definition at line 167 of file string_algorithm.tpp.
References claw::replace().
void claw::text::split | ( | Sequence & | sequence, |
const typename Sequence::value_type & | str, | ||
const typename Sequence::value_type::value_type | sep | ||
) |
Split a string into several substrings, according to a given separator.
sequence | A sequence in which the substrings are added. |
str | The string to split. |
sep | The separator on which the string is splitted. |
Definition at line 205 of file string_algorithm.tpp.
void claw::text::split | ( | Sequence & | sequence, |
typename Sequence::value_type::const_iterator | first, | ||
typename Sequence::value_type::const_iterator | last, | ||
const typename Sequence::value_type::value_type | sep | ||
) |
Split a string into several substrings, according to a given separator.
sequence | A sequence in which the substrings are added. |
first | Iterator on the beginning of the string to split. |
last | Iterator just past the end of the string to split. |
sep | The separator on which the string is splitted. |
Definition at line 222 of file string_algorithm.tpp.
References getline().
void claw::text::squeeze | ( | StringType & | str, |
const typename StringType::value_type *const | s | ||
) |
Squeeze successive characters of a string into one character.
str | The string to modify. |
s | The characters to remove. |
Example : std::string s("word aaa bbb abab"); claw::squeeze( s, "ab" ); std::cout << s << std::end; // result is "word a b abab"
Definition at line 120 of file string_algorithm.tpp.
void claw::text::trim | ( | StringType & | str, |
const typename StringType::value_type *const | s = " " |
||
) |
Remove characters at the begining end at the end of a string.
str | The string to modify. |
s | The characters to remove. |
Definition at line 96 of file string_algorithm.tpp.
void claw::text::trim_left | ( | StringType & | str, |
const typename StringType::value_type *const | s = " " |
||
) |
Remove characters at the begining of a string.
str | The string to modify. |
s | The characters to remove. |
Definition at line 64 of file string_algorithm.tpp.
void claw::text::trim_right | ( | StringType & | str, |
const typename StringType::value_type *const | s = " " |
||
) |
Remove characters at the end of a string.
str | The string to modify. |
s | The characters to remove. |
Definition at line 80 of file string_algorithm.tpp.
Referenced by claw::configuration_file::open().