cgv
|
Helper functions to process strings. More...
#include <cstdint>
#include <string>
#include <vector>
#include "date_time.h"
#include "token.h"
#include "lib_begin.h"
#include <cgv/config/lib_end.h>
Go to the source code of this file.
Namespaces | |
namespace | cgv |
the cgv namespace | |
namespace | cgv::utils |
namespace that holds tools that dont fit any other namespace | |
Functions | |
const char * | cgv::utils::skip_spaces (const char *begin, const char *end) |
return new start pointer by skipping spaces at begin | |
const char * | cgv::utils::cutoff_spaces (const char *begin, const char *end) |
return new end pointer by cutting off spaces at the end | |
std::string & | cgv::utils::ltrim (std::string &str, const std::string &chars="\t\n\v\f\r ") |
trim white space or other characters from start of string | |
std::string & | cgv::utils::rtrim (std::string &str, const std::string &chars="\t\n\v\f\r ") |
trim white space or other characters from end of string | |
std::string & | cgv::utils::trim (std::string &str, const std::string &chars="\t\n\v\f\r ") |
trim white space or other characters from start and end of string | |
std::string | cgv::utils::ltrim (const std::string &str, const std::string &chars="\t\n\v\f\r ") |
trim white space or other characters from start of string | |
std::string | cgv::utils::rtrim (const std::string &str, const std::string &chars="\t\n\v\f\r ") |
trim white space or other characters from end of string | |
std::string | cgv::utils::trim (const std::string &str, const std::string &chars="\t\n\v\f\r ") |
trim white space or other characters from start and end of string | |
std::string | cgv::utils::join (const std::vector< std::string >::const_iterator first, const std::vector< std::string >::const_iterator last, const std::string &sep, bool trailing_sep=false) |
joins a given range of strings, separating them by the given separator; if trailing_sep is true, also puts a separator at the end | |
std::string | cgv::utils::join (const std::vector< std::string > &strs, const std::string &sep, bool trailing_sep=false) |
joins a given list of strings, separating them by the given separator; if trailing_sep is true, also puts a separator at the end | |
CGV_API std::string | cgv::utils::join (const std::vector< token >::const_iterator first, const std::vector< token >::const_iterator last, const std::string &sep, bool trailing_sep=false) |
joins a given range of tokens, separating them by the given separator; if trailing_sep is true, also puts a separator at the end | |
bool | cgv::utils::is_space (char c) |
check if char is a whitespace | |
bool | cgv::utils::is_url_special (char c) |
check if char is a special character from an url | |
bool | cgv::utils::is_digit (char c) |
check if char is a digit | |
bool | cgv::utils::is_letter (char c) |
check if char is a letter | |
char | cgv::utils::to_lower (char c) |
convert char to lower case | |
std::string | cgv::utils::to_hex (uint8_t v, bool use_upper_case=true) |
convert to hex | |
uint8_t | cgv::utils::from_hex (char c) |
convert from hex character | |
std::vector< uint8_t > | cgv::utils::parse_hex_bytes (const std::string &byte_str) |
parse bytes hex coded bytes | |
std::string | cgv::utils::to_lower (const std::string &_s) |
convert string to lower case | |
char | cgv::utils::to_upper (char c) |
convert char to upper case | |
std::string | cgv::utils::to_upper (const std::string &_s) |
convert string to upper case | |
std::string & | cgv::utils::remove (std::string &s, char c) |
remove char c from the given string s and return a reference to the same string object | |
std::string | cgv::utils::remove_copy (const std::string &s, char c) |
return a copy of the given string s with all occurences of char removed | |
std::string | cgv::utils::replace_special (const std::string &_s) |
replaces the german special characters ä,ö,ü,ß,Ä,Ö,Ü | |
unsigned int | cgv::utils::replace (std::string &_s, char c1, char c2) |
replace char c1 with c2 in the given string _s and return number of replacements | |
unsigned int | cgv::utils::replace (std::string &_s, const std::string &s1, const std::string &s2) |
replace string s1 with s2 in the given string _s and return number of replacements | |
std::string | cgv::utils::interpret_special (const std::string &s) |
interprets the C++ special characters \a , \b , \f , \n , \r , \t , \v , \\' , \" , \\ , \ ?, \ooo , \xhh | |
std::string | cgv::utils::escape_special (const std::string &s) |
escapes the C++ special characters \a , \b , \f , \n , \r , \t , \v , \\' , \" , \\ , \ ? | |
bool | cgv::utils::find_name (const std::string &s, const char *names[], int &idx) |
check if string s is contained in the given array of names and in case of success store name index in idx | |
bool | cgv::utils::is_element (char c, const std::string &s) |
check if char c arises in string s | |
bool | cgv::utils::is_element (const std::string &e, const std::string &s, char sep=';') |
check if the string e is contained as element in the string s, which is a list separated by sep | |
int | cgv::utils::get_element_index (const std::string &e, const std::string &s, char sep=';') |
check if the string e is contained as element in the string s, which is a list separated by sep and return the index of the element. | |
std::string | cgv::utils::get_element (const std::string &s, int element_index, char sep=';') |
interpret s as a list separated by sep and return the element with the given element index. | |
bool | cgv::utils::is_integer (const char *begin, const char *end, int &value) |
check if the text range (begin,end( defines an integer value. If yes, store the value in the passed reference. | |
bool | cgv::utils::is_integer (const std::string &s, int &value) |
check if the passed string defines an integer value. If yes, store the value in the passed reference. | |
bool | cgv::utils::is_double (const char *begin, const char *end, double &value) |
check if the text range (begin,end( defines a double value. If yes, store the value in the passed reference. | |
bool | cgv::utils::is_double (const std::string &s, double &value) |
check if the passed string defines a double value. If yes, store the value in the passed reference. | |
bool | cgv::utils::is_year (const char *begin, const char *end, unsigned short &year, bool short_allowed=true) |
check and extract year from string token [begin , end ] | |
bool | cgv::utils::is_year (const std::string &s, unsigned short &year, bool short_allowed=true) |
check and extract year from string s | |
CGV_API bool | cgv::utils::is_day (const char *begin, const char *end, unsigned char &day) |
check and extract day from string token [begin , end ] | |
CGV_API bool | cgv::utils::is_day (const std::string &s, unsigned char &day) |
check and extract day from string s | |
bool | cgv::utils::is_month (const char *begin, const char *end, unsigned char &month) |
check and extract month from string token [begin , end ] | |
bool | cgv::utils::is_month (const std::string &s, unsigned char &month) |
check and extract month from string s | |
bool | cgv::utils::is_time (const char *begin, const char *end, cgv::utils::time &t, const char **new_end=0) |
check and extract time from string token [begin , end ] | |
bool | cgv::utils::is_time (const std::string &s, cgv::utils::time &t, const char **new_end=0) |
check and extract time from string s | |
bool | cgv::utils::is_date (const char *begin, const char *end, cgv::utils::date &d, const char **new_end=0) |
check and extract date from string token [begin , end ] | |
bool | cgv::utils::is_date (const std::string &s, cgv::utils::date &d, const char **new_end=0) |
check and extract date from string s | |
bool | cgv::utils::is_url (const char *begin, const char *end, const char **new_end=0) |
check and extract end of valid url from string token [begin , end ] | |
bool | cgv::utils::is_url (const std::string &s, const char **end=0) |
check and extract end of valid url from string s | |
unsigned int | cgv::utils::levenshtein_distance (const std::string &s1, const std::string &s2) |
compute the levenshtein distance between two strings s1 and s2 | |
Helper functions to process strings.
Definition in file scan.h.