libFAUDES

Sections

Index

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

Public Types

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

Public Member Functions

 Token (void)
 Empty constructor, constructs None token.
 Token (const Token &rToken)
 Copy constructor.
 ~Token (void)
 Token destructor.
Tokenoperator= (const Token &rOther)
 Assignment operator.
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.
void SetBinary (const char *data, long int len)
 Initialize Binary 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.

Static Public Member Functions

static void WriteBinary (std::ostream *pStream, const char *pData, long int len)
 Write specified binary data as base64 string to output stream.

Private Member Functions

void WriteString (std::ostream *pStream, char stop)
 Write a std::string value to an output stream.
void WriteBinary (std::ostream *pStream)
 Write my binary data as base64 string to output stream.
bool ReadNumber (std::istream *pStream)
 Read a number from an input file stream.
int ReadBinary (std::istream *pStream)
 Read a base64 binary string from an input file stream.
int 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

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)
Binary  =ABhlkjj= (base64 encoded binary data)


Constructor & Destructor Documentation

faudes::Token::Token ( void   ) 

Empty constructor, constructs None token.

faudes::Token::Token ( const Token rToken  ) 

Copy constructor.

faudes::Token::~Token ( void   ) 

Token destructor.


Member Function Documentation

Token & faudes::Token::operator= ( const Token rOther  ) 

Assignment operator.

void faudes::Token::SetNone ( void   ) 

Initialize None token.

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

Initialize as String token.

Parameters:
rName String to fill the Token

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

Initialize as Begin token.

Parameters:
rName Title of section to fill the Token

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

Initialize as End token.

Parameters:
rName Title of section to fill the Token

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

Initialize as Option token.

Parameters:
rName Option to fill the Token

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

Initialize as Integer token.

Parameters:
number Number to fill the Token

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

Initialize as Integer16 token.

Parameters:
number Number to fill the Token

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

Initialize as Float token.

Parameters:
number Number to fill the Token

void faudes::Token::SetBinary ( const char *  data,
long int  len 
)

Initialize Binary token.

This method allocates a copy of the data. For writing only, you may use the TokenWriter interface to avoid the local copy.

Parameters:
data Reference to raw data record
len Number of bytes in record

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

Get integer value of a numeric token.

Returns:
Token's integer value

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

Get float value of a numeric token.

Returns:
Token float value

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

Get string value of a name token.

Returns:
Token's name value

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

Get token Type.

Returns:
Token's TokenType

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)

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,)

void faudes::Token::WriteBinary ( std::ostream *  pStream,
const char *  pData,
long int  len 
) [static]

Write specified binary data as base64 string to output stream.

Parameters:
pStream Reference to std::ostream
len Number of bytes to write
pData Data to write

void faudes::Token::WriteString ( std::ostream *  pStream,
char  stop 
) [private]

Write a std::string value to an output stream.

Parameters:
pStream Reference to std::ostream
stop Character to escap eby prepending "\\"

void faudes::Token::WriteBinary ( std::ostream *  pStream  )  [private]

Write my binary data as base64 string to output stream.

Parameters:
pStream Reference to std::ostream

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

Read a number from an input file stream.

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

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

Read a base64 binary string from an input file stream.

Parameters:
pStream Reference to std::istream
Returns:
Line count or -1 for error

int 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:
Line count or -1 for error

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


Member Data Documentation

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

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

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

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

double faudes::Token::mFloatValue [private]

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


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

libFAUDES 2.13a c++ source docu by doxygen 1.5.6