X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbinarywriter.cpp;h=2ff96a457524c7a1e28a13c6e098de535bf0e006;hb=8d6360cbcd8fe92d97dcba5e68e3adb6f2c0c3bc;hp=09e36c0085be33c8ad7c0ff0eb5c8a611ca33a95;hpb=a582163d380833b1370ba067a1fd0ad5c2984723;p=libs%2Fdatafile.git diff --git a/source/binarywriter.cpp b/source/binarywriter.cpp index 09e36c0..2ff96a4 100644 --- a/source/binarywriter.cpp +++ b/source/binarywriter.cpp @@ -1,10 +1,4 @@ -/* $Id$ - -This file is part of libmspdatafile -Copyright © 2007-2008, 2010 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include #include "binarywriter.h" #include "statement.h" @@ -30,11 +24,9 @@ void BinaryWriter::write(const Statement &st) void BinaryWriter::write_(const Statement &st) { - Dictionary::iterator i = dict.find(DictEntry(st.keyword, st.get_signature())); - if(i==dict.end()) - throw InvalidParameterValue("Unknown statement"); + unsigned id = get_item(dict, DictEntry(st.keyword, st.get_signature())); - write_int(i->second); + write_int(id); for(Statement::Arguments::const_iterator j = st.args.begin(); j!=st.args.end(); ++j) switch(j->get_signature()) { @@ -142,10 +134,7 @@ void BinaryWriter::write_float(float f) void BinaryWriter::write_enum(const string &e) { - StringMap::const_iterator i = strings.find(e); - if(i==strings.end()) - throw InvalidParameterValue("Unknown enum"); - write_int(i->second); + write_int(get_item(strings, e)); } } // namespace DataFile