X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fargumentstore.cpp;h=532d66aaa230e49a63209be828de19ab3b5ed5aa;hb=HEAD;hp=49bdbada1b2c5fa49bdb4b9e4158b9c901c8dc13;hpb=3b78eeb8b92dc3524d6a0456b4daf0a0f3dbf813;p=libs%2Fdatafile.git diff --git a/source/argumentstore.cpp b/source/argumentstore.cpp index 49bdbad..22cb11f 100644 --- a/source/argumentstore.cpp +++ b/source/argumentstore.cpp @@ -1,5 +1,8 @@ +#include #include "argumentstore.h" +using namespace std; + namespace Msp { namespace DataFile { @@ -19,7 +22,30 @@ ArgumentStore::ArgumentStore(const StatementInfo &n): } } +ArgumentStore::ArgumentStore(const ArgumentStore &other): + info(other.info), + store(new char[info.args_size]) +{ + copy_from(other.store); +} + +ArgumentStore &ArgumentStore::operator=(const ArgumentStore &other) +{ + if(&other.info!=&info) + throw invalid_argument("ArgumentStore::operator="); + + destroy(); + copy_from(other.store); + + return *this; +} + ArgumentStore::~ArgumentStore() +{ + destroy(); +} + +void ArgumentStore::destroy() { for(unsigned i=0; i(store+info.arg_offsets[i])->~Symbol(); break; } + + delete[] store; +} + +void ArgumentStore::copy_from(const char *other) +{ + for(unsigned i=0; i(other+info.arg_offsets[i])); + break; + case SymbolType::signature: + new(store+info.arg_offsets[i]) SymbolType::Store(*reinterpret_cast(other+info.arg_offsets[i])); + break; + default: + copy(other+info.arg_offsets[i], other+(i+1