proj home

Files   Classes   Functions   Hierarchy  

stringconvert Class Reference

String helper functions. More...

#include <stringconvert.h>

List of all members.

Static Public Member Functions

template<typename T >
static stringc tostring (T const x)
 Convert from a data type to a string.
template<typename T >
static void fromstring (T &x, stringc &s)
 Convert or interpret from a string to a data type.
static void findandreplace (string &source, stringc &find, stringc &replace)
 Repeated replace a string on the original source string.
static stringc findandreplacefn (stringc &source, stringc &find, stringc &replace)
 Find and replace function.


Detailed Description

String helper functions.

Definition at line 36 of file stringconvert.h.


Member Function Documentation

void stringconvert::findandreplace ( string &  source,
stringc find,
stringc replace 
) [static]

Repeated replace a string on the original source string.

Taken from http://snipplr.com/view/1055/find-and-replace-one-string-with-another/

Definition at line 88 of file stringconvert.cpp.

Referenced by htmlstring::serialize(), and htmlstring::serializeInverse().

00093 { 
00094   size_t pos = 0; 
00095   size_t findlen = find.length(); 
00096   size_t replacelen = replace.length();
00097 
00098   if( findlen == 0 )
00099     return;
00100 
00101   for( ; (pos = source.find( find, pos )) != string::npos; )
00102   {
00103     source.replace( pos, findlen, replace );
00104     pos += replacelen;
00105   }
00106 }

stringc stringconvert::findandreplacefn ( stringc source,
stringc find,
stringc replace 
) [static]

Find and replace function.

Definition at line 109 of file stringconvert.cpp.

Referenced by mazedisp03::settings().

00114 { 
00115   string str(source); 
00116   findandreplace(str,find,replace); 
00117   return str; 
00118 }

template<typename T >
static void stringconvert::fromstring ( T x,
stringc s 
) [inline, static]

Convert or interpret from a string to a data type.

Definition at line 50 of file stringconvert.h.

00051   {
00052     stringstream ss(s);
00053     ss >> x;
00054   }

template<typename T >
static stringc stringconvert::tostring ( T const   x  )  [inline, static]

Convert from a data type to a string.

Definition at line 42 of file stringconvert.h.

Referenced by mazegameD2state01::settings(), and mazedisp03::settings().

00043   {
00044     stringstream ss;
00045     ss << x;
00046     return ss.str();
00047   }


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

Generated on Fri Mar 4 00:50:18 2011 for Chelton Evans Source by  doxygen 1.5.8