|
|
@ -189,6 +189,7 @@ private: |
|
|
|
const int8_t* Blob(size_t* size) const override {*size=sizeof(T); return reinterpret_cast<const int8_t*>(&val);} |
|
|
|
const int8_t* Blob(size_t* size) const override {*size=sizeof(T); return reinterpret_cast<const int8_t*>(&val);} |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
|
|
|
|
ObjectSimple() = delete; |
|
|
|
ObjectSimple(T t):val(t) {} |
|
|
|
ObjectSimple(T t):val(t) {} |
|
|
|
ObjectSimple(const T* t):val(*t) {} |
|
|
|
ObjectSimple(const T* t):val(*t) {} |
|
|
|
~ObjectSimple() {} |
|
|
|
~ObjectSimple() {} |
|
|
@ -215,7 +216,6 @@ public: |
|
|
|
|
|
|
|
|
|
|
|
// Own functions
|
|
|
|
// Own functions
|
|
|
|
T Value() const {return val;} |
|
|
|
T Value() const {return val;} |
|
|
|
void SetValue(T s) {val=s;} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Simple objects
|
|
|
|
// Simple objects
|
|
|
@ -238,21 +238,15 @@ private: |
|
|
|
std::string name; |
|
|
|
std::string name; |
|
|
|
std::shared_ptr<const ObjectBase> val; |
|
|
|
std::shared_ptr<const ObjectBase> val; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObjectPair(const ObjectPair* p):name(p->name),val(p->val) {} |
|
|
|
public: |
|
|
|
public: |
|
|
|
ObjectPair() {} |
|
|
|
ObjectPair() = delete; |
|
|
|
ObjectPair(const std::string& n, const ObjectBase* v):name(n) {val.reset(v);} |
|
|
|
ObjectPair(const std::string& n, const ObjectBase* v):name(n),val(v) {} |
|
|
|
ObjectPair(const std::string* n, const ObjectBase* v):name(*n) {val.reset(v);} |
|
|
|
ObjectPair(const std::string* n, const ObjectBase* v):name(*n),val(v) {} |
|
|
|
~ObjectPair() {} |
|
|
|
|
|
|
|
// Pure virtual overrides
|
|
|
|
// Pure virtual overrides
|
|
|
|
const ObjectBase* Copy() const override |
|
|
|
const ObjectBase* Copy() const override {return new ObjectPair(this);} |
|
|
|
{ |
|
|
|
|
|
|
|
auto ret=new ObjectPair; |
|
|
|
|
|
|
|
ret->name=name; ret->val=val; |
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
bool Print() const override |
|
|
|
bool Print() const override |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(!Exist()) return false; |
|
|
|
|
|
|
|
COUT(NORMAL)<<std::endl<<"Object type: "<<Type()<<std::endl; |
|
|
|
COUT(NORMAL)<<std::endl<<"Object type: "<<Type()<<std::endl; |
|
|
|
COUT(NORMAL)<<"Name is: "<<Name()<<std::endl; |
|
|
|
COUT(NORMAL)<<"Name is: "<<Name()<<std::endl; |
|
|
|
COUT(NORMAL)<<"Value type: "<<val->Type()<<std::endl; |
|
|
|
COUT(NORMAL)<<"Value type: "<<val->Type()<<std::endl; |
|
|
@ -264,20 +258,18 @@ public: |
|
|
|
std::string Dump() const override { return Name()+"="+val->Dump(); } |
|
|
|
std::string Dump() const override { return Name()+"="+val->Dump(); } |
|
|
|
|
|
|
|
|
|
|
|
// Own functions
|
|
|
|
// Own functions
|
|
|
|
bool Exist() const {return nullptr!=val.get();} |
|
|
|
|
|
|
|
const ObjectBase* Get(const std::string& gname) const |
|
|
|
const ObjectBase* Get(const std::string& gname) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(gname==name) return val->Copy(); |
|
|
|
if(gname==name) return val->Copy(); |
|
|
|
else return new ObjectError("ObjectPair Get","pair has name "+name+" not "+gname); |
|
|
|
else return new ObjectError("ObjectPair Get","pair has name "+name+" not "+gname); |
|
|
|
} |
|
|
|
} |
|
|
|
// This function is same as Get but return pointer on constant object
|
|
|
|
// This function is same as Get but return pointer on non-copied object (this pointer must not be deleted)
|
|
|
|
const ObjectBase* Find(const std::string& gname) const |
|
|
|
const ObjectBase* Find(const std::string& gname) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(gname==name) return val.get(); |
|
|
|
if(gname==name) return val.get(); |
|
|
|
else return nullptr; |
|
|
|
else return nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
std::string Name() const {return name;} |
|
|
|
std::string Name() const {return name;} |
|
|
|
void SetPair(const std::string& n, const ObjectBase* v) {if(!Exist()) {name=n; val.reset(v);}} |
|
|
|
|
|
|
|
const ObjectBase* Value() const {return val.get();} |
|
|
|
const ObjectBase* Value() const {return val.get();} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -289,20 +281,14 @@ public: |
|
|
|
private: |
|
|
|
private: |
|
|
|
std::shared_ptr<ListValues> vals; |
|
|
|
std::shared_ptr<ListValues> vals; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObjectList(const ObjectList* o):vals(o->vals) {} |
|
|
|
public: |
|
|
|
public: |
|
|
|
ObjectList() {vals.reset(new ListValues, [](ListValues* p){for(auto& i: *p) delete i; delete p;});} |
|
|
|
ObjectList() {vals.reset(new ListValues, [](ListValues* p){for(auto& i: *p) delete i; delete p;});} |
|
|
|
ObjectList(const ObjectBase* o) {vals.reset(new ListValues, [](ListValues* p){for(auto& i: *p) delete i; delete p;}); PushBack(o);} |
|
|
|
ObjectList(const ObjectBase* o) {vals.reset(new ListValues, [](ListValues* p){for(auto& i: *p) delete i; delete p;}); PushBack(o);} |
|
|
|
~ObjectList() {} |
|
|
|
|
|
|
|
// Pure virtual overrides
|
|
|
|
// Pure virtual overrides
|
|
|
|
const ObjectBase* Copy() const override |
|
|
|
const ObjectBase* Copy() const override {return new ObjectList(this);} |
|
|
|
{ |
|
|
|
|
|
|
|
auto ret=new ObjectList; |
|
|
|
|
|
|
|
ret->vals=vals; |
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
bool Print() const override |
|
|
|
bool Print() const override |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(!Exist()) return false; |
|
|
|
|
|
|
|
COUT(NORMAL)<<std::endl<<"Object type: "<<Type()<<std::endl; |
|
|
|
COUT(NORMAL)<<std::endl<<"Object type: "<<Type()<<std::endl; |
|
|
|
COUT(NORMAL)<<"Number of elements: "<<Size()<<std::endl; |
|
|
|
COUT(NORMAL)<<"Number of elements: "<<Size()<<std::endl; |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -320,17 +306,16 @@ public: |
|
|
|
|
|
|
|
|
|
|
|
// Own functions
|
|
|
|
// Own functions
|
|
|
|
const ObjectBase* At(ListValues::size_type i) const {return (*vals)[i];} |
|
|
|
const ObjectBase* At(ListValues::size_type i) const {return (*vals)[i];} |
|
|
|
bool Exist() const {return 0!=vals->size();} |
|
|
|
|
|
|
|
const ObjectBase* Get(const std::string& gname) const |
|
|
|
const ObjectBase* Get(const std::string& gname) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
const ObjectBase* p=Find(gname); |
|
|
|
const ObjectBase* p=Find(gname); |
|
|
|
return (nullptr==p)?new ObjectError("ObjectList Get","name "+gname+" not found in list"):p->Copy(); |
|
|
|
return (nullptr==p)?new ObjectError("ObjectList Get","name "+gname+" not found in list"):p->Copy(); |
|
|
|
} |
|
|
|
} |
|
|
|
// This function is same as Get but return pointer on constant object
|
|
|
|
// This function is same as Get but return pointer on non-copied object (this pointer must not be deleted)
|
|
|
|
const ObjectBase* Find(const std::string& gname) const |
|
|
|
const ObjectBase* Find(const std::string& gname) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
const ObjectBase* p; |
|
|
|
const ObjectBase* p; |
|
|
|
for(auto& i: *vals) |
|
|
|
for(const auto& i: *vals) |
|
|
|
{ |
|
|
|
{ |
|
|
|
p=nullptr; |
|
|
|
p=nullptr; |
|
|
|
OBType<ObjectPair> pair(i); |
|
|
|
OBType<ObjectPair> pair(i); |
|
|
|