cpe::string_converter Class Reference

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

List of all members.

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
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
template<typename T >
static std::string to_string (const T &t)
 get the string corresponding to the given value
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
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
static std::string to_lower (const std::string &input)
 return the lower case of a string
static std::string to_upper (const std::string &input)
 return the upper case of a string
static std::vector< std::string > delete_empty (const std::vector< std::string > &in)
 delete the empty space of a vector of string
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
static std::vector< std::string > load_filename_sequence (const std::string filename, const unsigned int &iteration=1)
 load file sequence

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

Referenced by cpe::texture::load_ppm_picture().

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:
int,: number found (-1 if failed)
int,: number of zeros (-1 if failed)
string,: first part of the word
string,: last 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  )  [inline, static]

get the string corresponding to the given value

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

Referenced by cpe::v4::assert_size(), cpe::v3::assert_size(), cpe::matrix3::assert_size(), draw_fps(), 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 
) [inline, static]

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 std::vector<T> cpe::string_converter::value_of ( const std::vector< std::string > &  in,
bool *  is_ok = 0 
) [inline, static]

return the value of the given vector of string

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

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_convstring_converter::value_of<double> ("4.54");

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:
Generated on Fri Apr 1 17:22:46 2011 by  doxygen 1.6.3