#include <tokenwriter.h>
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 (obmitted in String mode). | |
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. | |
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 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. |
|
Mode of operation: write to from file, string or stdout.
Definition at line 45 of file tokenwriter.h. |
|
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.
Definition at line 46 of file tokenwriter.cpp. |
|
File TokenWriter constructor.
Definition at line 29 of file tokenwriter.cpp. |
|
Destructor. Calls close Definition at line 84 of file tokenwriter.cpp. |
|
Set number of columns in a line.
Definition at line 104 of file tokenwriter.cpp. |
|
Get number of columns in a line.
Definition at line 99 of file tokenwriter.cpp. |
|
Get file mode.
Definition at line 92 of file tokenwriter.h. |
|
Write endl separator (obmitted in String mode).
Definition at line 109 of file tokenwriter.cpp. |
|
Get the filename. Return dummy values for console or string mode.
Definition at line 230 of file tokenwriter.cpp. |
|
Operator for writing Idxs to a stream.
Definition at line 256 of file tokenwriter.h. |
|
Operator for writing std::strings to a stream.
Definition at line 241 of file tokenwriter.h. |
|
Operator for writing tokens.
Definition at line 226 of file tokenwriter.h. |
|
Retrieve output as string (if in String mode).
Definition at line 89 of file tokenwriter.cpp. |
|
Write next token.
Definition at line 123 of file tokenwriter.cpp. |
|
Write begin label.
Definition at line 194 of file tokenwriter.cpp. |
|
Write comment.
Definition at line 208 of file tokenwriter.cpp. |
|
Write end label.
Definition at line 201 of file tokenwriter.cpp. |
|
Write float.
Definition at line 178 of file tokenwriter.cpp. |
|
Write non negative integer.
Definition at line 164 of file tokenwriter.cpp. |
|
Write integer as hex.
Definition at line 171 of file tokenwriter.cpp. |
|
Write option (may not contain any "+").
Definition at line 186 of file tokenwriter.cpp. |
|
Write string (may not contain any quotes.
Definition at line 151 of file tokenwriter.cpp. |
|
Column counter.
Definition at line 282 of file tokenwriter.h. |
|
Number of columns.
Definition at line 279 of file tokenwriter.h. |
|
Filename.
Definition at line 276 of file tokenwriter.h. |
|
actual stream object, file output
Definition at line 270 of file tokenwriter.h. |
|
output mode
Definition at line 264 of file tokenwriter.h. |
|
ostream object pointer
Definition at line 267 of file tokenwriter.h. |
|
actual stream object, string output
Definition at line 273 of file tokenwriter.h. |