16 #ifndef SERIALIZATION_STRING_UTILS_HPP_INCLUDED
17 #define SERIALIZATION_STRING_UTILS_HPP_INCLUDED
25 #include <boost/next_prior.hpp>
52 std::vector< std::string > vec_split =
split(val,
c,
flags);
53 return std::set< std::string >(vec_split.begin(), vec_split.end());
66 std::map< std::string, std::string >
map_split(
129 template <
typename T>
132 std::stringstream str;
133 for(
typename T::const_iterator
i = v.begin();
i != v.end(); ++
i) {
142 template <
typename T>
148 std::stringstream str;
149 for(
typename T::const_iterator
i = v.begin();
i != v.end(); ++
i) {
150 str <<
i->first << minor <<
i->second;
171 std::ostringstream str;
173 for(
typename T::const_iterator
i = v.begin();
i != v.end(); ++
i) {
213 {
return mod[0] ==
'-' ?
214 (unicode_minus +
std::string(mod.begin()+1, mod.end())) : (
"+" + mod);}
226 {
return escape(str,
"#@{}+-,\\*="); }
246 return '"' + str +
'"';
std::string si_string(double input, bool base2, std::string unit)
Convert into a string with an SI-postfix.
bool isvalid_wildcard(const std::string &username)
Check if the username pattern contains only valid characters.
std::string join_map(const T &v, const std::string &major=",", const std::string &minor=":")
std::string urlencode(const std::string &str)
Percent-escape characters in a UTF-8 string intended to be part of a URL.
std::string bullet_list(const T &v, size_t indent=4, const std::string &bullet=unicode_bullet)
Generates a new string containing a bullet list.
bool isvalid_username(const std::string &username)
Check if the username contains only valid characters.
GLenum GLenum GLenum input
std::map< std::string, std::string > map_split(std::string const &val, char major, char minor, int flags, std::string const &default_value)
Splits a string based on two separators into a map.
REMOVE_EMPTY : remove empty elements.
std::string unescape(const std::string &str)
Remove all escape characters (backslash)
bool wildcard_string_match(const std::string &str, const std::string &match)
Match using '*' as any number of characters (including none), and '?' as any one character.
GLuint const GLfloat * val
bool notspace(const char c)
const std::string unicode_multiplication_sign
const std::string number
template to number regex
std::string quote(const std::string &str)
Surround the string 'str' with double quotes.
std::string & strip(std::string &str)
Remove whitespace from the front and back of the string 'str'.
STRIP_SPACES : strips leading and trailing blank spaces.
const std::string unicode_minus
void ellipsis_truncate(std::string &str, const size_t size)
Truncates a string to a given utf-8 character count and then appends an ellipsis. ...
std::string half_signed_value(int val)
Sign with Unicode "−" if negative.
std::map< std::string, t_string > string_map
const std::string unicode_en_dash
std::string & strip_end(std::string &str)
Remove whitespace from the back of the string 'str'.
const std::string unicode_em_dash
cl_event GLbitfield flags
const std::string ¶meters float amount
std::string indent(const std::string &string, size_t indent_size)
Indent a block of text.
std::string join(T const &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::string escape(const std::string &str, const char *special_chars)
Prepends a configurable set of characters with a backslash.
std::pair< int, int > parse_range(std::string const &str)
std::vector< std::string > quoted_split(std::string const &val, char c, int flags, char quote)
This function is identical to split(), except it does not split when it otherwise would if the previo...
const std::string unicode_figure_dash
std::vector< std::pair< int, int > > parse_ranges(std::string const &str)
std::string signed_percent(int val)
Convert into a percentage (using the Unicode "−" and +0% convention.
bool string_bool(const std::string &str, bool def)
Convert no, false, off, 0, 0.0 to false, empty to def, and others to true.
bool isnewline(const char c)
std::string replace(std::string str, const std::string &src, const std::string &dst)
Replace all instances of src in str with dst.
std::set< std::string > set_split(std::string const &val, const char c= ',', const int flags=REMOVE_EMPTY|STRIP_SPACES)
Splits a (comma-)separated string into a set of pieces.
std::vector< std::string > parenthetical_split(std::string const &val, const char separator, std::string const &left, std::string const &right, const int flags)
Splits a string based either on a separator where text within parenthesis is protected from splitting...
int apply_modifier(const int number, const std::string &amount, const int minimum)
static const char * match(MatchState *ms, const char *s, const char *p)
GLsizei GLenum GLuint GLuint GLsizei char * message
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
bool portable_isspace(const char c)
std::string signed_value(int val)
Convert into a signed value (using the Unicode "−" and +0 convention.
std::string print_modifier(const std::string &mod)
std::vector< std::string > square_parenthetical_split(std::string const &val, const char separator, std::string const &left, std::string const &right, const int flags)
Similar to parenthetical_split, but also expands embedded square brackets.
GLsizei const GLcharARB ** string
bool word_completion(std::string &text, std::vector< std::string > &wordlist)
Try to complete the last word of 'text' with the 'wordlist'.
const std::string unicode_bullet
bool word_match(const std::string &message, const std::string &word)
Check if a message contains a word.