src/tool/string_tools.h File Reference

#include "../include/base.h"
#include <string>

Include dependency graph for string_tools.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define STRING_TOOLS__H

Functions

bool str2long (const std::string &txt, long &valeur)
bool str2int (const std::string &txt, int &valeur)
bool str2double (const std::string &txt, double &valeur)
bool str2bool (const std::string &str, bool &value)
std::string long2str (long x)
std::string ulong2str (ulong x)
std::string double2str (ulong x)
std::string bool2str (bool x)


Define Documentation

#define STRING_TOOLS__H

Definition at line 23 of file string_tools.h.


Function Documentation

std::string bool2str ( bool  x  ) 

std::string double2str ( ulong  x  ) 

std::string long2str ( long  x  ) 

Definition at line 74 of file string_tools.cpp.

00075 {
00076   std::ostringstream ss;
00077   ss << x;
00078   return ss.str();
00079 }

Here is the caller graph for this function:

bool str2bool ( const std::string &  str,
bool &  value 
)

Definition at line 49 of file string_tools.cpp.

00050 {
00051   // Try to convert str to a boolean value
00052   // return true and set the value on succeed
00053   // return if false its not a boolean
00054   if(str=="1" || str=="true" || str=="on")
00055   {
00056     value = true;
00057     return true;
00058   }
00059   if(str=="0" || str=="false" || str=="off")
00060   {
00061     value = false;
00062     return true;
00063   }
00064   return false;
00065 }

Here is the caller graph for this function:

bool str2double ( const std::string &  txt,
double &  valeur 
)

Definition at line 41 of file string_tools.cpp.

00042 {
00043   std::stringstream ss;
00044   ss << txt;
00045   ss >> valeur;
00046   return true;
00047 }

Here is the caller graph for this function:

bool str2int ( const std::string &  txt,
int &  valeur 
)

Definition at line 33 of file string_tools.cpp.

00034 {
00035   std::stringstream ss;
00036   ss << txt;
00037   ss >> valeur;
00038   return true;
00039 }

Here is the caller graph for this function:

bool str2long ( const std::string &  txt,
long &  valeur 
)

Definition at line 25 of file string_tools.cpp.

00026 {
00027   std::stringstream ss;
00028   ss << txt;
00029   ss >> valeur;
00030   return true;
00031 }

Here is the caller graph for this function:

std::string ulong2str ( ulong  x  ) 

Definition at line 81 of file string_tools.cpp.

00082 {
00083   std::ostringstream ss;
00084   ss << x;
00085   return ss.str();
00086 }

Here is the caller graph for this function:


Generated on Mon Jan 1 13:27:32 2007 for Wormux by  doxygen 1.4.7