]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/writer.cpp
Use custom encoding for floats in binary format
[libs/datafile.git] / source / writer.cpp
index 0da77bc0304dc471f24a368399c86cfbcabff391..60914090f742acaa97b90f1f1f9c58fd03756523 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of libmspdatafile
-Copyright © 2006  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include "binarywriter.h"
 #include "statement.h"
 #include "textwriter.h"
@@ -21,6 +14,11 @@ Writer::Writer(IO::Base &o):
        binary(false)
 { }
 
+Writer::~Writer()
+{
+       delete mode;
+}
+
 void Writer::write(const Statement &st)
 {
        mode->write(st);
@@ -31,21 +29,26 @@ void Writer::set_binary(bool b)
        if(b==binary)
                return;
 
-       binary=b;
+       binary = b;
 
        Statement st;
        if(binary)
-               st.keyword="__bin";
+               st.keyword = "__bin";
        else
-               st.keyword="__text";
+               st.keyword = "__text";
 
        mode->write(st);
 
        delete mode;
        if(binary)
-               mode=new BinaryWriter(out);
+               mode = new BinaryWriter(out);
        else
-               mode=new TextWriter(out);
+               mode = new TextWriter(out);
+}
+
+void Writer::set_float_precision(unsigned fp)
+{
+       mode->set_float_precision(fp);
 }
 
 } // namespace DataFile