X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fargumentstore.h;fp=source%2Fargumentstore.h;h=c2d5d76f3dbb473c613840c7f92dd9320fa07d5b;hb=3b78eeb8b92dc3524d6a0456b4daf0a0f3dbf813;hp=0000000000000000000000000000000000000000;hpb=a82776d980239e48d2b509d33b56e77a1ea44dda;p=libs%2Fdatafile.git diff --git a/source/argumentstore.h b/source/argumentstore.h new file mode 100644 index 0000000..c2d5d76 --- /dev/null +++ b/source/argumentstore.h @@ -0,0 +1,56 @@ +#ifndef MSP_DATAFILE_ARGUMENTSTORE_H_ +#define MSP_DATAFILE_ARGUMENTSTORE_H_ + +#include "statement.h" + +namespace Msp { +namespace DataFile { + +class ArgumentStore +{ +private: + const StatementInfo &info; + char *store; + +public: + ArgumentStore(const StatementInfo &); + ~ArgumentStore(); + + const StatementInfo &get_info() const { return info; } + + template + void set(unsigned i, const T &v) + { + *reinterpret_cast::Store *>(store+info.arg_offsets[i]) = v; + } + + template + typename TypeInfo::Load get(unsigned i) const + { + return extract::Store>(store+info.arg_offsets[i], info.key.signature[i]); + } + +private: + template + T extract(const char *, char) const; +}; + +template +inline T ArgumentStore::extract(const char *p, char) const +{ + return *reinterpret_cast(p); +} + +template<> +inline FloatType::Store ArgumentStore::extract(const char *p, char s) const +{ + if(s==IntType::signature) + return *reinterpret_cast(p); + else + return *reinterpret_cast(p); +} + +} // namespace DataFile +} // namespace Msp + +#endif