G3D::TextOutput Class ReferenceConvenient formatting of ASCII text written to a file.
More...
#include <TextOutput.h>
List of all members.
Detailed Description
Convenient formatting of ASCII text written to a file.
The core writeString, writeNumber, and writeSymbol methods map to TextInput's methods. Number and Symbol each print an additional space that is used to separate adjacent tokens.
TextOutput::printf allows arbitrary text to be conveniently dumped en-masse. Use [de]serialize(bool, TextOutput) and other overloads to read/write primitive types in a standardized manner and
When a word-wrap line break occurs, all whitespace between words is replaced with a single newline (the newline may be two characters-- see G3D::TextOutput::Options::NewlineStyle). Word wrapping occurs against the number of columns specified by Options::numColumns, minus the current indent level.
Indenting adds the specified number of spaces immediately after a newline. If a newline was followed by spaces in the original string, these are added to the indent spaces. Indenting will indent blank lines and will leave indents after the last newline of a file (if the indent level is non-zero at the end).
Serialization/Marshalling
Text serialization is accomplished using TextOutput by defining the pair of methods:
void serialize(TextOutput& to) const;
void deserialize(TextInput& ti);
See also G3D::TextInput.
BETA API
This API is subject to change in future versions.
Constructor & Destructor Documentation
| G3D::TextOutput::TextOutput |
( |
const std::string & |
filename, |
|
|
const Settings & |
options = Settings() | |
|
) |
| | [explicit] |
| G3D::TextOutput::TextOutput |
( |
const Settings & |
options = Settings() |
) |
[explicit] |
Constructs a text output that can later be commited to a string instead of a file.
Member Function Documentation
| void G3D::TextOutput::commit |
( |
bool |
flush = true |
) |
|
Commit to the filename specified on the constructor.
Not called from the destructor; you must call it yourself. - Parameters:
-
| flush | If true (default) the file is ready for reading when the method returns, otherwise the method returns immediately and writes the file in the background. |
| std::string G3D::TextOutput::commitString |
( |
|
) |
|
Produces a new string that contains the output.
| void G3D::TextOutput::commitString |
( |
std::string & |
string |
) |
|
| void G3D::TextOutput::popIndent |
( |
|
) |
|
| void __cdecl G3D::TextOutput::printf |
( |
const std::string |
fmt, |
|
|
|
... | |
|
) |
| | |
| void __cdecl G3D::TextOutput::printf |
( |
const char * |
fmt, |
|
|
|
... | |
|
) |
| | |
Normal printf conventions.
Note that the output will be reformatted for word-wrapping and newlines
| void G3D::TextOutput::pushIndent |
( |
|
) |
|
Increase indent level by 1.
| void __cdecl G3D::TextOutput::vprintf |
( |
const char * |
fmt, |
|
|
va_list |
argPtr | |
|
) |
| | |
| void G3D::TextOutput::writeBoolean |
( |
bool |
b |
) |
|
| void G3D::TextOutput::writeNewline |
( |
|
) |
|
| void G3D::TextOutput::writeNewlines |
( |
int |
numLines |
) |
|
| void G3D::TextOutput::writeNumber |
( |
int |
n |
) |
|
| void G3D::TextOutput::writeNumber |
( |
double |
n |
) |
|
| void G3D::TextOutput::writeString |
( |
const std::string & |
string |
) |
|
Writes a quoted string.
Special characters in the string (e.g., \, ,
) are escaped so that TextInput will produce the identical string on reading.
| void G3D::TextOutput::writeSymbol |
( |
const std::string & |
string |
) |
|
The symbol is written without quotes.
Symbols are required to begin with a letter or underscore and contain only letters, underscores, and numbers or be a C++ symbol (e.g. "{", "(", "++", etc.) so that they may be properly parsed by TextInput::readSymbol. Symbols are printed with a trailing space.
| void G3D::TextOutput::writeSymbols |
( |
const std::string & |
a, |
|
|
const std::string & |
b = "", |
|
|
const std::string & |
c = "", |
|
|
const std::string & |
d = "", |
|
|
const std::string & |
e = "", |
|
|
const std::string & |
f = "" | |
|
) |
| | |
Convenient idiom for writing multiple symbols in a row, e.g.
writeSymbols("name", "="); The empty symbols are not written.
The documentation for this class was generated from the following file:
Generated on Thu Aug 2 11:40:48 2007 for G3D by
1.5.2
Hosted by
|