22 #ifndef STRING_HELPER_H
23 #define STRING_HELPER_H
54 static T
value_of(
const std::string& in,
bool *is_ok=0)
57 std::istringstream is(in);
58 bool _is_ok=bool(is>>obj);
66 static std::vector <T>
value_of(
const std::vector <std::string>& in,
bool *is_ok=0)
73 std::vector <T> obj(N);
77 obj[k]=value_of<T> (in[k],&temp_is_ok);
78 if(is_ok!=0 && temp_is_ok==
false)
91 std::ostringstream oss;
93 return std::string(oss.str());
102 static std::string
zero_padding(
const std::string& input,
const int& zero_number=4);
105 template <
typename T>
110 static std::string
to_lower(
const std::string& input);
112 static std::string
to_upper(
const std::string& input);
115 static std::vector <std::string>
delete_empty(
const std::vector <std::string>& in);
126 static std::pair<std::pair<int,int>,std::pair<std::string,std::string> >
extract_number_part(
const std::string& filename);
132 static std::vector<std::string>
load_filename_sequence(
const std::string filename,
const unsigned int& iteration=1);
151 static std::vector <std::string>
tokenize(
const std::string& str,
const std::string& delimiters=
" ");
165 static file_helper copy(
const std::string& input_filename,
const std::string& output_filename);
static std::vector< std::string > load_filename_sequence(const std::string filename, const unsigned int &iteration=1)
load file sequence
Definition: string_helper.cpp:169
static std::string to_string_padded(const T &x, const unsigned int &zero_number=4)
helper to write padded string from a number easily
Definition: string_helper.hpp:106
A helper class to manipulate string (token, convert, ...)
Definition: string_helper.hpp:41
static std::string to_lower(const std::string &input)
return the lower case of a string
Definition: string_helper.cpp:72
static T value_of(const std::string &in, bool *is_ok=0)
return the value of the given string
Definition: string_helper.hpp:54
helper class with files
Definition: string_helper.hpp:156
static std::string to_upper(const std::string &input)
return the upper case of a string
Definition: string_helper.cpp:79
Helper class to tokenize easily a string.
Definition: string_helper.hpp:140
static std::string zero_padding(const std::string &input, const int &zero_number=4)
fill the appropriate number of zero to have the same size
Definition: string_helper.cpp:64
static std::vector< T > value_of(const std::vector< std::string > &in, bool *is_ok=0)
return the value of the given vector of string
Definition: string_helper.hpp:66
static std::string to_string(const T &t)
get the string corresponding to the given value
Definition: string_helper.hpp:89
static std::vector< std::string > delete_empty(const std::vector< std::string > &in)
delete the empty space of a vector of string
Definition: string_helper.cpp:87
static std::vector< std::string > tokenize(const std::string &str, const std::string &delimiters=" ")
tokenize a given string
Definition: string_helper.cpp:31
static file_helper copy(const std::string &input_filename, const std::string &output_filename)
copy the content of a file into an other one
Definition: string_helper.cpp:98
static std::pair< std::pair< int, int >, std::pair< std::string, std::string > > extract_number_part(const std::string &filename)
extract the last number part of a string and give the number of zeros
Definition: string_helper.cpp:124