English Français

Documentation / Manuel développeur

Modules disponibles

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / Launcher: TamponTexte Class Reference
Uranie / Launcher v4.9.0
/* @license-end */
TamponTexte Class Reference

TamponTExte contains basic tools for handling strings in data file manipulations. More...

#include <TamponTexte.h>

Collaboration diagram for TamponTexte:

Public Member Functions

 TamponTexte (const char *, int dummy=0)
 
void ecrit (const char *nom=0)
 
const char * champLigne (int ifield, int iline)
 
const char * champ (int ifield)
 
std::string ligne (int iline)
 
void initSeparateurs (const char *)
 
void initFieldSeparateur (const char *)
 
void initCarCommentaires (const char *)
 
void elimineCommentaires ()
 
void elimineBlancs ()
 
bool estVide () const
 
int nombreLignes ()
 
int nombreChamps ()
 
int nombreChampsLigne (int)
 
void remplaceChamp (int, const char *)
 
const char * nom () const
 

Private Member Functions

void replaceAll (std::string &buffer, const std::string &str1, const std::string &str2)
 

Private Attributes

bool _blog
 
std::vector< std::string > _separators
 
std::string _cFieldSeparator
 
std::vector< std::string > _comments
 
std::string _buffer
 
std::string _name
 

Detailed Description

TamponTExte contains basic tools for handling strings in data file manipulations.

TamponTexte comes as a replacement for the CLUB equivalent class

Constructor & Destructor Documentation

◆ TamponTexte()

TamponTexte::TamponTexte ( const char *  filename,
int  dummy = 0 
)

Creates a TamponTexte object by reading a file and storing it in the working buffer

Parameters
filenamename of the ascii file read for the buffer
dummyunused param in order to reproduce the club syntax

References _buffer, _cFieldSeparator, _name, and TamponTexteError::printMessage().

Member Function Documentation

◆ champ()

const char * TamponTexte::champ ( int  ifield)
Parameters
ifieldtoken number (1-indexing)
Returns
token Parses the buffer with separators (" ", "\n" and "\t" being default) as delimiters.

References _buffer, _cFieldSeparator, _separators, TamponTexteError::printMessage(), and replaceAll().

Referenced by ClassImp(), and ClassImp().

◆ champLigne()

const char * TamponTexte::champLigne ( int  ifield,
int  iline 
)
Parameters
ilineline number
ifieldfield number
Returns
field retrieves the field designated by a (field, line) double (with 1-indexing)

For instance, on file : aa bb cc dd ee ff

champLigne (1,3) will return "ee"

References _buffer, _cFieldSeparator, _separators, TamponTexteError::printMessage(), and replaceAll().

Referenced by ClassImp(), ClassImp(), and ClassImp().

◆ ecrit()

void TamponTexte::ecrit ( const char *  name = 0)
Parameters
namefile name for writing the buffer (default : input file)

References _buffer, _name, and TamponTexteError::printMessage().

Referenced by ClassImp(), and ClassImp().

◆ elimineBlancs()

void TamponTexte::elimineBlancs ( )

Deletes lines with white caracters only.

References _buffer.

Referenced by ClassImp(), ClassImp(), and ClassImp().

◆ elimineCommentaires()

void TamponTexte::elimineCommentaires ( )

Eliminates comments. Lines starting with comments will be entirely removed. For lines with a comment symbol in the middle, the line will be deleted after the comment symbol.

References _buffer, and _comments.

Referenced by ClassImp(), ClassImp(), ClassImp(), and ClassImp().

◆ estVide()

bool TamponTexte::estVide ( ) const

References _buffer.

Referenced by ClassImp(), ClassImp(), ClassImp(), ClassImp(), and ClassImp().

◆ initCarCommentaires()

void TamponTexte::initCarCommentaires ( const char *  comment)

Defines comment symbols

Parameters
commentlist of chars for symbols starting comments

References _comments.

Referenced by ClassImp(), ClassImp(), ClassImp(), ClassImp(), and ClassImp().

◆ initFieldSeparateur()

void TamponTexte::initFieldSeparateur ( const char *  separator)

Adds a separator character to the separator list used for parsing tokens

References _cFieldSeparator.

Referenced by ClassImp(), ClassImp(), ClassImp(), ClassImp(), and ClassImp().

◆ initSeparateurs()

void TamponTexte::initSeparateurs ( const char *  separator)

Adds a separator character to the separator list used for parsing tokens

References _separators.

Referenced by ClassImp(), ClassImp(), ClassImp(), ClassImp(), and ClassImp().

◆ ligne()

std::string TamponTexte::ligne ( int  iline)

References _buffer, and TamponTexteError::printMessage().

Referenced by ClassImp().

◆ nom()

const char * TamponTexte::nom ( ) const

References _name.

Referenced by ClassImp(), and ClassImp().

◆ nombreChamps()

int TamponTexte::nombreChamps ( )
Returns
number of tokens in the buffer

References _buffer, and _cFieldSeparator.

Referenced by ClassImp(), and ClassImp().

◆ nombreChampsLigne()

int TamponTexte::nombreChampsLigne ( int  iline)
Parameters

iline line number (0-indexing)

Returns
number of tokens on line iline

References _buffer, _cFieldSeparator, _separators, and replaceAll().

Referenced by ClassImp(), ClassImp(), and ClassImp().

◆ nombreLignes()

int TamponTexte::nombreLignes ( )
Returns
number of lines in the buffer

References _buffer.

Referenced by ClassImp(), ClassImp(), and ClassImp().

◆ remplaceChamp()

void TamponTexte::remplaceChamp ( int  itoken,
const char *  replace 
)
Parameters
itokentoken number (0-indexing)
replacestring for replacement Replaces token number itoken with string replace

References _buffer, _cFieldSeparator, _separators, and replaceAll().

Referenced by ClassImp(), and ClassImp().

◆ replaceAll()

void TamponTexte::replaceAll ( std::string &  buffer,
const std::string &  str1,
const std::string &  str2 
)
private

Replace all occurrences of str1 by str2 in buffer

Parameters
bufferstring to perform the replacement
str1string to be replaced by str2
str2string that replaces str1

Referenced by champ(), champLigne(), nombreChampsLigne(), and remplaceChamp().

Member Data Documentation

◆ _blog

bool TamponTexte::_blog
private

◆ _buffer

◆ _cFieldSeparator

std::string TamponTexte::_cFieldSeparator
private

◆ _comments

std::vector<std::string> TamponTexte::_comments
private

◆ _name

std::string TamponTexte::_name
private

Referenced by ecrit(), nom(), and TamponTexte().

◆ _separators

std::vector<std::string> TamponTexte::_separators
private