]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/binarywriter.cpp
Don't use deprecated typedefs
[libs/datafile.git] / source / binarywriter.cpp
index ffdc040f115565bbb18239ee9f2c14a137507fde..0fbf8ce503058f5aaa89734250856777e083409e 100644 (file)
@@ -2,6 +2,7 @@
 #include <msp/core/maputils.h>
 #include "binarywriter.h"
 #include "binfloat.h"
+#include "output.h"
 #include "statement.h"
 
 using namespace std;
@@ -9,15 +10,15 @@ using namespace std;
 namespace Msp {
 namespace DataFile {
 
-BinaryWriter::BinaryWriter(IO::Base &o):
+BinaryWriter::BinaryWriter(Output &o):
        WriterMode(o),
        next_kwd_id(1),
        next_str_id(1),
        float_precision(32)
 {
-       dict[DictEntry("__kwd", "iss")] = -1;
-       dict[DictEntry("__str", "is")] = -2;
-       dict[DictEntry("__flt", "i")] = -3;
+       dict[StatementKey("__kwd", "iss")] = -1;
+       dict[StatementKey("__str", "is")] = -2;
+       dict[StatementKey("__flt", "i")] = -3;
 }
 
 void BinaryWriter::set_float_precision(unsigned fp)
@@ -39,7 +40,7 @@ void BinaryWriter::write(const Statement &st)
 
 void BinaryWriter::write_(const Statement &st)
 {
-       int id = get_item(dict, DictEntry(st.keyword, st.get_signature()));
+       int id = get_item(dict, StatementKey(st.keyword, st.get_signature()));
 
        write_int(id);
        for(Statement::Arguments::const_iterator j = st.args.begin(); j!=st.args.end(); ++j)
@@ -59,21 +60,21 @@ void BinaryWriter::write_(const Statement &st)
 
 void BinaryWriter::collect_keywords(const Statement &st)
 {
-       DictEntry de(st.keyword, st.get_signature());
+       StatementKey key(st.keyword, st.get_signature());
 
-       if(!dict.count(de))
+       if(!dict.count(key))
        {
                Statement kst;
                kst.keyword = "__kwd";
                kst.args.push_back(next_kwd_id);
-               kst.args.push_back(de.keyword);
-               kst.args.push_back(de.args);
+               kst.args.push_back(key.keyword);
+               kst.args.push_back(key.signature);
                write_(kst);
 
-               dict[de] = next_kwd_id++;
+               dict[key] = next_kwd_id++;
        }
 
-       for(ValueArray::const_iterator i = st.args.begin(); i!=st.args.end(); ++i)
+       for(vector<Value>::const_iterator i = st.args.begin(); i!=st.args.end(); ++i)
        {
                char sig = i->get_signature();
                string str;
@@ -125,7 +126,7 @@ void BinaryWriter::write_string(const StringType::Store &s)
        else
        {
                write_int(s.size());
-               out.write(s.data(), s.size());
+               out.write(s);
        }
 }