#include <msp/core/maputils.h>
#include "binarywriter.h"
#include "binfloat.h"
+#include "output.h"
#include "statement.h"
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)
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)
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)
else
{
write_int(s.size());
- out.write(s.data(), s.size());
+ out.write(s);
}
}