cgv
|
namespace that holds tools that dont fit any other namespace More...
Classes | |
class | big_binary_file |
class to handle files with very large sizes (>=2GB) hiding the ugly win32 api calls More... | |
struct | date |
struct | date_time |
struct | guid |
simple struct to represent guid More... | |
struct | line |
a line in a text is simply represented as a token More... | |
class | pointer_test |
class | Profiler |
A profiler class for managing different stopwatches. More... | |
struct | progression |
progression provides a simple possibility to show progression of process in console. More... | |
class | statistics |
incrementally accumulate statistical information More... | |
class | stopwatch |
A trivial stop watch class for time measurement. More... | |
struct | time |
struct | token |
representation of a token in a text by two pointers begin and end, that point to the first character of the token and behind the last character of the token. More... | |
class | tokenizer |
the tokenizer allows to split text into tokens in a convenient way. More... | |
struct | typed_token |
a typed token also stores the type and value of a parsed token. More... | |
Enumerations | |
enum | token_type { PLAIN , URL , FLOAT_VALUE , TIME_VALUE , DATE_VALUE } |
different types that a typed_token can have More... | |
Functions | |
void | split_to_tokens (const char *begin, const char *end, std::vector< token > &tokens, const std::string &separators, bool merge_separators=true, const std::string &open_parenthesis="", const std::string &close_parenthesis="", const std::string &whitespaces=" \t\n", unsigned int max_nr_tokens=-1) |
this function splits a text range into tokens. | |
void | split_to_lines (const char *begin, const char *end, std::vector< line > &lines, bool truncate_trailing_spaces=true) |
this function splits a text range at the newline characters into single lines. | |
bool | balanced_find_content (const char *begin, const char *end, token &content, char open_parenthesis, char close_parenthesis) |
the input range must begin with an open parenthesis. | |
std::string | strip_cpp_comments (const std::string &source, bool correct_new_lines=true) |
remove cpp-style comments from string | |
void | split_to_tokens (const token &tok, std::vector< token > &tokens, const std::string &separators, bool merge_separators=true, const std::string &open_parenthesis="", const std::string &close_parenthesis="", const std::string &whitespaces=" \t\n", unsigned int=-1) |
text range given as token | |
void | split_to_tokens (const std::string &s, std::vector< token > &tokens, const std::string &separators, bool merge_separators=true, const std::string &open_parenthesis="", const std::string &close_parenthesis="", const std::string &whitespaces=" \t\n", unsigned int=(unsigned int) -1) |
text range given as string | |
void | split_to_lines (const token &tok, std::vector< line > &lines, bool truncate_trailing_spaces=true) |
text range given as token | |
void | split_to_lines (const std::string &s, std::vector< line > &lines, bool truncate_trailing_spaces=true) |
text range given as string | |
bool | balanced_find_content (const token &expression, token &content, char open_parenthesis, char close_parenthesis) |
bool | balanced_find_content (const std::string &expression, token &content, char open_parenthesis, char close_parenthesis) |
bool | is_bit_set (unsigned int bit_idx, unsigned int bit_field) |
check if a bit of a bit field is set | |
void | enable_upper_bits (unsigned int &bit_field, unsigned int fst_bit_idx) |
set all the bits of bit_field with index equal or larger than fst_bit_idx | |
void | disable_upper_bits (unsigned int &bit_field, unsigned int fst_bit_idx) |
clear all the bits of bit_field with index equal or larger than fst_bit_idx | |
void | enable_lower_bits (unsigned int &bit_field, unsigned int fst_bit_idx) |
set all the bits of bit_field with index equal or less than fst_bit_idx | |
void | disable_lower_bits (unsigned int &bit_field, unsigned int fst_bit_idx) |
clear all the bits of bit_field with index equal or less than fst_bit_idx | |
void | set_bits (unsigned int &bit_field, unsigned int off, unsigned int n, unsigned int value) |
set n bits starting with index off of the given bit field from the first bits of the given integer value | |
std::wstring | str2wstr (const std::string &s) |
convert a 8-bit string to a 16-bit string | |
std::string | wstr2str (const std::wstring &s) |
convert a 16-bit string to a 8-bit string | |
static bool | is_base64 (unsigned char c) |
std::string | encode_base64 (const std::string &s) |
encode a string into base64 | |
std::string | decode_base64 (const std::string &s) |
decode a base64 encoded string | |
template<> | |
std::string | to_string (const std::string &v, unsigned int w, unsigned int p, bool) |
specialization of conversion from string to strings | |
template<> | |
bool | from_string (std::string &v, const std::string &s) |
specialization to extract string value from string | |
template<typename T > | |
std::string | to_string (const T &v, unsigned int w=-1, unsigned int p=-1, bool fixed=false) |
convert a numeric type T into string of width w and precision p | |
template<typename T > | |
std::string | to_string (const T &v, unsigned int w, char fill_char) |
convert an integer type T into string of width w with given fill character | |
template<> | |
CGV_API std::string | to_string (const std::string &v, unsigned int w, unsigned int p, bool) |
specialization of conversion from string to strings | |
template<typename T > | |
bool | from_string (T &v, const std::string &s) |
extract value from string | |
template<> | |
CGV_API bool | from_string (std::string &v, const std::string &s) |
specialization to extract string value from string | |
time_t | convert_to_time (const date_time &dt) |
date_time | convert_to_date_time (time_t ti) |
date_time | now () |
std::ostream & | operator<< (std::ostream &os, const time &T) |
std::ostream & | operator<< (std::ostream &os, const date &D) |
std::ostream & | operator<< (std::ostream &os, const date_time &DT) |
guid | guid_from_string (const std::string &str) |
convert string to guid | |
std::string | to_string (const guid &_id) |
convert guid to string | |
bool | operator< (const guid &g1, const guid &g2) |
comparison operation | |
bool | operator== (const guid &g1, const guid &g2) |
comparison operation | |
bool | has_option (const std::string &option) |
check whether the system variable CGV_OPTIONS contains the given option (the comparison is case insensitve) within a semicolon separated list | |
void | enumerate_options (std::vector< std::string > &options) |
push back all options provided in the CGV_OPTIONS system variable | |
bool | is_space (char c) |
check if char is a whitespace | |
bool | is_url_special (char c) |
check if char is a special character from an url | |
bool | is_digit (char c) |
check if char is a digit | |
bool | is_letter (char c) |
check if char is a letter | |
char | to_lower (char c) |
convert char to lower case | |
std::string | to_hex (uint8_t v, bool use_upper_case=true) |
convert to hex | |
uint8_t | from_hex (char c) |
convert from hex character | |
std::vector< uint8_t > | parse_hex_bytes (const std::string &byte_str) |
parse bytes hex coded bytes | |
std::string | to_lower (const std::string &_s) |
convert string to lower case | |
char | to_upper (char c) |
convert char to upper case | |
std::string | to_upper (const std::string &_s) |
convert string to upper case | |
std::string & | 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 | remove_copy (const std::string &s, char c) |
return a copy of the given string s with all occurences of char removed | |
std::string | replace_special (const std::string &_s) |
replaces the german special characters ä,ö,ü,ß,Ä,Ö,Ü | |
unsigned int | 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 | 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 | escape_special (const std::string &s) |
escapes the C++ special characters \a , \b , \f , \n , \r , \t , \v , \\' , \" , \\ , \ ? | |
std::string | interpret_special (const std::string &s) |
interprets the C++ special characters \a , \b , \f , \n , \r , \t , \v , \\' , \" , \\ , \ ?, \ooo , \xhh | |
bool | is_element (char c, const std::string &s) |
check if char c arises in string s | |
bool | 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 | |
std::string | 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. | |
int | 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. | |
bool | 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 | 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 | 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 | 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 | 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 | is_year (const std::string &s, unsigned short &year, bool short_allowed=true) |
check and extract year from string s | |
bool | 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 | is_month (const char *begin, const char *end, unsigned char &month) |
check and extract month from string token [begin , end ] | |
bool | is_month (const std::string &s, unsigned char &month) |
check and extract month from string s | |
bool | is_time (const std::string &s, cgv::utils::time &t, const char **new_end=0) |
check and extract time from string s | |
bool | is_date (const std::string &s, cgv::utils::date &d, const char **new_end=0) |
check and extract date from string s | |
bool | 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 | 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 | is_url (const std::string &s, const char **end=0) |
check and extract end of valid url from string s | |
bool | 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 ] | |
const char * | skip_spaces (const char *begin, const char *end) |
return new start pointer by skipping spaces at begin | |
const char * | cutoff_spaces (const char *begin, const char *end) |
return new end pointer by cutting off spaces at the end | |
std::string & | 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 & | 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 & | 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 | 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 | 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 | 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 | 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 | 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 | |
std::string | join (const std::vector< cgv::utils::token >::const_iterator first, const std::vector< cgv::utils::token >::const_iterator last, const std::string &sep, bool trailing_sep) |
joins a given range of tokens, separating them by the given separator; if trailing_sep is true, also puts a separator at the end | |
unsigned int | levenshtein_distance (const std::string &s1, const std::string &s2) |
compute the levenshtein distance between two strings s1 and s2 | |
CGV_API std::string | 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 | |
CGV_API bool | is_day (const char *begin, const char *end, unsigned char &day) |
check and extract day from string token [begin , end ] | |
CGV_API bool | is_day (const std::string &s, unsigned char &day) |
check and extract day from string s | |
void | parse_enum_declarations (const std::string &enum_declarations, std::vector< token > &enum_names, std::vector< int > &enum_values) |
parse an enum declaration string into names and values | |
unsigned | find_enum_index (int value, const std::vector< int > &enum_values) |
convert value to index | |
unsigned | find_enum_index (const std::string &name, const std::vector< token > &enum_names) |
convert name to index | |
std::string | find_enum_name (const std::string &enum_declarations, int value) |
lookup name of value in enum declaration | |
std::ostream & | operator<< (std::ostream &os, const statistics &s) |
std::string | to_string (const token &t) |
convert to string | |
std::vector< std::string > | to_strings (const std::vector< token >::const_iterator first, const std::vector< token >::const_iterator last) |
convert to strings | |
std::vector< std::string > | to_strings (const std::vector< token > &ts) |
convert to strings | |
std::ostream & | operator<< (std::ostream &os, const token &t) |
stream out operator | |
void | bite_all (tokenizer &t, std::vector< token > &result) |
bite all tokens into a token vector | |
Variables | |
static const std::string | base64_chars |
const unsigned char | AE = static_cast<unsigned char>(142) |
const unsigned char | ae = static_cast<unsigned char>(132) |
const unsigned char | OE = static_cast<unsigned char>(153) |
const unsigned char | oe = static_cast<unsigned char>(148) |
const unsigned char | UE = static_cast<unsigned char>(154) |
const unsigned char | ue = static_cast<unsigned char>(129) |
const unsigned char | ss = static_cast<unsigned char>(225) |
constexpr auto | S_TO_NS =1000000000LL |
constexpr auto | NS_TO_S =(1.0/double(S_TO_NS)) |
namespace that holds tools that dont fit any other namespace
different types that a typed_token can have
Definition at line 25 of file advanced_scan.h.
CGV_API bool cgv::utils::balanced_find_content | ( | const char * | begin, |
const char * | end, | ||
token & | content, | ||
char | open_parenthesis, | ||
char | close_parenthesis | ||
) |
the input range must begin with an open parenthesis.
The function finds the matching closing parenthesis and returns a token with the content inside the parentheses.
Examples:
balanced_find_content( "a+b", => , '(', ')' ) ==> false; balanced_find_content( "(a+b)", => "a+b", '(', ')' ) ==> true; balanced_find_content( "(a+(c*d),b)", => "a+(c*d),b", '(', ')' ) ==> true;
Definition at line 87 of file advanced_scan.cxx.
References cgv::utils::token::begin, and skip_spaces().
|
inline |
Definition at line 154 of file advanced_scan.h.
|
inline |
Definition at line 147 of file advanced_scan.h.
bite all tokens into a token vector
Definition at line 121 of file tokenizer.h.
References cgv::utils::tokenizer::bite(), and cgv::utils::tokenizer::skip_ws_check_empty().
Referenced by cgv::base::base::is_property(), cgv::base::load_plugin(), gui_config_file_observer::multi_observe(), cgv::base::base::multi_set(), cgv::gui::help_menu_entry::on_register(), cgv::base::ref_data_path_list(), and cgv::ppp::command_token::split_off_from().
date_time cgv::utils::convert_to_date_time | ( | time_t | ti | ) |
Definition at line 46 of file date_time.cxx.
time_t cgv::utils::convert_to_time | ( | const date_time & | dt | ) |
Definition at line 32 of file date_time.cxx.
CGV_API const char * cgv::utils::cutoff_spaces | ( | const char * | begin, |
const char * | end | ||
) |
return new end pointer by cutting off spaces at the end
Definition at line 690 of file scan.cxx.
References is_space().
Referenced by cgv::base::analyze_command().
CGV_API std::string cgv::utils::decode_base64 | ( | std::string const & | encoded_string | ) |
decode a base64 encoded string
Definition at line 105 of file convert.cxx.
Referenced by cgv::render::shader_code::decode_if_base64().
CGV_API void cgv::utils::disable_lower_bits | ( | unsigned int & | bit_field, |
unsigned int | fst_bit_idx | ||
) |
clear all the bits of bit_field with index equal or less than fst_bit_idx
Definition at line 51 of file bit_operations.cxx.
Referenced by set_bits().
CGV_API void cgv::utils::disable_upper_bits | ( | unsigned int & | bit_field, |
unsigned int | fst_bit_idx | ||
) |
clear all the bits of bit_field with index equal or larger than fst_bit_idx
Definition at line 29 of file bit_operations.cxx.
Referenced by cgv::data::packing_info::get_signed(), cgv::data::packing_info::get_unsigned(), and set_bits().
CGV_API void cgv::utils::enable_lower_bits | ( | unsigned int & | bit_field, |
unsigned int | fst_bit_idx | ||
) |
set all the bits of bit_field with index equal or less than fst_bit_idx
Definition at line 40 of file bit_operations.cxx.
CGV_API void cgv::utils::enable_upper_bits | ( | unsigned int & | bit_field, |
unsigned int | fst_bit_idx | ||
) |
set all the bits of bit_field with index equal or larger than fst_bit_idx
Definition at line 17 of file bit_operations.cxx.
Referenced by cgv::data::packing_info::get_signed().
CGV_API std::string cgv::utils::encode_base64 | ( | const std::string & | s | ) |
encode a string into base64
Definition at line 61 of file convert.cxx.
void CGV_API cgv::utils::enumerate_options | ( | std::vector< std::string > & | options | ) |
push back all options provided in the CGV_OPTIONS system variable
Definition at line 18 of file options.cxx.
References split_to_tokens(), and to_string().
Referenced by has_option().
CGV_API std::string cgv::utils::escape_special | ( | const std::string & | s | ) |
escapes the C++ special characters \a
, \b
, \f
, \n
, \r
, \t
, \v
, \\'
, \"
, \\
, \
?
Definition at line 205 of file scan.cxx.
Referenced by cgv::reflect::debug_reflection_handler::reflect_member_void(), and cgv::data::ascii_write_reflection_handler::reflect_member_void().
CGV_API unsigned cgv::utils::find_enum_index | ( | const std::string & | name, |
const std::vector< token > & | enum_names | ||
) |
convert name to index
Definition at line 44 of file scan_enum.cxx.
CGV_API unsigned cgv::utils::find_enum_index | ( | int | value, |
const std::vector< int > & | enum_values | ||
) |
convert value to index
Definition at line 35 of file scan_enum.cxx.
Referenced by find_enum_name(), cgv::reflect::abst_enum_reflection_traits::get_to_string(), and cgv::reflect::abst_enum_reflection_traits::set_from_string().
CGV_API std::string cgv::utils::find_enum_name | ( | const std::string & | enum_declarations, |
int | value | ||
) |
lookup name of value in enum declaration
Definition at line 53 of file scan_enum.cxx.
References find_enum_index(), parse_enum_declarations(), and to_string().
CGV_API 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
Definition at line 507 of file scan.cxx.
Referenced by is_month().
CGV_API uint8_t cgv::utils::from_hex | ( | char | c | ) |
bool cgv::utils::from_string | ( | std::string & | v, |
const std::string & | s | ||
) |
specialization to extract string value from string
Definition at line 13 of file convert_string.cxx.
Referenced by cgv::gui::key_control< T >::set_void(), and cgv::gui::key_control< bool >::set_void().
CGV_API bool cgv::utils::from_string | ( | std::string & | v, |
const std::string & | s | ||
) |
specialization to extract string value from string
Definition at line 13 of file convert_string.cxx.
Referenced by cgv::gui::key_control< T >::set_void(), and cgv::gui::key_control< bool >::set_void().
bool cgv::utils::from_string | ( | T & | v, |
const std::string & | s | ||
) |
extract value from string
Definition at line 45 of file convert_string.h.
CGV_API 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.
If index is out of range, return empty string.
Definition at line 301 of file scan.cxx.
Referenced by vr_emulator::stream_stats().
CGV_API 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.
If not contained, return -1.
Definition at line 323 of file scan.cxx.
Referenced by is_element().
CGV_API guid cgv::utils::guid_from_string | ( | const std::string & | str | ) |
bool CGV_API cgv::utils::has_option | ( | const std::string & | option | ) |
check whether the system variable CGV_OPTIONS contains the given option (the comparison is case insensitve) within a semicolon separated list
Definition at line 8 of file options.cxx.
References enumerate_options(), and to_upper().
Referenced by vr_test::init().
CGV_API std::string cgv::utils::interpret_special | ( | const std::string & | s | ) |
interprets the C++ special characters \a
, \b
, \f
, \n
, \r
, \t
, \v
, \\'
, \"
, \\
, \
?, \ooo
, \xhh
Definition at line 227 of file scan.cxx.
References is_digit(), and to_lower().
Referenced by cgv::data::ascii_read_reflection_handler::reflect_member_void().
|
inlinestatic |
Definition at line 57 of file convert.cxx.
CGV_API bool cgv::utils::is_bit_set | ( | unsigned int | bit_idx, |
unsigned int | bit_field | ||
) |
check if a bit of a bit field is set
Definition at line 7 of file bit_operations.cxx.
Referenced by cgv::data::packing_info::get_signed().
CGV_API bool cgv::utils::is_date | ( | const char * | begin, |
const char * | end, | ||
cgv::utils::date & | d, | ||
const char ** | new_end | ||
) |
CGV_API bool cgv::utils::is_date | ( | const std::string & | s, |
cgv::utils::date & | d, | ||
const char ** | new_end | ||
) |
check and extract date from string s
Definition at line 591 of file scan.cxx.
References is_digit(), is_integer(), is_month(), is_url_special(), and is_year().
Referenced by is_date().
CGV_API bool cgv::utils::is_digit | ( | char | c | ) |
check if char is a digit
Definition at line 20 of file scan.cxx.
Referenced by interpret_special(), is_date(), is_integer(), is_time(), gui_config_file_observer::multi_observe(), and cgv::base::base::multi_set().
CGV_API 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.
Definition at line 426 of file scan.cxx.
Referenced by is_double(), cgv::media::mesh::obj_reader_generic< T >::parse_vec2(), and cgv::media::mesh::obj_reader_generic< T >::parse_vec3().
CGV_API 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.
Definition at line 484 of file scan.cxx.
References is_double().
CGV_API bool cgv::utils::is_element | ( | char | c, |
const std::string & | s | ||
) |
check if char c
arises in string s
Definition at line 291 of file scan.cxx.
Referenced by cgv::utils::tokenizer::balanced_bite(), cgv::utils::tokenizer::bite(), cgv::media::image::image_writer::image_writer(), cgv::media::image::image_reader::open(), cgv::media::video::video_reader::open(), cgv::utils::tokenizer::reverse_bite(), cgv::utils::token::reverse_skip(), cgv::utils::token::skip(), cgv::ppp::command_token::split_off_from(), split_to_tokens(), and cgv::media::video::video_writer::video_writer().
CGV_API 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
Definition at line 296 of file scan.cxx.
References get_element_index().
CGV_API 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.
Definition at line 367 of file scan.cxx.
References is_digit(), and to_upper().
Referenced by cgv::render::shader_program::attach_program(), cgv::render::shader_code::get_last_error(), is_date(), is_integer(), is_month(), is_time(), is_year(), gui_config_file_observer::multi_observe(), cgv::base::base::multi_set(), parse_enum_declarations(), cgv::gui::question(), cgv::reflect::find_reflection_handler::reflect_group_begin(), cgv::data::component_format::set_component_format(), and cgv::data::data_format::set_data_format().
CGV_API 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.
Definition at line 421 of file scan.cxx.
References is_integer().
CGV_API bool cgv::utils::is_letter | ( | char | c | ) |
CGV_API bool cgv::utils::is_month | ( | const char * | begin, |
const char * | end, | ||
unsigned char & | month | ||
) |
check and extract month from string token [begin
, end
]
Definition at line 520 of file scan.cxx.
References find_name(), is_integer(), replace_special(), and to_lower().
Referenced by is_date(), and is_month().
CGV_API bool cgv::utils::is_month | ( | const std::string & | s, |
unsigned char & | month | ||
) |
check and extract month from string s
Definition at line 546 of file scan.cxx.
References is_month().
CGV_API bool cgv::utils::is_space | ( | char | c | ) |
check if char is a whitespace
Definition at line 12 of file scan.cxx.
Referenced by cgv::render::shader_program::attach_program(), cutoff_spaces(), cgv::render::shader_program::extract_instances(), cgv::render::shader_code::set_vertex_attrib_locations(), skip_spaces(), and split_to_lines().
CGV_API bool cgv::utils::is_time | ( | const char * | begin, |
const char * | end, | ||
cgv::utils::time & | t, | ||
const char ** | new_end | ||
) |
CGV_API bool cgv::utils::is_time | ( | const std::string & | s, |
cgv::utils::time & | t, | ||
const char ** | new_end | ||
) |
check and extract time from string s
Definition at line 551 of file scan.cxx.
References is_digit(), is_integer(), and is_url_special().
Referenced by is_time().
CGV_API bool cgv::utils::is_url | ( | const char * | begin, |
const char * | end, | ||
const char ** | new_end | ||
) |
CGV_API bool cgv::utils::is_url | ( | const std::string & | s, |
const char ** | end | ||
) |
check and extract end of valid url from string s
Definition at line 653 of file scan.cxx.
References is_url_special().
Referenced by is_url().
CGV_API bool cgv::utils::is_url_special | ( | char | c | ) |
CGV_API bool cgv::utils::is_year | ( | const char * | begin, |
const char * | end, | ||
unsigned short & | year, | ||
bool | short_allowed | ||
) |
check and extract year from string token [begin
, end
]
Definition at line 490 of file scan.cxx.
References is_integer().
CGV_API bool cgv::utils::is_year | ( | const std::string & | s, |
unsigned short & | year, | ||
bool | short_allowed | ||
) |
std::string cgv::utils::join | ( | const std::vector< cgv::utils::token >::const_iterator | first, |
const std::vector< cgv::utils::token >::const_iterator | last, | ||
const std::string & | sep, | ||
bool | trailing_sep | ||
) |
joins a given range of tokens, separating them by the given separator; if trailing_sep is true, also puts a separator at the end
Definition at line 753 of file scan.cxx.
References join(), and to_strings().
CGV_API std::string cgv::utils::join | ( | const std::vector< std::string > & | strs, |
const std::string & | sep, | ||
bool | trailing_sep | ||
) |
CGV_API 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 | ||
) |
joins a given range of strings, separating them by the given separator; if trailing_sep is true, also puts a separator at the end
Definition at line 733 of file scan.cxx.
Referenced by cgv::gui::file_helper::add_multi_filter(), join(), and join().
|
extern |
joins a given range of tokens, separating them by the given separator; if trailing_sep is true, also puts a separator at the end
Definition at line 753 of file scan.cxx.
References join(), and to_strings().
CGV_API unsigned int cgv::utils::levenshtein_distance | ( | const std::string & | s1, |
const std::string & | s2 | ||
) |
CGV_API std::string cgv::utils::ltrim | ( | const std::string & | str, |
const std::string & | chars | ||
) |
CGV_API std::string & cgv::utils::ltrim | ( | std::string & | str, |
const std::string & | chars | ||
) |
CGV_API date_time cgv::utils::now | ( | ) |
Definition at line 70 of file date_time.cxx.
CGV_API std::ostream & cgv::utils::operator<< | ( | std::ostream & | os, |
const date & | D | ||
) |
Definition at line 80 of file date_time.cxx.
CGV_API std::ostream & cgv::utils::operator<< | ( | std::ostream & | os, |
const date_time & | DT | ||
) |
Definition at line 85 of file date_time.cxx.
CGV_API std::ostream & cgv::utils::operator<< | ( | std::ostream & | os, |
const statistics & | s | ||
) |
Definition at line 72 of file statistics.cxx.
CGV_API std::ostream & cgv::utils::operator<< | ( | std::ostream & | os, |
const time & | T | ||
) |
Definition at line 75 of file date_time.cxx.
|
inline |
stream out operator
Definition at line 72 of file token.h.
References cgv::utils::token::begin, cgv::utils::token::empty(), and cgv::utils::token::get_length().
CGV_API void cgv::utils::parse_enum_declarations | ( | const std::string & | enum_declarations, |
std::vector< token > & | enum_names, | ||
std::vector< int > & | enum_values | ||
) |
parse an enum declaration string into names and values
Definition at line 10 of file scan_enum.cxx.
References is_integer(), and cgv::utils::tokenizer::set_ws().
Referenced by find_enum_name().
CGV_API std::vector< uint8_t > cgv::utils::parse_hex_bytes | ( | const std::string & | byte_str | ) |
CGV_API std::string & cgv::utils::remove | ( | std::string & | s, |
char | c | ||
) |
CGV_API std::string cgv::utils::remove_copy | ( | const std::string & | s, |
char | c | ||
) |
CGV_API 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
Definition at line 159 of file scan.cxx.
Referenced by cgv::media::image::image_reader::construct_filter_string(), cgv::media::image::image_writer::construct_filter_string(), cgv::media::video::video_reader::construct_filter_string(), cgv::media::video::video_writer::construct_filter_string(), cgv::type::info::extract_type_name(), cgv::media::image::image_reader::get_supported_extensions(), cgv::media::image::image_writer::get_supported_extensions(), cgv::media::video::video_reader::get_supported_extensions(), and cgv::media::video::video_writer::get_supported_extensions().
CGV_API unsigned int cgv::utils::replace | ( | std::string & | _s, |
const std::string & | s1, | ||
const std::string & | s2 | ||
) |
CGV_API std::string cgv::utils::replace_special | ( | const std::string & | _s | ) |
replaces the german special characters ä,ö,ü,ß,Ä,Ö,Ü
Definition at line 141 of file scan.cxx.
Referenced by is_month().
CGV_API std::string cgv::utils::rtrim | ( | const std::string & | str, |
const std::string & | chars | ||
) |
CGV_API std::string & cgv::utils::rtrim | ( | std::string & | str, |
const std::string & | chars | ||
) |
CGV_API void cgv::utils::set_bits | ( | unsigned int & | bit_field, |
unsigned int | off, | ||
unsigned int | n, | ||
unsigned int | value | ||
) |
set n bits starting with index off of the given bit field from the first bits of the given integer value
Definition at line 64 of file bit_operations.cxx.
References disable_lower_bits(), and disable_upper_bits().
Referenced by cgv::data::packing_info::set_signed(), and cgv::data::packing_info::set_unsigned().
CGV_API const char * cgv::utils::skip_spaces | ( | const char * | begin, |
const char * | end | ||
) |
return new start pointer by skipping spaces at begin
Definition at line 683 of file scan.cxx.
References is_space().
Referenced by cgv::base::analyze_command(), balanced_find_content(), and cgv::ppp::command_token::is_empty().
CGV_API void cgv::utils::split_to_lines | ( | const char * | begin, |
const char * | end, | ||
std::vector< line > & | lines, | ||
bool | truncate_trailing_spaces = true |
||
) |
this function splits a text range at the newline characters into single lines.
If truncate_trailing_spaces is true all spaces and tabs at the end of the line are excluded.
Definition at line 65 of file advanced_scan.cxx.
References is_space().
Referenced by cgv::render::shader_program::build_program(), cgv::render::shader_program::collect_program(), cgv::render::shader_code::get_last_error(), cgv::render::shader_program::open_program_file(), cgv::media::mesh::obj_reader_base::parse_obj(), cgv::gui::vr_calibration::read_calibration(), cgv::media::mesh::obj_reader_base::read_mtl(), cgv::render::shader_code::resolve_includes(), split_to_lines(), and split_to_lines().
|
inline |
text range given as string
Definition at line 126 of file advanced_scan.h.
References split_to_lines().
|
inline |
text range given as token
Definition at line 119 of file advanced_scan.h.
References cgv::utils::token::begin, and split_to_lines().
CGV_API void cgv::utils::split_to_tokens | ( | const char * | begin, |
const char * | end, | ||
std::vector< token > & | tokens, | ||
const std::string & | separators, | ||
bool | merge_separators = true , |
||
const std::string & | open_parenthesis = "" , |
||
const std::string & | close_parenthesis = "" , |
||
const std::string & | whitespaces = " \t\n" , |
||
unsigned int | max_nr_tokens = -1 |
||
) |
this function splits a text range into tokens.
The function is typically applied to a line. One can specify whitespaces that are used to detect split locations but do not generate any tokens. The separators also mark split locations and generate tokens. If merge_separators is true, successive separators are merged into one token. Finally, one can specify a pair of character lists open_paranthesis and close_paranthesis that are used to overwrite the splitting mechanism and allow to generate tokens including whitespaces and separators. Some examples:
applying
vector<token> tokens; split_to_tokens(line.begin, line.end, tokens, ".,;:", "'{", "'}", " \t");
to the line
Hello world... This is a "split to tokens" test line. {copyright: S. G.}
generates the following tokens:
Hello world ... This is a split to tokens test line copyright: S. G.
Definition at line 6 of file advanced_scan.cxx.
References is_element().
Referenced by enumerate_options(), cgv::render::shader_program::extract_instances(), cgv::render::shader_code::set_vertex_attrib_locations(), split_to_tokens(), and split_to_tokens().
|
inline |
text range given as string
Definition at line 100 of file advanced_scan.h.
References split_to_tokens().
|
inline |
text range given as token
Definition at line 84 of file advanced_scan.h.
References cgv::utils::token::begin, and split_to_tokens().
CGV_API std::wstring cgv::utils::str2wstr | ( | const std::string & | s | ) |
convert a 8-bit string to a 16-bit string
Definition at line 11 of file convert.cxx.
Referenced by cgv::data::ascii_write_reflection_handler::ascii_write_reflection_handler(), and cgv::type::variant< T >::set().
CGV_API std::string cgv::utils::strip_cpp_comments | ( | const std::string & | source, |
bool | correct_new_lines = true |
||
) |
remove cpp-style comments from string
source | source string from which to strip cpp style comments |
correct_new_lines | whether to replace two character new lines with single character new lines |
Definition at line 115 of file advanced_scan.cxx.
Referenced by cgv::render::shader_code::set_vertex_attrib_locations().
CGV_API std::string cgv::utils::to_hex | ( | uint8_t | v, |
bool | use_upper_case | ||
) |
CGV_API char cgv::utils::to_lower | ( | char | c | ) |
convert char to lower case
Definition at line 39 of file scan.cxx.
Referenced by cgv::render::shader_code::detect_shader_type(), cgv::media::image::image_writer::image_writer(), vr_test::init(), interpret_special(), is_letter(), is_month(), cgv::base::load_plugin(), cgv::media::image::image_reader::open(), cgv::media::video::video_reader::open(), cgv::media::mesh::simple_mesh< T >::read(), to_lower(), and cgv::media::video::video_writer::video_writer().
CGV_API std::string cgv::utils::to_lower | ( | const std::string & | _s | ) |
CGV_API std::string cgv::utils::to_string | ( | const guid & | id | ) |
std::string cgv::utils::to_string | ( | const std::string & | v, |
unsigned int | w, | ||
unsigned int | p, | ||
bool | |||
) |
specialization of conversion from string to strings
Definition at line 7 of file convert_string.cxx.
References to_string().
Referenced by cgv::gui::provider::add_tree_node(), cgv::base::analyze_command(), cgv::render::shader_program::attach_program(), cgv::gui::provider::begin_tree_node_void(), cgv::render::shader_program::build_program(), cgv::render::shader_program::collect_program(), cgv::render::mesh_render_info::configure_vbos(), vr_emulator::create_controller_gui(), vr_test::create_gui(), cgv::render::texture::deduce_file_names(), enumerate_options(), cgv::ppp::expression_processor::evaluate(), cgv::render::shader_program::extract_instances(), cgv::render::extract_mesh(), find_enum_name(), cgv::render::shader_code::get_last_error(), cgv::ppp::variant::get_str(), config_view< T >::get_user_data(), cgv::render::context::get_window_matrix(), cgv::reflect::reflection_handler::group_traversal_name(), cgv::base::base::is_property(), cgv::base::load_plugin(), gui_config_file_observer::multi_observe(), cgv::base::base::multi_set(), cgv::utils::token::operator!=(), cgv::utils::token::operator!=(), cgv::utils::token::operator==(), cgv::utils::token::operator==(), cgv::gui::base_provider_generator::parse_gui_file(), cgv::media::mesh::obj_reader_base::parse_obj(), cgv::plot::plot2d::plot2d(), cgv::plot::plot3d::plot3d(), cgv::gui::question(), cgv::render::gl::gl_context::read_frame_buffer(), cgv::media::mesh::obj_reader_base::read_mtl(), cgv::base::ref_data_path_list(), cgv::base::property_declaration_reflection_handler::reflect_group_begin(), cgv::reflect::debug_reflection_handler::reflect_group_begin(), cgv::render::shader_code::resolve_includes(), cgv::type::variant< T >::set(), cgv::data::component_format::set_component_format(), cgv::render::context::set_current_lights(), cgv::data::data_format::set_data_format(), cgv::render::shader_code::set_vertex_attrib_locations(), cgv::ppp::command_token::split_off_from(), to_string(), to_string(), to_string(), to_string(), to_string(), and to_strings().
CGV_API std::string cgv::utils::to_string | ( | const std::string & | v, |
unsigned int | w, | ||
unsigned int | p, | ||
bool | |||
) |
specialization of conversion from string to strings
Definition at line 7 of file convert_string.cxx.
References to_string().
Referenced by cgv::gui::provider::add_tree_node(), cgv::base::analyze_command(), cgv::render::shader_program::attach_program(), cgv::gui::provider::begin_tree_node_void(), cgv::render::shader_program::build_program(), cgv::render::shader_program::collect_program(), cgv::render::mesh_render_info::configure_vbos(), vr_emulator::create_controller_gui(), vr_test::create_gui(), cgv::render::texture::deduce_file_names(), enumerate_options(), cgv::ppp::expression_processor::evaluate(), cgv::render::shader_program::extract_instances(), cgv::render::extract_mesh(), find_enum_name(), cgv::render::shader_code::get_last_error(), cgv::ppp::variant::get_str(), config_view< T >::get_user_data(), cgv::render::context::get_window_matrix(), cgv::reflect::reflection_handler::group_traversal_name(), cgv::base::base::is_property(), cgv::base::load_plugin(), gui_config_file_observer::multi_observe(), cgv::base::base::multi_set(), cgv::utils::token::operator!=(), cgv::utils::token::operator!=(), cgv::utils::token::operator==(), cgv::utils::token::operator==(), cgv::gui::base_provider_generator::parse_gui_file(), cgv::media::mesh::obj_reader_base::parse_obj(), cgv::plot::plot2d::plot2d(), cgv::plot::plot3d::plot3d(), cgv::gui::question(), cgv::render::gl::gl_context::read_frame_buffer(), cgv::media::mesh::obj_reader_base::read_mtl(), cgv::base::ref_data_path_list(), cgv::base::property_declaration_reflection_handler::reflect_group_begin(), cgv::reflect::debug_reflection_handler::reflect_group_begin(), cgv::render::shader_code::resolve_includes(), cgv::type::variant< T >::set(), cgv::data::component_format::set_component_format(), cgv::render::context::set_current_lights(), cgv::data::data_format::set_data_format(), cgv::render::shader_code::set_vertex_attrib_locations(), cgv::ppp::command_token::split_off_from(), to_string(), to_string(), to_string(), to_string(), to_string(), and to_strings().
std::string cgv::utils::to_string | ( | const T & | v, |
unsigned int | w, | ||
char | fill_char | ||
) |
convert an integer type T
into string of width w
with given fill character
Definition at line 33 of file convert_string.h.
References to_string().
std::string cgv::utils::to_string | ( | const T & | v, |
unsigned int | w = -1 , |
||
unsigned int | p = -1 , |
||
bool | fixed = false |
||
) |
convert a numeric type T
into string of width w
and precision p
Definition at line 18 of file convert_string.h.
References to_string().
|
inline |
convert to string
Definition at line 60 of file token.h.
References cgv::utils::token::begin, cgv::utils::token::empty(), cgv::utils::token::get_length(), and to_string().
|
inline |
|
inline |
convert to strings
Definition at line 62 of file token.h.
References to_string().
Referenced by join(), and to_strings().
CGV_API char cgv::utils::to_upper | ( | char | c | ) |
convert char to upper case
Definition at line 106 of file scan.cxx.
Referenced by cgv::gui::file_helper::compare_extension(), cgv::render::gl::gl_context::configure_gl(), cgv::gui::file_helper::ensure_extension(), cgv::render::shader_code::get_last_error(), has_option(), is_integer(), cgv::gui::shortcut::stream_in(), and to_upper().
CGV_API std::string cgv::utils::to_upper | ( | const std::string & | _s | ) |
CGV_API std::string cgv::utils::trim | ( | const std::string & | str, |
const std::string & | chars | ||
) |
CGV_API std::string & cgv::utils::trim | ( | std::string & | str, |
const std::string & | chars | ||
) |
trim white space or other characters from start and end of string
Definition at line 709 of file scan.cxx.
References ltrim(), and rtrim().
Referenced by cgv::gui::help_menu_entry::on_register(), and cgv::render::shader_code::resolve_includes().
CGV_API std::string cgv::utils::wstr2str | ( | const std::wstring & | ws | ) |
convert a 16-bit string to a 8-bit string
Definition at line 26 of file convert.cxx.
Referenced by cgv::type::variant< T >::get().
const unsigned char cgv::utils::AE = static_cast<unsigned char>(142) |
const unsigned char cgv::utils::ae = static_cast<unsigned char>(132) |
|
static |
Definition at line 51 of file convert.cxx.
|
constexpr |
Definition at line 20 of file stopwatch.cxx.
const unsigned char cgv::utils::OE = static_cast<unsigned char>(153) |
const unsigned char cgv::utils::oe = static_cast<unsigned char>(148) |
|
constexpr |
Definition at line 19 of file stopwatch.cxx.
const unsigned char cgv::utils::ss = static_cast<unsigned char>(225) |
const unsigned char cgv::utils::UE = static_cast<unsigned char>(154) |