]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/statement.cpp
More efficient way of loading binary files
[libs/datafile.git] / source / statement.cpp
index 29961a963fcfa97ce6d8461c0a384a64ce465bcd..3b6f7165b0ef1fa50874c255b12cd987c2563b22 100644 (file)
@@ -1,5 +1,6 @@
 #include <msp/strings/format.h>
 #include "statement.h"
+#include "type.h"
 
 using namespace std;
 
@@ -33,5 +34,38 @@ string Statement::get_signature() const
        return result;
 }
 
+
+StatementInfo::StatementInfo():
+       args_size(0)
+{ }
+
+StatementInfo::StatementInfo(const string &k, const string &s):
+       key(k, s),
+       args_size(0)
+{
+       for(string::const_iterator i=key.signature.begin(); i!=key.signature.end(); ++i)
+       {
+               arg_offsets.push_back(args_size);
+               switch(*i)
+               {
+               case IntType::signature:
+                       args_size += sizeof(IntType::Store);
+                       break;
+               case FloatType::signature:
+                       args_size += sizeof(FloatType::Store);
+                       break;
+               case BoolType::signature:
+                       args_size += sizeof(BoolType::Store);
+                       break;
+               case StringType::signature:
+                       args_size += sizeof(StringType::Store);
+                       break;
+               case SymbolType::signature:
+                       args_size += sizeof(SymbolType::Store);
+                       break;
+               }
+       }
+}
+
 } // namespace DataFile
 } // namespace Msp