libFAUDES
Sections
Index
|
faudes::TokenWriter Class Reference
|
Public Types | |
enum | Mode { File, XmlFile, Stdout, String, Stream, XmlStream } |
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 (const std::string &rFilename, const std::string &doctype) | |
Xml File TokenWriter constructor. | |
TokenWriter (std::ostream &rStream, const std::string &doctype="") | |
Stream TokenWriter constructor. | |
~TokenWriter (void) | |
Destructor. | |
std::string | FileName (void) const |
Get the filename. | |
void | Flush (void) |
Flush any buffers. | |
bool | FileMode (void) const |
Test for file mode (incl. | |
bool | XmlMode (void) const |
Test for xml file mode. | |
bool | StdoutMode (void) const |
Test for file mode. | |
std::string | Str (void) |
Retrieve output as string (if in String mode). | |
std::ostream * | Streamp (void) |
Access C++ stream. | |
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 (const Token &rToken) |
Write next token. | |
void | WriteString (const std::string &rString) |
Write string. | |
void | WriteText (const std::string &rText) |
Write text. | |
void | WriteText (const std::string &rLabel, const std::string &rText) |
Write text section. | |
void | WriteText (const Token &rBeginTag, const std::string &rText) |
Write text section. | |
void | WriteCharacterData (const std::string &rCharData) |
Write character data. | |
void | WriteVerbatim (const std::string &rString) |
Write string. | |
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 | WriteEmpty (const std::string &rLabel) |
Write empty section label. | |
void | WriteComment (const std::string &rComment) |
Write comment in faudes format. | |
void | WriteXmlComment (const std::string &rComment) |
Write comment in Xml format. | |
void | WriteBinary (const char *pData, long int len) |
Write comment. | |
TokenWriter & | operator<< (Token &rToken) |
Operator for writing tokens. | |
TokenWriter & | operator<< (const std::string &rString) |
Operator for writing std::strings to a stream. | |
TokenWriter & | operator<< (const Idx index) |
Operator for writing Idxs to a stream. | |
Private Member Functions | |
void | DoFlush (void) |
Flush internal buffer. | |
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::ostream * | pSStream |
Actual stream object, stream output. | |
Token | mOutBuffer |
Outputbuffer. | |
bool | mHasOutBuffer |
std::string | mFileName |
Filename. | |
int | mColumns |
Number of columns. | |
int | mColCount |
Column counter. | |
bool | mEndl |
Endl seperator on/off. | |
std::string | mDocType |
Xml doctype if in xml mode. |
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 42 of file cfl_tokenwriter.h.
Mode of operation: write to from file, string or stdout.
Definition at line 49 of file cfl_tokenwriter.h.
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.
Exception |
|
Definition at line 73 of file cfl_tokenwriter.cpp.
faudes::TokenWriter::TokenWriter | ( | const std::string & | rFilename, | |
std::ios::openmode | openmode = std::ios::out|std::ios::trunc | |||
) |
File TokenWriter constructor.
rFilename | File to write | |
openmode | std::ios::openmode |
Exception |
|
Definition at line 29 of file cfl_tokenwriter.cpp.
faudes::TokenWriter::TokenWriter | ( | const std::string & | rFilename, | |
const std::string & | doctype | |||
) |
Xml File TokenWriter constructor.
rFilename | File to write | |
doctype | String to indicate XML doctype. |
Exception |
|
Definition at line 47 of file cfl_tokenwriter.cpp.
faudes::TokenWriter::TokenWriter | ( | std::ostream & | rStream, | |
const std::string & | doctype = "" | |||
) |
Stream TokenWriter constructor.
rStream | stream C++ stream to write to | |
doctype | String to indicate XML doctype. |
Exception |
|
Definition at line 113 of file cfl_tokenwriter.cpp.
faudes::TokenWriter::~TokenWriter | ( | void | ) |
void faudes::TokenWriter::Columns | ( | int | columns | ) |
Set number of columns in a line.
columns | # of columns in a line |
Definition at line 172 of file cfl_tokenwriter.cpp.
int faudes::TokenWriter::Columns | ( | void | ) | const |
Get number of columns in a line.
Definition at line 167 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::DoFlush | ( | void | ) | [private] |
Flush internal buffer.
Definition at line 197 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::Endl | ( | bool | on | ) |
Turn endl separator on/off.
Definition at line 191 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::Endl | ( | void | ) |
Write endl separator.
Exception |
|
Definition at line 177 of file cfl_tokenwriter.cpp.
bool faudes::TokenWriter::FileMode | ( | void | ) | const [inline] |
std::string faudes::TokenWriter::FileName | ( | void | ) | const |
Get the filename.
Return dummy values for console or string mode.
Definition at line 496 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::Flush | ( | void | ) |
Flush any buffers.
Definition at line 142 of file cfl_tokenwriter.cpp.
TokenWriter& faudes::TokenWriter::operator<< | ( | const Idx | index | ) | [inline] |
Operator for writing Idxs to a stream.
index | Index to write |
Exception |
|
Definition at line 421 of file cfl_tokenwriter.h.
TokenWriter& faudes::TokenWriter::operator<< | ( | const std::string & | rString | ) | [inline] |
Operator for writing std::strings to a stream.
rString | String to write |
Exception |
|
Definition at line 406 of file cfl_tokenwriter.h.
TokenWriter& faudes::TokenWriter::operator<< | ( | Token & | rToken | ) | [inline] |
Operator for writing tokens.
rToken | Token to write |
Exception |
|
Definition at line 391 of file cfl_tokenwriter.h.
bool faudes::TokenWriter::StdoutMode | ( | void | ) | const [inline] |
std::string faudes::TokenWriter::Str | ( | void | ) |
Retrieve output as string (if in String mode).
Exception |
|
Definition at line 148 of file cfl_tokenwriter.cpp.
std::ostream * faudes::TokenWriter::Streamp | ( | void | ) |
Access C++ stream.
Definition at line 159 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::Write | ( | const Token & | rToken | ) |
Write next token.
rToken | Token to write |
Exception |
|
Definition at line 238 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteBegin | ( | const std::string & | rLabel | ) |
Write begin label.
rLabel | End label, e.g. "Alphabet" |
Exception |
|
Definition at line 396 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteBinary | ( | const char * | pData, | |
long int | len | |||
) |
Write comment.
len | Number of bytes to write | |
pData | Data to write |
Exception |
|
Definition at line 490 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteCharacterData | ( | const std::string & | rCharData | ) |
Write character data.
Writes the specified string as it is. Thus, relevant enteties must be escaped befrand.
rCharData | String to write |
Exception |
|
Definition at line 336 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteComment | ( | const std::string & | rComment | ) |
Write comment in faudes format.
rComment | Comment to write |
Exception |
|
Definition at line 417 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteEmpty | ( | const std::string & | rLabel | ) |
Write empty section label.
rLabel | End label, e.g. "Alphabet" |
Exception |
|
Definition at line 410 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteEnd | ( | const std::string & | rLabel | ) |
Write end label.
rLabel | End label, e.g. "Alphabet" |
Exception |
|
Definition at line 403 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteFloat | ( | const double & | val | ) |
Write float.
val | float to write |
Exception |
|
Definition at line 380 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteInteger | ( | Idx | index | ) |
Write non negative integer.
index | Integer to write |
Exception |
|
Definition at line 366 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteInteger16 | ( | long int | val | ) |
Write integer as hex.
val | Integer to write |
Exception |
|
Definition at line 373 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteOption | ( | const std::string & | rOpt | ) |
Write option (may not contain any "+").
rOpt | option to write |
Exception |
|
Definition at line 388 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteString | ( | const std::string & | rString | ) |
Write string.
Writes a std string token, i.e. enclosed in double quotes any quotes in the string will be escaped, controls ignored.
rString | String to write |
Exception |
|
Definition at line 280 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteText | ( | const Token & | rBeginTag, | |
const std::string & | rText | |||
) |
Write text section.
Writes the specified string eclosed in begin/end tags. Use this version to have attributes in the begin tag.
rBeginTag | Begin tag. | |
rText | String to write |
Exception |
|
Definition at line 306 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteText | ( | const std::string & | rLabel, | |
const std::string & | rText | |||
) |
Write text section.
Writes the specified string eclosed in begin/end tags.
Exception |
|
Definition at line 328 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteText | ( | const std::string & | rText | ) |
Write text.
Writes the specified string. Relevant enteties are escaped.
rText | String to write |
Exception |
|
Definition at line 293 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteVerbatim | ( | const std::string & | rString | ) |
Write string.
Writes string enclosed in verbatim markes __VERBATIM__, incl controls.
rString | String to write |
Exception |
|
Definition at line 349 of file cfl_tokenwriter.cpp.
void faudes::TokenWriter::WriteXmlComment | ( | const std::string & | rComment | ) |
Write comment in Xml format.
rComment | Comment to write |
Exception |
|
Definition at line 458 of file cfl_tokenwriter.cpp.
bool faudes::TokenWriter::XmlMode | ( | void | ) | const [inline] |
int faudes::TokenWriter::mColCount [private] |
Column counter.
Definition at line 454 of file cfl_tokenwriter.h.
int faudes::TokenWriter::mColumns [private] |
Number of columns.
Definition at line 451 of file cfl_tokenwriter.h.
std::string faudes::TokenWriter::mDocType [private] |
Xml doctype if in xml mode.
Definition at line 460 of file cfl_tokenwriter.h.
bool faudes::TokenWriter::mEndl [private] |
Endl seperator on/off.
Definition at line 457 of file cfl_tokenwriter.h.
std::string faudes::TokenWriter::mFileName [private] |
Filename.
Definition at line 448 of file cfl_tokenwriter.h.
std::ofstream faudes::TokenWriter::mFStream [private] |
Actual stream object, file output.
Definition at line 435 of file cfl_tokenwriter.h.
bool faudes::TokenWriter::mHasOutBuffer [private] |
Definition at line 445 of file cfl_tokenwriter.h.
Mode faudes::TokenWriter::mMode [private] |
Output mode.
Definition at line 429 of file cfl_tokenwriter.h.
Token faudes::TokenWriter::mOutBuffer [private] |
Outputbuffer.
Definition at line 444 of file cfl_tokenwriter.h.
std::ostream* faudes::TokenWriter::mpStream [private] |
ostream object pointer
Definition at line 432 of file cfl_tokenwriter.h.
std::ostringstream faudes::TokenWriter::mSStream [private] |
Actual stream object, string output.
Definition at line 438 of file cfl_tokenwriter.h.
std::ostream* faudes::TokenWriter::pSStream [private] |
Actual stream object, stream output.
Definition at line 441 of file cfl_tokenwriter.h.
libFAUDES 2.20d --- 2011.04.26 --- c++ source docu by doxygen