X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Fwriter.h;h=df308266d976810217be152efec93d8f2a75b77a;hp=756e19a22c41668cea43fb5387944b90b84a4721;hb=8e3fad222e174b7c659fd3d994d54314657ed989;hpb=27630d44298cb67e075c166f4421288cc8ca117e diff --git a/source/writer.h b/source/writer.h index 756e19a..df30826 100644 --- a/source/writer.h +++ b/source/writer.h @@ -1,16 +1,9 @@ -/* $Id$ - -This file is part of libmspdatafile -Copyright © 2006 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_DATAFILE_WRITER_H_ #define MSP_DATAFILE_WRITER_H_ #include -#include -#include "binarydict.h" +#include +#include "output.h" namespace Msp { namespace DataFile { @@ -18,17 +11,38 @@ namespace DataFile { class Statement; class WriterMode; +/** +Frontend for writing data. +*/ class Writer { private: - std::ostream &out; + Output out; WriterMode *mode; bool binary; public: - Writer(std::ostream &); - void write(const Statement &); - void set_binary(bool); + Writer(IO::Base &o); + ~Writer(); + + /** + Writes a statement to the output. This function always writes a complete + statement, so it's not possible to add substatements later. + */ + void write(const Statement &st); + + /** + Sets binary or text mode. While it is possible to enter and exit binary + mode multiple times, doing so produces sub-optimal output. + + @param b true for binary mode, false for text + */ + void set_binary(bool b); + + /** Sets the precision of floating point numbers in bits. Depending on the + mode not all values may be valid, but any value between 16 and 64 that is + divisible by 8 is guaranteed to work. */ + void set_float_precision(unsigned); }; } // namespace DataFile