faudes::Token Class Reference

#include <token.h>

List of all members.


Detailed Description

Tokens model atomic data for stream IO.

A Token models a string or numeric datum that can be read from a or written to a C++ stream. The class itself implements the representation of the data including its type. For section handling and actual file processing see TokenReader and TokenWriter.

Parameters:
mType faudes::TokenType of the Token
mStringValue Token value as C++-type std::string
mIntegerValue Token value as C++-type long integer
mFloatValue Token value of C++-type double

Definition at line 52 of file token.h.

Public Types

enum  TokenType {
  None, Begin, End, String,
  Option, Integer, Integer16, Float
}
 Token types:. More...

Public Member Functions

 Token (void)
 Empty constructor, constructs None token.
 Token (const Token &rToken)
 Copy constructor.
 ~Token (void)
 Token destructor.
void SetNone (void)
 Initialize None token.
void SetString (const std::string &rName)
 Initialize as String token.
void SetBegin (const std::string &rName)
 Initialize as Begin token.
void SetEnd (const std::string &rName)
 Initialize as End token.
void SetOption (const std::string &rName)
 Initialize as Option token.
void SetInteger (const long int number)
 Initialize as Integer token.
void SetInteger16 (const long int number)
 Initialize as Integer16 token.
void SetFloat (const double number)
 Initialize as Float token.
long int IntegerValue (void) const
 Get integer value of a numeric token.
double FloatValue (void) const
 Get float value of a numeric token.
const std::string & StringValue (void) const
 Get string value of a name token.
TokenType Type (void) const
 Get token Type.
int Read (std::istream *pStream)
 Read Token from input stream.
void Write (std::ostream *pStream)
 Write Token to output stream.

Private Member Functions

bool ReadNumber (std::istream *pStream)
 Read a number from an input file stream.
bool ReadString (std::istream *pStream, char stop)
 Read a std::string value from an input file stream.
int ReadSpace (std::istream *pStream)
 Read (ignore) spaces and comments in an input file stream.

Private Attributes

TokenType mType
 Token type.
std::string mStringValue
 Token std::string value (if Token is of type Name, Begein or End).
long int mIntegerValue
 Token integer value (if Token is of type Integer or Integer16).
double mFloatValue
 Token float value (if Token is of type Float).


Member Enumeration Documentation

enum faudes::Token::TokenType
 

Token types:.

Enumerator:
None  Invalid/empty token.
Begin  <label> (begin of section)
End  <\label> (end of section)
String  "name" (the name may not contain a quote (") )
Option  +xyZ+ (the option string may not contain a "+")
Integer  1234 (non-negative)
Integer16  0x12fff ("0x" makes a number Integer16)
Float  -12.34 ("-" or "." make a number a float)

Definition at line 74 of file token.h.


Constructor & Destructor Documentation

faudes::Token::Token void   ) 
 

Empty constructor, constructs None token.

Definition at line 28 of file token.cpp.

faudes::Token::Token const Token rToken  ) 
 

Copy constructor.

faudes::Token::~Token void   ) 
 

Token destructor.

Definition at line 36 of file token.cpp.


Member Function Documentation

double faudes::Token::FloatValue void   )  const [inline]
 

Get float value of a numeric token.

Returns:
Token float value

Definition at line 164 of file token.h.

long int faudes::Token::IntegerValue void   )  const [inline]
 

Get integer value of a numeric token.

Returns:
Token's integer value

Definition at line 154 of file token.h.

int faudes::Token::Read std::istream *  pStream  ) 
 

Read Token from input stream.

Parameters:
pStream Pointer to std::ifstream
Exceptions:
Exception 
  • ios exceptions (eg file io error)

Definition at line 244 of file token.cpp.

bool faudes::Token::ReadNumber std::istream *  pStream  )  [private]
 

Read a number from an input file stream.

Parameters:
pStream Reference to std::istream
Returns:
Success

Definition at line 80 of file token.cpp.

int faudes::Token::ReadSpace std::istream *  pStream  )  [private]
 

Read (ignore) spaces and comments in an input file stream.

Parameters:
pStream Reference to std::istream
Returns:
Number of lines read

Definition at line 207 of file token.cpp.

bool faudes::Token::ReadString std::istream *  pStream,
char  stop
[private]
 

Read a std::string value from an input file stream.

Parameters:
pStream Reference to std::istream
stop Stop character
Returns:
Success

Definition at line 182 of file token.cpp.

void faudes::Token::SetBegin const std::string &  rName  ) 
 

Initialize as Begin token.

Parameters:
rName Title of section to fill the Token

Definition at line 50 of file token.cpp.

void faudes::Token::SetEnd const std::string &  rName  ) 
 

Initialize as End token.

Parameters:
rName Title of section to fill the Token

Definition at line 55 of file token.cpp.

void faudes::Token::SetFloat const double  number  ) 
 

Initialize as Float token.

Parameters:
number Number to fill the Token

Definition at line 75 of file token.cpp.

void faudes::Token::SetInteger const long int  number  ) 
 

Initialize as Integer token.

Parameters:
number Number to fill the Token

Definition at line 65 of file token.cpp.

void faudes::Token::SetInteger16 const long int  number  ) 
 

Initialize as Integer16 token.

Parameters:
number Number to fill the Token

Definition at line 70 of file token.cpp.

void faudes::Token::SetNone void   ) 
 

Initialize None token.

Definition at line 40 of file token.cpp.

void faudes::Token::SetOption const std::string &  rName  ) 
 

Initialize as Option token.

Parameters:
rName Option to fill the Token

Definition at line 60 of file token.cpp.

void faudes::Token::SetString const std::string &  rName  ) 
 

Initialize as String token.

Parameters:
rName String to fill the Token

Definition at line 45 of file token.cpp.

const std::string& faudes::Token::StringValue void   )  const [inline]
 

Get string value of a name token.

Returns:
Token's name value

Definition at line 174 of file token.h.

TokenType faudes::Token::Type void   )  const [inline]
 

Get token Type.

Returns:
Token's TokenType

Definition at line 184 of file token.h.

void faudes::Token::Write std::ostream *  pStream  ) 
 

Write Token to output stream.

Parameters:
pStream Pointer to ostream
Exceptions:
Exception 
  • ios exceptions (eg file io error,)

Definition at line 140 of file token.cpp.


Member Data Documentation

double faudes::Token::mFloatValue [private]
 

Token float value (if Token is of type Float).

Definition at line 219 of file token.h.

long int faudes::Token::mIntegerValue [private]
 

Token integer value (if Token is of type Integer or Integer16).

Definition at line 216 of file token.h.

std::string faudes::Token::mStringValue [private]
 

Token std::string value (if Token is of type Name, Begein or End).

Definition at line 213 of file token.h.

TokenType faudes::Token::mType [private]
 

Token type.

Definition at line 210 of file token.h.


The documentation for this class was generated from the following files:
Generated on Fri May 9 11:26:48 2008 for libFAUDES 2.09b by  doxygen 1.4.4