+#include <stdexcept>
#include "argumentstore.h"
+using namespace std;
+
namespace Msp {
namespace DataFile {
}
}
+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<info.key.signature.size(); ++i)
switch(info.key.signature[i])
delete[] store;
}
+void ArgumentStore::copy_from(const char *other)
+{
+ for(unsigned i=0; i<info.key.signature.size(); ++i)
+ switch(info.key.signature[i])
+ {
+ case StringType::signature:
+ new(store+info.arg_offsets[i]) StringType::Store(*reinterpret_cast<const StringType::Store *>(other+info.arg_offsets[i]));
+ break;
+ case SymbolType::signature:
+ new(store+info.arg_offsets[i]) SymbolType::Store(*reinterpret_cast<const SymbolType::Store *>(other+info.arg_offsets[i]));
+ break;
+ default:
+ 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]);
+ break;
+ }
+}
+
} // namespace DataFile
} // namespace Msp