1
This commit is contained in:
parent
9c890ba78e
commit
6364d325fa
@ -11,19 +11,27 @@ namespace a8
|
||||
a8::MutableXObject* MutableXObject::NewObject()
|
||||
{
|
||||
a8::MutableXObject* obj = new a8::MutableXObject();
|
||||
obj->type_ = XOT_OBJECT;
|
||||
obj->value_.object_value = new std::map<std::string, std::shared_ptr<a8::XObject>>();
|
||||
obj->ConvertObject();
|
||||
return obj;
|
||||
}
|
||||
|
||||
a8::MutableXObject* MutableXObject::NewArray()
|
||||
{
|
||||
a8::MutableXObject* obj = new a8::MutableXObject();
|
||||
obj->type_ = XOT_ARRAY;
|
||||
obj->value_.array_value = new std::vector<std::shared_ptr<a8::XObject>>();
|
||||
obj->ConvertArray();
|
||||
return obj;
|
||||
}
|
||||
|
||||
std::shared_ptr<a8::MutableXObject> MutableXObject::CreateObject()
|
||||
{
|
||||
return std::shared_ptr<a8::MutableXObject>(NewObject());
|
||||
}
|
||||
|
||||
std::shared_ptr<a8::MutableXObject> MutableXObject::CreateArray()
|
||||
{
|
||||
return std::shared_ptr<a8::MutableXObject>(NewArray());
|
||||
}
|
||||
|
||||
a8::MutableXObject& MutableXObject::Push(a8::XValue val)
|
||||
{
|
||||
if (type_ != XOT_ARRAY) {
|
||||
|
@ -6,7 +6,7 @@ namespace a8
|
||||
|
||||
class MutableXObject : public XObject
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
MutableXObject();
|
||||
|
||||
public:
|
||||
@ -14,6 +14,9 @@ namespace a8
|
||||
static a8::MutableXObject* NewObject();
|
||||
static a8::MutableXObject* NewArray();
|
||||
|
||||
static std::shared_ptr<a8::MutableXObject> CreateObject();
|
||||
static std::shared_ptr<a8::MutableXObject> CreateArray();
|
||||
|
||||
a8::MutableXObject& Push(a8::XValue val);
|
||||
a8::MutableXObject& Push(a8::MutableXObject& val);
|
||||
a8::MutableXObject& SetVal(const std::string& key, a8::XValue val);
|
||||
|
@ -571,4 +571,16 @@ namespace a8
|
||||
|
||||
}
|
||||
|
||||
void XObject::ConvertObject()
|
||||
{
|
||||
type_ = XOT_OBJECT;
|
||||
value_.object_value = new std::map<std::string, std::shared_ptr<a8::XObject>>();
|
||||
}
|
||||
|
||||
void XObject::ConvertArray()
|
||||
{
|
||||
type_ = XOT_ARRAY;
|
||||
value_.array_value = new std::vector<std::shared_ptr<a8::XObject>>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,6 +58,10 @@ namespace a8
|
||||
void JsonValueToXObject(Json::Value& json_val, a8::XObject& xobject);
|
||||
void XmlElementToXObject(tinyxml2::XMLElement* xml_ele, a8::XObject& xobject);
|
||||
|
||||
protected:
|
||||
void ConvertObject();
|
||||
void ConvertArray();
|
||||
|
||||
protected:
|
||||
unsigned char type_ = a8::XOT_SIMPLE;
|
||||
union {
|
||||
|
Loading…
x
Reference in New Issue
Block a user