libFAUDES

Sections

Index

faudes::TokenWriter Class Reference

#include <tokenwriter.h>

List of all members.


Detailed Description

A TokenWriter writes sequential tokens to a file, a string or stdout.

It is the counterpart of the TokenReader. Since wrtiting data comparatively straight foreward, there is no explicit support of sections etc. It is left to the calling function to organise the output.

Definition at line 38 of file tokenwriter.h.


Public Types

enum  Mode { File, Stdout, String }
 Mode of operation: write to from file, string or stdout. More...

Public Member Functions

 TokenWriter (Mode mode)
 Console or String TokenWriter constructor.
 TokenWriter (const std::string &rFilename, std::ios::openmode openmode=std::ios::out|std::ios::trunc)
 File TokenWriter constructor.
 ~TokenWriter (void)
 Destructor.
std::string FileName (void) const
 Get the filename.
Mode DestMode (void) const
 Get file mode.
std::string Str (void)
 Retrieve output as string (if in String mode).
int Columns (void) const
 Get number of columns in a line.
void Columns (int columns)
 Set number of columns in a line.
void Endl (void)
 Write endl separator.
void Endl (bool on)
 Turn endl separator on/off.
void Write (Token &rToken)
 Write next token.
void WriteString (const std::string &rString)
 Write string (may not contain any quotes.
void WriteInteger (Idx index)
 Write non negative integer.
void WriteFloat (const double &val)
 Write float.
void WriteInteger16 (long int val)
 Write integer as hex.
void WriteOption (const std::string &rOpt)
 Write option (may not contain any "+").
void WriteBegin (const std::string &rLabel)
 Write begin label.
void WriteEnd (const std::string &rLabel)
 Write end label.
void WriteComment (const std::string &rComment)
 Write comment.
void WriteBinary (const char *pData, long int len)
 Write comment.
TokenWriteroperator<< (Token &rToken)
 Operator for writing tokens.
TokenWriteroperator<< (const std::string &rString)
 Operator for writing std::strings to a stream.
TokenWriteroperator<< (const Idx index)
 Operator for writing Idxs to a stream.

Private Attributes

Mode mMode
 Output mode.
std::ostream * mpStream
 ostream object pointer
std::ofstream mFStream
 Actual stream object, file output.
std::ostringstream mSStream
 Actual stream object, string output.
std::string mFileName
 Filename.
int mColumns
 Number of columns.
int mColCount
 Column counter.
bool mEndl
 Endl seperator on/off.

Member Enumeration Documentation

Mode of operation: write to from file, string or stdout.

Enumerator:
File 
Stdout 
String 

Definition at line 45 of file tokenwriter.h.


Constructor & Destructor Documentation

faudes::TokenWriter::TokenWriter ( Mode  mode  ) 

Console or String TokenWriter constructor.

Technical detail: the console tokenwriter holds a ref. to std::cout; it will behave strange and perhaps cause segfaults if it is instantiated befor std::cout is up; you can avoid this issue by instantiating you console tokenwriter using the new operator.

Exceptions:
Exception 

Definition at line 47 of file tokenwriter.cpp.

faudes::TokenWriter::TokenWriter ( const std::string &  rFilename,
std::ios::openmode  openmode = std::ios::out|std::ios::trunc 
)

File TokenWriter constructor.

Parameters:
rFilename File to write
openmode std::ios::openmode
Exceptions:
Exception 

Definition at line 29 of file tokenwriter.cpp.

faudes::TokenWriter::~TokenWriter ( void   ) 

Destructor.

Calls close

Definition at line 87 of file tokenwriter.cpp.


Member Function Documentation

std::string faudes::TokenWriter::FileName ( void   )  const

Get the filename.

Return dummy values for console or string mode.

Returns:
Filename

Definition at line 242 of file tokenwriter.cpp.

Mode faudes::TokenWriter::DestMode ( void   )  const [inline]

Get file mode.

Returns:
Mode

Definition at line 92 of file tokenwriter.h.

std::string faudes::TokenWriter::Str ( void   ) 

Retrieve output as string (if in String mode).

Exceptions:
Exception 

Definition at line 92 of file tokenwriter.cpp.

int faudes::TokenWriter::Columns ( void   )  const

Get number of columns in a line.

Returns:
# of columns in a line

Definition at line 102 of file tokenwriter.cpp.

void faudes::TokenWriter::Columns ( int  columns  ) 

Set number of columns in a line.

Parameters:
columns # of columns in a line

Definition at line 107 of file tokenwriter.cpp.

void faudes::TokenWriter::Endl ( void   ) 

Write endl separator.

Exceptions:
Exception 

Definition at line 112 of file tokenwriter.cpp.

void faudes::TokenWriter::Endl ( bool  on  ) 

Turn endl separator on/off.

Definition at line 125 of file tokenwriter.cpp.

void faudes::TokenWriter::Write ( Token rToken  ) 

Write next token.

Parameters:
rToken Token to write
Exceptions:
Exception 

Definition at line 131 of file tokenwriter.cpp.

void faudes::TokenWriter::WriteString ( const std::string &  rString  ) 

Write string (may not contain any quotes.

Parameters:
rString String to write
Exceptions:
Exception 

Definition at line 159 of file tokenwriter.cpp.

void faudes::TokenWriter::WriteInteger ( Idx  index  ) 

Write non negative integer.

Parameters:
index Integer to write
Exceptions:
Exception 

Definition at line 172 of file tokenwriter.cpp.

void faudes::TokenWriter::WriteFloat ( const double &  val  ) 

Write float.

Parameters:
val float to write
Exceptions:
Exception 

Definition at line 186 of file tokenwriter.cpp.

void faudes::TokenWriter::WriteInteger16 ( long int  val  ) 

Write integer as hex.

Parameters:
val Integer to write
Exceptions:
Exception 

Definition at line 179 of file tokenwriter.cpp.

void faudes::TokenWriter::WriteOption ( const std::string &  rOpt  ) 

Write option (may not contain any "+").

Parameters:
rOpt option to write
Exceptions:
Exception 

Definition at line 194 of file tokenwriter.cpp.

void faudes::TokenWriter::WriteBegin ( const std::string &  rLabel  ) 

Write begin label.

Parameters:
rLabel End label, e.g. "Alphabet"
Exceptions:
Exception 

Definition at line 202 of file tokenwriter.cpp.

void faudes::TokenWriter::WriteEnd ( const std::string &  rLabel  ) 

Write end label.

Parameters:
rLabel End label, e.g. "Alphabet"
Exceptions:
Exception 

Definition at line 209 of file tokenwriter.cpp.

void faudes::TokenWriter::WriteComment ( const std::string &  rComment  ) 

Write comment.

Parameters:
rComment Comment to write
Exceptions:
Exception 

Definition at line 216 of file tokenwriter.cpp.

void faudes::TokenWriter::WriteBinary ( const char *  pData,
long int  len 
)

Write comment.

Parameters:
len Number of bytes to write
pData Data to write
Exceptions:
Exception 

Definition at line 237 of file tokenwriter.cpp.

TokenWriter& faudes::TokenWriter::operator<< ( Token rToken  )  [inline]

Operator for writing tokens.

Parameters:
rToken Token to write
Returns:
Reference to this TokenWriter
Exceptions:
Exception 

Definition at line 244 of file tokenwriter.h.

TokenWriter& faudes::TokenWriter::operator<< ( const std::string &  rString  )  [inline]

Operator for writing std::strings to a stream.

Parameters:
rString String to write
Returns:
Reference to this TokenWriter
Exceptions:
Exception 

Definition at line 259 of file tokenwriter.h.

TokenWriter& faudes::TokenWriter::operator<< ( const Idx  index  )  [inline]

Operator for writing Idxs to a stream.

Parameters:
index Index to write
Returns:
Reference to this TokenWriter
Exceptions:
Exception 

Definition at line 274 of file tokenwriter.h.


Member Data Documentation

Output mode.

Definition at line 282 of file tokenwriter.h.

std::ostream* faudes::TokenWriter::mpStream [private]

ostream object pointer

Definition at line 285 of file tokenwriter.h.

std::ofstream faudes::TokenWriter::mFStream [private]

Actual stream object, file output.

Definition at line 288 of file tokenwriter.h.

std::ostringstream faudes::TokenWriter::mSStream [private]

Actual stream object, string output.

Definition at line 291 of file tokenwriter.h.

std::string faudes::TokenWriter::mFileName [private]

Filename.

Definition at line 294 of file tokenwriter.h.

Number of columns.

Definition at line 297 of file tokenwriter.h.

Column counter.

Definition at line 300 of file tokenwriter.h.

Endl seperator on/off.

Definition at line 303 of file tokenwriter.h.


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

libFAUDES 2.14g --- 2009-12-3 --- c++ source docu by doxygen 1.5.6