]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/writer.h
Cosmetic changes
[libs/datafile.git] / source / writer.h
index 756e19a22c41668cea43fb5387944b90b84a4721..5f32786f443b443f15c33d996ed070d10fb0461d 100644 (file)
@@ -1,34 +1,53 @@
-/* $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 <map>
-#include <ostream>
-#include "binarydict.h"
+#include <msp/core/noncopyable.h>
+#include <msp/io/base.h>
+#include "output.h"
 
 namespace Msp {
 namespace DataFile {
 
-class Statement;
+struct Statement;
 class WriterMode;
 
-class Writer
+/**
+Frontend for writing data.
+*/
+class Writer: private NonCopyable
 {
 private:
-       std::ostream &out;
-       WriterMode *mode;
-       bool binary;
+       Output out;
+       WriterMode *mode = nullptr;
+       bool binary = false;
 
 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);
+
+       /** Enables output compression.  Once enabled, it won't be possible to
+       disable compression. */
+       void set_compressed();
+
+       /** 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