2 #include "argumentstore.h"
9 ArgumentStore::ArgumentStore(const StatementInfo &n):
11 store(new char[info.args_size])
13 for(unsigned i=0; i<info.key.signature.size(); ++i)
14 switch(info.key.signature[i])
16 case StringType::signature:
17 new(store+info.arg_offsets[i]) StringType::Store;
19 case SymbolType::signature:
20 new(store+info.arg_offsets[i]) SymbolType::Store;
25 ArgumentStore::ArgumentStore(const ArgumentStore &other):
27 store(new char[info.args_size])
29 copy_from(other.store);
32 ArgumentStore &ArgumentStore::operator=(const ArgumentStore &other)
34 if(&other.info!=&info)
35 throw invalid_argument("ArgumentStore::operator=");
38 copy_from(other.store);
43 ArgumentStore::~ArgumentStore()
48 void ArgumentStore::destroy()
50 for(unsigned i=0; i<info.key.signature.size(); ++i)
51 switch(info.key.signature[i])
53 case StringType::signature:
54 reinterpret_cast<StringType::Store *>(store+info.arg_offsets[i])->~basic_string();
56 case SymbolType::signature:
57 reinterpret_cast<SymbolType::Store *>(store+info.arg_offsets[i])->~Symbol();
64 void ArgumentStore::copy_from(const char *other)
66 for(unsigned i=0; i<info.key.signature.size(); ++i)
67 switch(info.key.signature[i])
69 case StringType::signature:
70 new(store+info.arg_offsets[i]) StringType::Store(*reinterpret_cast<const StringType::Store *>(other+info.arg_offsets[i]));
72 case SymbolType::signature:
73 new(store+info.arg_offsets[i]) SymbolType::Store(*reinterpret_cast<const SymbolType::Store *>(other+info.arg_offsets[i]));
76 copy(other+info.arg_offsets[i], other+(i+1<info.arg_offsets.size() ? info.arg_offsets[i+1] : info.args_size), store+info.arg_offsets[i]);
81 } // namespace DataFile