]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/binarywriter.cpp
Use a common StatementKey structure for Loader and BinaryParser/Writer
[libs/datafile.git] / source / binarywriter.cpp
index d1433304c251744a7a51c702a2b80b73b3d24139..087e140ddd5d1d1f79173afac9d3cb9f7e57fb8b 100644 (file)
@@ -16,9 +16,9 @@ BinaryWriter::BinaryWriter(Output &o):
        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)
@@ -40,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)
@@ -60,18 +60,18 @@ 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)