CLASS  1.1
Fonctions membres publiques | Fonctions membres publiques statiques
Référence de la classe StringLine

#include <StringLine.hxx>

Liste de tous les membres

Fonctions membres publiques

string ReplaceAll (string InLine, string ToReplace, string By)

Fonctions membres publiques statiques

static string NextWord (string Line, int &start, char sep=' ', char alt_sep='\0')
static string PreviousWord (string Line, int &start, char sep=' ', char alt_sep='\0')
static void ToLower (string &Line)
static void ToUpper (string &Line)
static int Find (const char *search, string Line)
static int rFind (const char *search, string Line)
template<class out_T , class in_T >
static out_T convert (const in_T &t)
static int GetStartWord (string Line, int CurrentPosition, char sep=' ', char alt_sep='\0')
static int GetEndWord (string Line, int CurrentPosition, char sep=' ', char alt_sep='\0')

Description détaillée

The aim of this class is to provide tools to extract fields ("word") from a string and convert a string in Upper/Lower case. All methods are static so that it is not necessary to create object to use them

example:

 string line="The temperature is : 300.6 K";
 int start;

 1st method: creation of StringLine

 start=0;
 StringLine SL;
 string the=SL.NextWord(line,start);
 string temperature_is=SL.NextWord(line,start,':');
 string colon=SL.NextWord(line,start);
 double T=atof(SL.NextWord(line,start).c_str());
 cout<<the<<endl<<temperature_is<<endl<<T<<endl;
 
 2nd method: "using" the static methods
 
 start=0;
 the=StringLine::NextWord(line,start);
 temperature_is=StringLine::NextWord(line,start,':');
 colon=StringLine::NextWord(line,start);
 T=atof(StringLine::NextWord(line,start).c_str());
 cout<<the<<endl<<temperature_is<<endl<<T<<endl;
Auteur:
PTO
Version:
0.1

Définition à la ligne 49 du fichier StringLine.hxx.


Documentation des fonctions membres

template<class out_T , class in_T >
out_T StringLine::convert ( const in_T &  t) [inline, static]

Example:

         string s="32.12";
         double t=StringLine::convert<double>(s);
         string temperature=StringLine::convert<string>(300.);
Paramètres:
t: the input value

Définition à la ligne 252 du fichier StringLine.hxx.

int StringLine::Find ( const char *  search,
string  Line 
) [inline, static]

returns the position, starting from the begenning of the first occurence of search in Line if it is found, else returns -1

Paramètres:
search: a string to find
Line: where to search

Définition à la ligne 235 du fichier StringLine.hxx.

int StringLine::GetEndWord ( string  Line,
int  CurrentPosition,
char  sep = ' ',
char  alt_sep = '\0' 
) [inline, static]
Paramètres:
Line: a line containing words
CurrentPosition: from where to start to find the end of a word
sep: the separator between 2 words (default=space)
alt_sep: the alternative separator between 2 words (default='')

Définition à la ligne 217 du fichier StringLine.hxx.

int StringLine::GetStartWord ( string  Line,
int  CurrentPosition,
char  sep = ' ',
char  alt_sep = '\0' 
) [inline, static]
Paramètres:
Line: a line containing words
CurrentPosition: from where to start to find the begining of a word
sep: the separator between 2 words (default=space)
alt_sep: the alternative separator between 2 words (default='')

Définition à la ligne 195 du fichier StringLine.hxx.

string StringLine::NextWord ( string  Line,
int &  start,
char  sep = ' ',
char  alt_sep = '\0' 
) [inline, static]

Find Next word in a line starting from position "start" in the line. If an alternative separator is given, the word length is defined by the first position of sep or alt_sep found. The first value of start is in general 0 (i.e. the beginning of the Line)

Paramètres:
Line: a line containing words
start: from where to start to find the begining of a word
sep: the separator between 2 words (default=space)
alt_sep: the alternative separator between 2 words (default='')

Définition à la ligne 131 du fichier StringLine.hxx.

Voici le graphe des appelants de cette fonction :

string StringLine::PreviousWord ( string  Line,
int &  start,
char  sep = ' ',
char  alt_sep = '\0' 
) [inline, static]

Find Previous word in a line starting from position "start" in the line. If an alternative separator is given, the word length is defined by the first position of sep or alt_sep found. The first value of start is in general the end of the Line.

Paramètres:
Line: a line containing words
start: from where to start to find the begining of a word
sep: the separator between 2 words (default=space)
alt_sep: the alternative separator between 2 words (default='')

Définition à la ligne 147 du fichier StringLine.hxx.

string StringLine::ReplaceAll ( string  InLine,
string  ToReplace,
string  By 
) [inline]
Paramètres:
InLine: the string which contains the sub-string to replace
ToReplace: the sub-string to replace
By: the sub-string ToReplace is replaced by the sub-string By in Inline

Définition à la ligne 262 du fichier StringLine.hxx.

int StringLine::rFind ( const char *  search,
string  Line 
) [inline, static]

returns the position, starting from the end of the first occurence of search in Line if it is found, else returns -1

Paramètres:
search: a string to find
Line: where to search

Définition à la ligne 243 du fichier StringLine.hxx.

void StringLine::ToLower ( string &  Line) [inline, static]

Définition à la ligne 179 du fichier StringLine.hxx.

void StringLine::ToUpper ( string &  Line) [inline, static]

Définition à la ligne 187 du fichier StringLine.hxx.


La documentation de cette classe a été générée à partir du fichier suivant :
 Tout Classes Fichiers Fonctions Variables Macros