diff --git a/core/AmArg.cpp b/core/AmArg.cpp index 529982af..94b5e10d 100644 --- a/core/AmArg.cpp +++ b/core/AmArg.cpp @@ -46,6 +46,21 @@ const char* AmArg::t2str(int type) { } } +AmArg::AmArg(const AmArg& v) + : type(v.type) { + switch (type) { + case Array: + value = new ValueArray(*std::get(v.value)); + break; + case Struct: + value = new ValueStruct(*std::get(v.value)); + break; + default: + value = v.value; + break; + } +} + AmArg::AmArg(std::map& v) : type(Undef) { assertStruct(); @@ -233,6 +248,23 @@ AmArg& AmArg::get(size_t idx) const { return (*std::get(value))[idx]; } +AmArg& AmArg::operator=(const AmArg& v) { + invalidate(); + type = v.type; + switch (type) { + case Array: + value = new ValueArray(*std::get(v.value)); + break; + case Struct: + value = new ValueStruct(*std::get(v.value)); + break; + default: + value = v.value; + break; + } + return *this; +} + AmArg& AmArg::operator[](size_t idx) { assertArray(idx+1); return (*std::get(value))[idx]; diff --git a/core/AmArg.h b/core/AmArg.h index 6542eff1..ca94d940 100644 --- a/core/AmArg.h +++ b/core/AmArg.h @@ -128,7 +128,7 @@ class AmArg : type(Undef) { } - AmArg(const AmArg& v) = default; + AmArg(const AmArg& v); AmArg(const int& v) : type(Int), @@ -197,7 +197,7 @@ class AmArg short getType() const { return type; } - AmArg& operator=(const AmArg& rhs) = default; + AmArg& operator=(const AmArg& rhs); #define isArgUndef(a) (AmArg::Undef == a.getType()) #define isArgArray(a) (AmArg::Array == a.getType())