cpe::string_converter Class Reference

A helper class to manipulate string (token, convert, ...) More...

Static Public Member Functions

template<typename T >
static T value_of (const std::string &in, bool *is_ok=0)
 return the value of the given string More...
 
template<typename T >
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 More...
 
template<typename T >
static std::string to_string (const T &t)
 get the string corresponding to the given value More...
 
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 More...
 
template<typename T >
static std::string to_string_padded (const T &x, const unsigned int &zero_number=4)
 helper to write padded string from a number easily More...
 
static std::string to_lower (const std::string &input)
 return the lower case of a string More...
 
static std::string to_upper (const std::string &input)
 return the upper case of a string More...
 
static std::vector< std::string > delete_empty (const std::vector< std::string > &in)
 delete the empty space of a vector of string More...
 
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 More...
 
static std::vector< std::string > load_filename_sequence (const std::string filename, const unsigned int &iteration=1)
 load file sequence More...
 

Detailed Description

A helper class to manipulate string (token, convert, ...)

A class to convert a string into value or value into string

Member Function Documentation

std::vector< std::string > cpe::string_converter::delete_empty ( const std::vector< std::string > &  in)
static

delete the empty space of a vector of string

std::pair< std::pair< int, int >, std::pair< std::string, std::string > > cpe::string_converter::extract_number_part ( const std::string &  filename)
static

extract the last number part of a string and give the number of zeros

Parameters
intnumber found (-1 if failed)
intnumber of zeros (-1 if failed)
stringfirst part of the word
stringlast part of the word

ex. my_file_001.dat -> number=1, zeros=2, part_1="my_file_" part_2=".dat"

Referenced by load_filename_sequence().

std::vector< std::string > cpe::string_converter::load_filename_sequence ( const std::string  filename,
const unsigned int &  iteration = 1 
)
static

load file sequence

Try to load every filename following the numbers on disk

References extract_number_part(), to_string(), and zero_padding().

+ Here is the call graph for this function:

std::string cpe::string_converter::to_lower ( const std::string &  input)
static

return the lower case of a string

template<typename T >
static std::string cpe::string_converter::to_string ( const T &  t)
inlinestatic

get the string corresponding to the given value

example: std::string val=mesh_conv::string_converter::to_string(4.0*78.5);

Referenced by cpe::quad_index::assert_size(), cpe::surface_param::assert_size(), cpe::grid::assert_size(), load_filename_sequence(), and to_string_padded().

template<typename T >
static std::string cpe::string_converter::to_string_padded ( const T &  x,
const unsigned int &  zero_number = 4 
)
inlinestatic

helper to write padded string from a number easily

References to_string(), and zero_padding().

+ Here is the call graph for this function:

std::string cpe::string_converter::to_upper ( const std::string &  input)
static

return the upper case of a string

template<typename T >
static T cpe::string_converter::value_of ( const std::string &  in,
bool *  is_ok = 0 
)
inlinestatic

return the value of the given string

Returns
the value asked and a boolean is set to 0(!=0) if the conversion succed (failed)

example: double val=mesh_conv::string_converter::value_of<double> ("4.54");

template<typename T >
static std::vector<T> cpe::string_converter::value_of ( const std::vector< std::string > &  in,
bool *  is_ok = 0 
)
inlinestatic

return the value of the given vector of string

std::string cpe::string_converter::zero_padding ( const std::string &  input,
const int &  zero_number = 4 
)
static

fill the appropriate number of zero to have the same size

exemple zero_padding("62",5)="00062"

exemple zero_padding("c;7",4)="0x;7"

Referenced by load_filename_sequence(), and to_string_padded().


The documentation for this class was generated from the following files: