![]() |
TkN 2.1
Toolkit for Nuclei
|
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more... More...
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more...
Definition at line 53 of file tkstring.h.
#include <tkstring.h>
Public Types | |
enum | ECaseCompare { kExact , kIgnoreCase } |
Public Member Functions | |
tkstring () | |
tkstring (char _c) | |
tkstring (const char *_c) | |
tkstring (const std::string &_s) | |
tkstring (const unsigned char *_c) | |
tkstring (double _value, double _error) | |
virtual | ~tkstring () |
tkstring & | append (const tkstring &_st) |
double | atof () const |
Converts a string to double value. More... | |
int | atoi () const |
Converts a string to integer value. More... | |
int64_t | atoll () const |
Converts a string to long integer value. More... | |
bool | begins_with (const char *_s, ECaseCompare _cmp=kExact) const |
bool | begins_with (const tkstring &_pat, ECaseCompare _cmp=kExact) const |
tkstring & | capitalize () |
Change first letter of string from lower to upper case. More... | |
bool | contains (const char *_pat, ECaseCompare _cmp=kExact) const |
bool | contains (const tkstring &_pat, ECaseCompare _cmp=kExact) const |
tkstring | copy () const |
Returns a copy of this string. More... | |
int | count_string (const tkstring &_st) const |
bool | ends_with (const char *_s, ECaseCompare _cmp=kExact) const |
bool | ends_with (const tkstring &_pat, ECaseCompare _cmp=kExact) const |
bool | equal_to (const char *_s, ECaseCompare _cmp=kExact) const |
Returns true if the string and _s are identical. More... | |
bool | equal_to (const tkstring &_pat, ECaseCompare _cmp=kExact) const |
tkstring | extract_alpha () |
Returns a tkstring composed only of the alphabetic letters of the original tkstring. More... | |
tkstring | get_last_occurence (const char *_s1) |
size_t | index (const char *_s, size_t _pos=0, ECaseCompare _cmp=kExact) const |
Returns the index of the substring _s. More... | |
size_t | index (const tkstring &_pat, size_t _pos=0, ECaseCompare _cmp=kExact) const |
Returns the index of the substring _pat. More... | |
bool | is_alpha () const |
Checks whether tkstring is only composed of alphabetic letters. More... | |
bool | is_digit () const |
Checks if all characters in string are digits (0-9) or whitespaces. More... | |
bool | is_empty () const |
bool | is_float () const |
Checks if string contains a floating point or integer number. More... | |
bool | match (const char *_pattern) const |
bool | match (const tkstring &_pattern) const |
tkstring & | prepend (const tkstring &_st) |
std::istream & | read_line (std::istream &_strm, bool _skip_white=true) |
tkstring::read_line More... | |
tkstring & | remove_all (const char *_s1) |
tkstring & | remove_all (const tkstring &_s1) |
tkstring & | remove_all_extra_white_space () |
tkstring | remove_alpha () |
Returns a tkstring composed only of the non alphabetic letters of the original tkstring. More... | |
tkstring | remove_last_occurence (const char *_s1) |
tkstring & | replace_all (const char *_s1, const char *_s2) |
tkstring & | replace_all (const char *_s1, const tkstring &_s2) |
tkstring & | replace_all (const char *_s1, size_t _ls1, const char *_s2, size_t _ls2) |
tkstring & | replace_all (const tkstring &_s1, const char *_s2) |
tkstring & | replace_all (const tkstring &_s1, const tkstring &_s2) |
tkstring | strip_all_extra_white_space () const |
tkstring | substr (size_type __pos=0, size_type __n=npos) const |
Inlines. More... | |
tkstring & | to_lower () |
Change all letters to lower case. More... | |
tkstring & | to_upper () |
Change all letters to upper case. More... | |
std::vector< tkstring > | tokenize (const tkstring &_delim=" ") const |
Create a vector of string separated by at least one delimiter. More... | |
std::vector< tkstring > | tokenize_from_string (const tkstring &_delim) const |
Create a vector of string separated by a full string as delimiter. More... | |
Static Public Member Functions | |
static tkstring | Form (const char *_format,...) |
static const char * | form (const char *_format,...) |
static double | get_absolute_error (tkstring val, tkstring error) |
Get absolute uncertainty from value and error strings (1.27 4 -> 0.04), returns -1 in case of empty error string. More... | |
static double | get_precision (tkstring _st) |
Extract the precision for a given ENSDF data. More... | |
enum ECaseCompare |
Enumerator | |
---|---|
kExact | |
kIgnoreCase |
Definition at line 57 of file tkstring.h.
|
inline |
Definition at line 60 of file tkstring.h.
|
inline |
Definition at line 61 of file tkstring.h.
|
inline |
Definition at line 62 of file tkstring.h.
|
inline |
Definition at line 63 of file tkstring.h.
tkstring | ( | double | _value, |
double | _error | ||
) |
Definition at line 454 of file tkstring.cpp.
|
inline |
Definition at line 66 of file tkstring.h.
|
inlinevirtual |
Definition at line 68 of file tkstring.h.
Definition at line 227 of file tkstring.h.
double atof | ( | ) | const |
Converts a string to double value.
Basically a copy of KVString::Atof() from KaliVeda
Definition at line 191 of file tkstring.cpp.
int atoi | ( | ) | const |
Converts a string to integer value.
Basically a copy of KVString::Atoi() from KaliVeda
Definition at line 175 of file tkstring.cpp.
|
inline |
Converts a string to long integer value.
Definition at line 89 of file tkstring.h.
|
inline |
Definition at line 185 of file tkstring.h.
|
inline |
Definition at line 188 of file tkstring.h.
tkstring & capitalize | ( | ) |
Change first letter of string from lower to upper case.
Definition at line 376 of file tkstring.cpp.
|
inline |
Definition at line 197 of file tkstring.h.
|
inline |
Definition at line 194 of file tkstring.h.
tkstring copy | ( | ) | const |
Returns a copy of this string.
Definition at line 370 of file tkstring.cpp.
int count_string | ( | const tkstring & | _st | ) | const |
Definition at line 547 of file tkstring.cpp.
bool ends_with | ( | const char * | _s, |
ECaseCompare | _cmp = kExact |
||
) | const |
Definition at line 241 of file tkstring.cpp.
|
inline |
Definition at line 191 of file tkstring.h.
bool equal_to | ( | const char * | _s, |
ECaseCompare | _cmp = kExact |
||
) | const |
Returns true if the string and _s are identical.
_s | string to compare with |
_cmp | kExact or kIgnoreCase |
Definition at line 234 of file tkstring.cpp.
|
inline |
Definition at line 182 of file tkstring.h.
tkstring extract_alpha | ( | ) |
Returns a tkstring composed only of the alphabetic letters of the original tkstring.
Definition at line 387 of file tkstring.cpp.
|
static |
Definition at line 345 of file tkstring.cpp.
|
static |
Definition at line 431 of file tkstring.cpp.
Get absolute uncertainty from value and error strings (1.27 4 -> 0.04), returns -1 in case of empty error string.
Definition at line 631 of file tkstring.cpp.
tkstring get_last_occurence | ( | const char * | _s1 | ) |
Definition at line 329 of file tkstring.cpp.
|
static |
Extract the precision for a given ENSDF data.
st | string containing an ENSDF formated data |
'The standard numeric uncertainty denotes an uncertainty in the last significant figures'.
For example:
Given the quantity (NR or QP ...) as a string, this method returns the coefficient that must multiply the uncertainty field to get the absolute uncertainty.
Definition at line 649 of file tkstring.cpp.
size_t index | ( | const char * | _s, |
size_t | _pos = 0 , |
||
ECaseCompare | _cmp = kExact |
||
) | const |
Returns the index of the substring _s.
_s | substring to find |
_pos | occurence of this substring |
_cmp | kExact or kIgnoreCase |
Definition at line 218 of file tkstring.cpp.
|
inline |
Returns the index of the substring _pat.
Definition at line 200 of file tkstring.h.
bool is_alpha | ( | ) | const |
Checks whether tkstring is only composed of alphabetic letters.
Returns kTRUE if string contains only alphabetic letters
Definition at line 420 of file tkstring.cpp.
bool is_digit | ( | ) | const |
Checks if all characters in string are digits (0-9) or whitespaces.
Returns true if all characters in string are digits (0-9) or whitespaces, i.e. "123456" and "123 456" are both valid integer strings.
Returns false in case string length is 0 or string contains other characters or only whitespace.
Definition at line 81 of file tkstring.cpp.
|
inline |
Definition at line 163 of file tkstring.h.
bool is_float | ( | ) | const |
Checks if string contains a floating point or integer number.
Returns kTRUE if string contains a floating point or integer number.
Examples of valid formats are:
Definition at line 110 of file tkstring.cpp.
bool match | ( | const char * | _pattern | ) | const |
Definition at line 579 of file tkstring.cpp.
|
inline |
Definition at line 221 of file tkstring.h.
Definition at line 224 of file tkstring.h.
std::istream & read_line | ( | std::istream & | _strm, |
bool | _skip_white = true |
||
) |
|
inline |
Definition at line 218 of file tkstring.h.
Definition at line 215 of file tkstring.h.
tkstring & remove_all_extra_white_space | ( | ) |
Definition at line 526 of file tkstring.cpp.
tkstring remove_alpha | ( | ) |
Returns a tkstring composed only of the non alphabetic letters of the original tkstring.
Definition at line 401 of file tkstring.cpp.
tkstring remove_last_occurence | ( | const char * | _s1 | ) |
Definition at line 337 of file tkstring.cpp.
|
inline |
Definition at line 212 of file tkstring.h.
Definition at line 209 of file tkstring.h.
tkstring & replace_all | ( | const char * | _s1, |
size_t | _ls1, | ||
const char * | _s2, | ||
size_t | _ls2 | ||
) |
Definition at line 317 of file tkstring.cpp.
Definition at line 206 of file tkstring.h.
Definition at line 203 of file tkstring.h.
tkstring strip_all_extra_white_space | ( | ) | const |
Definition at line 560 of file tkstring.cpp.
|
inline |
Inlines.
Definition at line 179 of file tkstring.h.
tkstring & to_lower | ( | ) |
Change all letters to lower case.
Definition at line 59 of file tkstring.cpp.
tkstring & to_upper | ( | ) |
Change all letters to upper case.
Definition at line 65 of file tkstring.cpp.
Create a vector of string separated by at least one delimiter.
Definition at line 254 of file tkstring.cpp.
Create a vector of string separated by a full string as delimiter.
Definition at line 294 of file tkstring.cpp.