mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-11-30 10:57:34 +08:00
add vector map field
This commit is contained in:
parent
ff6f3d162b
commit
da4feafa1e
@ -125,6 +125,9 @@
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="stdafx.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="struct.stub" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
@ -36,4 +36,7 @@
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="struct.stub" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
484
app/gson/demo/gson.cpp
Normal file
484
app/gson/demo/gson.cpp
Normal file
@ -0,0 +1,484 @@
|
||||
#include "stdafx.h"
|
||||
#include "struct.h"
|
||||
#include "gson.h"
|
||||
#include "acl_cpp/serialize/gson_helper.ipp"
|
||||
namespace acl
|
||||
{
|
||||
acl::json_node& gson(acl::json &$json, const base &$obj)
|
||||
{
|
||||
acl::json_node &$node = $json.create_node();
|
||||
|
||||
if (check_nullptr($obj.string))
|
||||
$node.add_null("string");
|
||||
else
|
||||
$node.add_text("string", acl::get_value($obj.string));
|
||||
|
||||
if (check_nullptr($obj.string_ptr))
|
||||
$node.add_null("string_ptr");
|
||||
else
|
||||
$node.add_text("string_ptr", acl::get_value($obj.string_ptr));
|
||||
|
||||
if (check_nullptr($obj.a))
|
||||
$node.add_null("a");
|
||||
else
|
||||
$node.add_number("a", acl::get_value($obj.a));
|
||||
|
||||
if (check_nullptr($obj.a_ptr))
|
||||
$node.add_null("a_ptr");
|
||||
else
|
||||
$node.add_number("a_ptr", acl::get_value($obj.a_ptr));
|
||||
|
||||
if (check_nullptr($obj.b))
|
||||
$node.add_null("b");
|
||||
else
|
||||
$node.add_number("b", acl::get_value($obj.b));
|
||||
|
||||
if (check_nullptr($obj.b_ptr))
|
||||
$node.add_null("b_ptr");
|
||||
else
|
||||
$node.add_number("b_ptr", acl::get_value($obj.b_ptr));
|
||||
|
||||
if (check_nullptr($obj.c))
|
||||
$node.add_null("c");
|
||||
else
|
||||
$node.add_number("c", acl::get_value($obj.c));
|
||||
|
||||
if (check_nullptr($obj.c_ptr))
|
||||
$node.add_null("c_ptr");
|
||||
else
|
||||
$node.add_number("c_ptr", acl::get_value($obj.c_ptr));
|
||||
|
||||
if (check_nullptr($obj.d))
|
||||
$node.add_null("d");
|
||||
else
|
||||
$node.add_number("d", acl::get_value($obj.d));
|
||||
|
||||
if (check_nullptr($obj.d_ptr))
|
||||
$node.add_null("d_ptr");
|
||||
else
|
||||
$node.add_number("d_ptr", acl::get_value($obj.d_ptr));
|
||||
|
||||
if (check_nullptr($obj.e))
|
||||
$node.add_null("e");
|
||||
else
|
||||
$node.add_number("e", acl::get_value($obj.e));
|
||||
|
||||
if (check_nullptr($obj.e_ptr))
|
||||
$node.add_null("e_ptr");
|
||||
else
|
||||
$node.add_number("e_ptr", acl::get_value($obj.e_ptr));
|
||||
|
||||
if (check_nullptr($obj.f))
|
||||
$node.add_null("f");
|
||||
else
|
||||
$node.add_number("f", acl::get_value($obj.f));
|
||||
|
||||
if (check_nullptr($obj.f_ptr))
|
||||
$node.add_null("f_ptr");
|
||||
else
|
||||
$node.add_number("f_ptr", acl::get_value($obj.f_ptr));
|
||||
|
||||
if (check_nullptr($obj.g))
|
||||
$node.add_null("g");
|
||||
else
|
||||
$node.add_number("g", acl::get_value($obj.g));
|
||||
|
||||
if (check_nullptr($obj.g_ptr))
|
||||
$node.add_null("g_ptr");
|
||||
else
|
||||
$node.add_number("g_ptr", acl::get_value($obj.g_ptr));
|
||||
|
||||
if (check_nullptr($obj.acl_string))
|
||||
$node.add_null("acl_string");
|
||||
else
|
||||
$node.add_text("acl_string", acl::get_value($obj.acl_string));
|
||||
|
||||
if (check_nullptr($obj.acl_string_ptr))
|
||||
$node.add_null("acl_string_ptr");
|
||||
else
|
||||
$node.add_text("acl_string_ptr", acl::get_value($obj.acl_string_ptr));
|
||||
|
||||
if (check_nullptr($obj.h))
|
||||
$node.add_null("h");
|
||||
else
|
||||
$node.add_double("h", acl::get_value($obj.h));
|
||||
|
||||
if (check_nullptr($obj.h_ptr))
|
||||
$node.add_null("h_ptr");
|
||||
else
|
||||
$node.add_double("h_ptr", acl::get_value($obj.h_ptr));
|
||||
|
||||
if (check_nullptr($obj.i))
|
||||
$node.add_null("i");
|
||||
else
|
||||
$node.add_double("i", acl::get_value($obj.i));
|
||||
|
||||
if (check_nullptr($obj.i_ptr))
|
||||
$node.add_null("i_ptr");
|
||||
else
|
||||
$node.add_double("i_ptr", acl::get_value($obj.i_ptr));
|
||||
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
acl::json_node& gson(acl::json &$json, const base *$obj)
|
||||
{
|
||||
return gson ($json, *$obj);
|
||||
}
|
||||
|
||||
|
||||
acl::string gson(const base &$obj)
|
||||
{
|
||||
acl::json $json;
|
||||
acl::json_node &$node = acl::gson ($json, $obj);
|
||||
return $node.to_string ();
|
||||
}
|
||||
|
||||
|
||||
std::pair<bool,std::string> gson(acl::json_node &$node, base &$obj)
|
||||
{
|
||||
acl::json_node *string = $node["string"];
|
||||
acl::json_node *string_ptr = $node["string_ptr"];
|
||||
acl::json_node *a = $node["a"];
|
||||
acl::json_node *a_ptr = $node["a_ptr"];
|
||||
acl::json_node *b = $node["b"];
|
||||
acl::json_node *b_ptr = $node["b_ptr"];
|
||||
acl::json_node *c = $node["c"];
|
||||
acl::json_node *c_ptr = $node["c_ptr"];
|
||||
acl::json_node *d = $node["d"];
|
||||
acl::json_node *d_ptr = $node["d_ptr"];
|
||||
acl::json_node *e = $node["e"];
|
||||
acl::json_node *e_ptr = $node["e_ptr"];
|
||||
acl::json_node *f = $node["f"];
|
||||
acl::json_node *f_ptr = $node["f_ptr"];
|
||||
acl::json_node *g = $node["g"];
|
||||
acl::json_node *g_ptr = $node["g_ptr"];
|
||||
acl::json_node *acl_string = $node["acl_string"];
|
||||
acl::json_node *acl_string_ptr = $node["acl_string_ptr"];
|
||||
acl::json_node *h = $node["h"];
|
||||
acl::json_node *h_ptr = $node["h_ptr"];
|
||||
acl::json_node *i = $node["i"];
|
||||
acl::json_node *i_ptr = $node["i_ptr"];
|
||||
std::pair<bool, std::string> result;
|
||||
|
||||
if(!string ||!(result = gson(*string, &$obj.string), result.first))
|
||||
return std::make_pair(false, "required [base.string] failed:{"+result.second+"}");
|
||||
|
||||
if(string_ptr)
|
||||
gson(*string_ptr, &$obj.string_ptr);
|
||||
|
||||
if(!a ||!(result = gson(*a, &$obj.a), result.first))
|
||||
return std::make_pair(false, "required [base.a] failed:{"+result.second+"}");
|
||||
|
||||
if(!a_ptr ||!(result = gson(*a_ptr, &$obj.a_ptr), result.first))
|
||||
return std::make_pair(false, "required [base.a_ptr] failed:{"+result.second+"}");
|
||||
|
||||
if(!b ||!(result = gson(*b, &$obj.b), result.first))
|
||||
return std::make_pair(false, "required [base.b] failed:{"+result.second+"}");
|
||||
|
||||
if(!b_ptr ||!(result = gson(*b_ptr, &$obj.b_ptr), result.first))
|
||||
return std::make_pair(false, "required [base.b_ptr] failed:{"+result.second+"}");
|
||||
|
||||
if(!c ||!(result = gson(*c, &$obj.c), result.first))
|
||||
return std::make_pair(false, "required [base.c] failed:{"+result.second+"}");
|
||||
|
||||
if(!c_ptr ||!(result = gson(*c_ptr, &$obj.c_ptr), result.first))
|
||||
return std::make_pair(false, "required [base.c_ptr] failed:{"+result.second+"}");
|
||||
|
||||
if(!d ||!(result = gson(*d, &$obj.d), result.first))
|
||||
return std::make_pair(false, "required [base.d] failed:{"+result.second+"}");
|
||||
|
||||
if(!d_ptr ||!(result = gson(*d_ptr, &$obj.d_ptr), result.first))
|
||||
return std::make_pair(false, "required [base.d_ptr] failed:{"+result.second+"}");
|
||||
|
||||
if(!e ||!(result = gson(*e, &$obj.e), result.first))
|
||||
return std::make_pair(false, "required [base.e] failed:{"+result.second+"}");
|
||||
|
||||
if(!e_ptr ||!(result = gson(*e_ptr, &$obj.e_ptr), result.first))
|
||||
return std::make_pair(false, "required [base.e_ptr] failed:{"+result.second+"}");
|
||||
|
||||
if(!f ||!(result = gson(*f, &$obj.f), result.first))
|
||||
return std::make_pair(false, "required [base.f] failed:{"+result.second+"}");
|
||||
|
||||
if(!f_ptr ||!(result = gson(*f_ptr, &$obj.f_ptr), result.first))
|
||||
return std::make_pair(false, "required [base.f_ptr] failed:{"+result.second+"}");
|
||||
|
||||
if(!g ||!(result = gson(*g, &$obj.g), result.first))
|
||||
return std::make_pair(false, "required [base.g] failed:{"+result.second+"}");
|
||||
|
||||
if(!g_ptr ||!(result = gson(*g_ptr, &$obj.g_ptr), result.first))
|
||||
return std::make_pair(false, "required [base.g_ptr] failed:{"+result.second+"}");
|
||||
|
||||
if(!acl_string ||!(result = gson(*acl_string, &$obj.acl_string), result.first))
|
||||
return std::make_pair(false, "required [base.acl_string] failed:{"+result.second+"}");
|
||||
|
||||
if(!acl_string_ptr ||!(result = gson(*acl_string_ptr, &$obj.acl_string_ptr), result.first))
|
||||
return std::make_pair(false, "required [base.acl_string_ptr] failed:{"+result.second+"}");
|
||||
|
||||
if(!h ||!(result = gson(*h, &$obj.h), result.first))
|
||||
return std::make_pair(false, "required [base.h] failed:{"+result.second+"}");
|
||||
|
||||
if(!h_ptr ||!(result = gson(*h_ptr, &$obj.h_ptr), result.first))
|
||||
return std::make_pair(false, "required [base.h_ptr] failed:{"+result.second+"}");
|
||||
|
||||
if(!i ||!(result = gson(*i, &$obj.i), result.first))
|
||||
return std::make_pair(false, "required [base.i] failed:{"+result.second+"}");
|
||||
|
||||
if(!i_ptr ||!(result = gson(*i_ptr, &$obj.i_ptr), result.first))
|
||||
return std::make_pair(false, "required [base.i_ptr] failed:{"+result.second+"}");
|
||||
|
||||
return std::make_pair(true,"");
|
||||
}
|
||||
|
||||
|
||||
std::pair<bool,std::string> gson(acl::json_node &$node, base *$obj)
|
||||
{
|
||||
return gson($node, *$obj);
|
||||
}
|
||||
|
||||
|
||||
acl::json_node& gson(acl::json &$json, const hello::world &$obj)
|
||||
{
|
||||
acl::json_node &$node = $json.create_node();
|
||||
|
||||
if (check_nullptr($obj.b))
|
||||
$node.add_null("b");
|
||||
else
|
||||
$node.add_child("b", acl::gson($json, $obj.b));
|
||||
|
||||
if (check_nullptr($obj.b_ptr))
|
||||
$node.add_null("b_ptr");
|
||||
else
|
||||
$node.add_child("b_ptr", acl::gson($json, $obj.b_ptr));
|
||||
|
||||
if (check_nullptr($obj.bases_list))
|
||||
$node.add_null("bases_list");
|
||||
else
|
||||
$node.add_child("bases_list", acl::gson($json, $obj.bases_list));
|
||||
|
||||
if (check_nullptr($obj.bases_list_ptr))
|
||||
$node.add_null("bases_list_ptr");
|
||||
else
|
||||
$node.add_child("bases_list_ptr", acl::gson($json, $obj.bases_list_ptr));
|
||||
|
||||
if (check_nullptr($obj.bases_ptr_list_ptr))
|
||||
$node.add_null("bases_ptr_list_ptr");
|
||||
else
|
||||
$node.add_child("bases_ptr_list_ptr", acl::gson($json, $obj.bases_ptr_list_ptr));
|
||||
|
||||
if (check_nullptr($obj.base_map))
|
||||
$node.add_null("base_map");
|
||||
else
|
||||
$node.add_child("base_map", acl::gson($json, $obj.base_map));
|
||||
|
||||
if (check_nullptr($obj.base_list_map))
|
||||
$node.add_null("base_list_map");
|
||||
else
|
||||
$node.add_child("base_list_map", acl::gson($json, $obj.base_list_map));
|
||||
|
||||
if (check_nullptr($obj.vector_string))
|
||||
$node.add_null("vector_string");
|
||||
else
|
||||
$node.add_child("vector_string", acl::gson($json, $obj.vector_string));
|
||||
|
||||
if (check_nullptr($obj.vector_list_base))
|
||||
$node.add_null("vector_list_base");
|
||||
else
|
||||
$node.add_child("vector_list_base", acl::gson($json, $obj.vector_list_base));
|
||||
|
||||
if (check_nullptr($obj.me))
|
||||
$node.add_null("me");
|
||||
else
|
||||
$node.add_number("me", acl::get_value($obj.me));
|
||||
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
acl::json_node& gson(acl::json &$json, const hello::world *$obj)
|
||||
{
|
||||
return gson ($json, *$obj);
|
||||
}
|
||||
|
||||
|
||||
acl::string gson(const hello::world &$obj)
|
||||
{
|
||||
acl::json $json;
|
||||
acl::json_node &$node = acl::gson ($json, $obj);
|
||||
return $node.to_string ();
|
||||
}
|
||||
|
||||
|
||||
std::pair<bool,std::string> gson(acl::json_node &$node, hello::world &$obj)
|
||||
{
|
||||
acl::json_node *b = $node["b"];
|
||||
acl::json_node *b_ptr = $node["b_ptr"];
|
||||
acl::json_node *bases_list = $node["bases_list"];
|
||||
acl::json_node *bases_list_ptr = $node["bases_list_ptr"];
|
||||
acl::json_node *bases_ptr_list_ptr = $node["bases_ptr_list_ptr"];
|
||||
acl::json_node *base_map = $node["base_map"];
|
||||
acl::json_node *base_list_map = $node["base_list_map"];
|
||||
acl::json_node *vector_string = $node["vector_string"];
|
||||
acl::json_node *vector_list_base = $node["vector_list_base"];
|
||||
acl::json_node *me = $node["me"];
|
||||
std::pair<bool, std::string> result;
|
||||
|
||||
if(!b ||!b->get_obj()||!(result = gson(*b->get_obj(), &$obj.b), result.first))
|
||||
return std::make_pair(false, "required [hello::world.b] failed:{"+result.second+"}");
|
||||
|
||||
if(!b_ptr ||!b_ptr->get_obj()||!(result = gson(*b_ptr->get_obj(), &$obj.b_ptr), result.first))
|
||||
return std::make_pair(false, "required [hello::world.b_ptr] failed:{"+result.second+"}");
|
||||
|
||||
if(!bases_list ||!bases_list->get_obj()||!(result = gson(*bases_list->get_obj(), &$obj.bases_list), result.first))
|
||||
return std::make_pair(false, "required [hello::world.bases_list] failed:{"+result.second+"}");
|
||||
|
||||
if(!bases_list_ptr ||!bases_list_ptr->get_obj()||!(result = gson(*bases_list_ptr->get_obj(), &$obj.bases_list_ptr), result.first))
|
||||
return std::make_pair(false, "required [hello::world.bases_list_ptr] failed:{"+result.second+"}");
|
||||
|
||||
if(bases_ptr_list_ptr&& bases_ptr_list_ptr->get_obj())
|
||||
gson(*bases_ptr_list_ptr->get_obj(), &$obj.bases_ptr_list_ptr);
|
||||
|
||||
if(!base_map ||!base_map->get_obj()||!(result = gson(*base_map->get_obj(), &$obj.base_map), result.first))
|
||||
return std::make_pair(false, "required [hello::world.base_map] failed:{"+result.second+"}");
|
||||
|
||||
if(!base_list_map ||!base_list_map->get_obj()||!(result = gson(*base_list_map->get_obj(), &$obj.base_list_map), result.first))
|
||||
return std::make_pair(false, "required [hello::world.base_list_map] failed:{"+result.second+"}");
|
||||
|
||||
if(!vector_string ||!vector_string->get_obj()||!(result = gson(*vector_string->get_obj(), &$obj.vector_string), result.first))
|
||||
return std::make_pair(false, "required [hello::world.vector_string] failed:{"+result.second+"}");
|
||||
|
||||
if(!vector_list_base ||!vector_list_base->get_obj()||!(result = gson(*vector_list_base->get_obj(), &$obj.vector_list_base), result.first))
|
||||
return std::make_pair(false, "required [hello::world.vector_list_base] failed:{"+result.second+"}");
|
||||
|
||||
if(!me ||!(result = gson(*me, &$obj.me), result.first))
|
||||
return std::make_pair(false, "required [hello::world.me] failed:{"+result.second+"}");
|
||||
|
||||
return std::make_pair(true,"");
|
||||
}
|
||||
|
||||
|
||||
std::pair<bool,std::string> gson(acl::json_node &$node, hello::world *$obj)
|
||||
{
|
||||
return gson($node, *$obj);
|
||||
}
|
||||
|
||||
|
||||
acl::json_node& gson(acl::json &$json, const list1 &$obj)
|
||||
{
|
||||
acl::json_node &$node = $json.create_node();
|
||||
|
||||
if (check_nullptr($obj.b))
|
||||
$node.add_null("b");
|
||||
else
|
||||
$node.add_child("b", acl::gson($json, $obj.b));
|
||||
|
||||
if (check_nullptr($obj.b_ptr))
|
||||
$node.add_null("b_ptr");
|
||||
else
|
||||
$node.add_child("b_ptr", acl::gson($json, $obj.b_ptr));
|
||||
|
||||
if (check_nullptr($obj.bases_list))
|
||||
$node.add_null("bases_list");
|
||||
else
|
||||
$node.add_child("bases_list", acl::gson($json, $obj.bases_list));
|
||||
|
||||
if (check_nullptr($obj.bases_list_ptr))
|
||||
$node.add_null("bases_list_ptr");
|
||||
else
|
||||
$node.add_child("bases_list_ptr", acl::gson($json, $obj.bases_list_ptr));
|
||||
|
||||
if (check_nullptr($obj.bases_ptr_list_ptr))
|
||||
$node.add_null("bases_ptr_list_ptr");
|
||||
else
|
||||
$node.add_child("bases_ptr_list_ptr", acl::gson($json, $obj.bases_ptr_list_ptr));
|
||||
|
||||
if (check_nullptr($obj.base_map))
|
||||
$node.add_null("base_map");
|
||||
else
|
||||
$node.add_child("base_map", acl::gson($json, $obj.base_map));
|
||||
|
||||
if (check_nullptr($obj.base_list_map))
|
||||
$node.add_null("base_list_map");
|
||||
else
|
||||
$node.add_child("base_list_map", acl::gson($json, $obj.base_list_map));
|
||||
|
||||
if (check_nullptr($obj.vector_string))
|
||||
$node.add_null("vector_string");
|
||||
else
|
||||
$node.add_child("vector_string", acl::gson($json, $obj.vector_string));
|
||||
|
||||
if (check_nullptr($obj.vector_list_base))
|
||||
$node.add_null("vector_list_base");
|
||||
else
|
||||
$node.add_child("vector_list_base", acl::gson($json, $obj.vector_list_base));
|
||||
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
acl::json_node& gson(acl::json &$json, const list1 *$obj)
|
||||
{
|
||||
return gson ($json, *$obj);
|
||||
}
|
||||
|
||||
|
||||
acl::string gson(const list1 &$obj)
|
||||
{
|
||||
acl::json $json;
|
||||
acl::json_node &$node = acl::gson ($json, $obj);
|
||||
return $node.to_string ();
|
||||
}
|
||||
|
||||
|
||||
std::pair<bool,std::string> gson(acl::json_node &$node, list1 &$obj)
|
||||
{
|
||||
acl::json_node *b = $node["b"];
|
||||
acl::json_node *b_ptr = $node["b_ptr"];
|
||||
acl::json_node *bases_list = $node["bases_list"];
|
||||
acl::json_node *bases_list_ptr = $node["bases_list_ptr"];
|
||||
acl::json_node *bases_ptr_list_ptr = $node["bases_ptr_list_ptr"];
|
||||
acl::json_node *base_map = $node["base_map"];
|
||||
acl::json_node *base_list_map = $node["base_list_map"];
|
||||
acl::json_node *vector_string = $node["vector_string"];
|
||||
acl::json_node *vector_list_base = $node["vector_list_base"];
|
||||
std::pair<bool, std::string> result;
|
||||
|
||||
if(!b ||!b->get_obj()||!(result = gson(*b->get_obj(), &$obj.b), result.first))
|
||||
return std::make_pair(false, "required [list1.b] failed:{"+result.second+"}");
|
||||
|
||||
if(!b_ptr ||!b_ptr->get_obj()||!(result = gson(*b_ptr->get_obj(), &$obj.b_ptr), result.first))
|
||||
return std::make_pair(false, "required [list1.b_ptr] failed:{"+result.second+"}");
|
||||
|
||||
if(!bases_list ||!bases_list->get_obj()||!(result = gson(*bases_list->get_obj(), &$obj.bases_list), result.first))
|
||||
return std::make_pair(false, "required [list1.bases_list] failed:{"+result.second+"}");
|
||||
|
||||
if(!bases_list_ptr ||!bases_list_ptr->get_obj()||!(result = gson(*bases_list_ptr->get_obj(), &$obj.bases_list_ptr), result.first))
|
||||
return std::make_pair(false, "required [list1.bases_list_ptr] failed:{"+result.second+"}");
|
||||
|
||||
if(bases_ptr_list_ptr&& bases_ptr_list_ptr->get_obj())
|
||||
gson(*bases_ptr_list_ptr->get_obj(), &$obj.bases_ptr_list_ptr);
|
||||
|
||||
if(!base_map ||!base_map->get_obj()||!(result = gson(*base_map->get_obj(), &$obj.base_map), result.first))
|
||||
return std::make_pair(false, "required [list1.base_map] failed:{"+result.second+"}");
|
||||
|
||||
if(!base_list_map ||!base_list_map->get_obj()||!(result = gson(*base_list_map->get_obj(), &$obj.base_list_map), result.first))
|
||||
return std::make_pair(false, "required [list1.base_list_map] failed:{"+result.second+"}");
|
||||
|
||||
if(!vector_string ||!vector_string->get_obj()||!(result = gson(*vector_string->get_obj(), &$obj.vector_string), result.first))
|
||||
return std::make_pair(false, "required [list1.vector_string] failed:{"+result.second+"}");
|
||||
|
||||
if(!vector_list_base ||!vector_list_base->get_obj()||!(result = gson(*vector_list_base->get_obj(), &$obj.vector_list_base), result.first))
|
||||
return std::make_pair(false, "required [list1.vector_list_base] failed:{"+result.second+"}");
|
||||
|
||||
return std::make_pair(true,"");
|
||||
}
|
||||
|
||||
|
||||
std::pair<bool,std::string> gson(acl::json_node &$node, list1 *$obj)
|
||||
{
|
||||
return gson($node, *$obj);
|
||||
}
|
||||
|
||||
|
||||
}///end of acl.
|
21
app/gson/demo/gson.h
Normal file
21
app/gson/demo/gson.h
Normal file
@ -0,0 +1,21 @@
|
||||
namespace acl
|
||||
{
|
||||
//base
|
||||
acl::string gson(const base &$obj);
|
||||
acl::json_node& gson(acl::json &$json, const base &$obj);
|
||||
acl::json_node& gson(acl::json &$json, const base *$obj);
|
||||
std::pair<bool,std::string> gson(acl::json_node &$node, base &$obj);
|
||||
std::pair<bool,std::string> gson(acl::json_node &$node, base *$obj);
|
||||
//hello::world
|
||||
acl::string gson(const hello::world &$obj);
|
||||
acl::json_node& gson(acl::json &$json, const hello::world &$obj);
|
||||
acl::json_node& gson(acl::json &$json, const hello::world *$obj);
|
||||
std::pair<bool,std::string> gson(acl::json_node &$node, hello::world &$obj);
|
||||
std::pair<bool,std::string> gson(acl::json_node &$node, hello::world *$obj);
|
||||
//list1
|
||||
acl::string gson(const list1 &$obj);
|
||||
acl::json_node& gson(acl::json &$json, const list1 &$obj);
|
||||
acl::json_node& gson(acl::json &$json, const list1 *$obj);
|
||||
std::pair<bool,std::string> gson(acl::json_node &$node, list1 &$obj);
|
||||
std::pair<bool,std::string> gson(acl::json_node &$node, list1 *$obj);
|
||||
}///end of acl.
|
@ -40,27 +40,31 @@ void test_base()
|
||||
obj.bases_list_ptr = new std::list<base>;
|
||||
obj.bases_list_ptr->push_back(b);
|
||||
obj.bases_ptr_list_ptr = new std::list<base*>;
|
||||
obj.bases_ptr_list_ptr->push_back(nullptr);
|
||||
obj.bases_ptr_list_ptr->push_back(nullptr);
|
||||
obj.bases_ptr_list_ptr->push_back(nullptr);
|
||||
obj.bases_ptr_list_ptr->push_back(nullptr);
|
||||
obj.bases_ptr_list_ptr->push_back(NULL);
|
||||
obj.bases_ptr_list_ptr->push_back(NULL);
|
||||
obj.bases_ptr_list_ptr->push_back(NULL);
|
||||
obj.bases_ptr_list_ptr->push_back(NULL);
|
||||
obj.base_map.insert(std::make_pair("base", b));
|
||||
obj.base_list_map.insert( std::make_pair("base", obj.bases_list));
|
||||
obj.vector_list_base.push_back(obj.bases_list);
|
||||
|
||||
acl::json json;
|
||||
acl::json_node &node = acl::gson(json, obj);
|
||||
printf("%s\n", node.to_string().c_str());
|
||||
printf("%s\n\n", node.to_string().c_str());
|
||||
|
||||
|
||||
list1 obj2;
|
||||
acl::json json2;
|
||||
json2.update(node.to_string().c_str());
|
||||
printf("%s\n",json2.to_string().c_str());
|
||||
printf("%s\n\n",json2.to_string().c_str());
|
||||
std::pair<bool,std::string> ret = acl::gson(json2.get_root(), obj2);
|
||||
if(ret.first == false)
|
||||
printf("%s\n",ret.second.c_str());
|
||||
printf("%s\n\n",ret.second.c_str());
|
||||
else
|
||||
{
|
||||
acl::json json3;
|
||||
acl::json_node &node3 = acl::gson(json3, obj2);
|
||||
printf("%s\n", node3.to_string().c_str());
|
||||
printf("%s\n\n", node3.to_string().c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,22 +2,24 @@
|
||||
|
||||
struct base
|
||||
{
|
||||
std::string string;
|
||||
std::string *string_ptr;
|
||||
int a;
|
||||
int *a_ptr;
|
||||
unsigned int b;
|
||||
std::string string ;
|
||||
//Gson@optional
|
||||
std::string *string_ptr ;
|
||||
int a ;
|
||||
int *a_ptr ;
|
||||
unsigned int b ;
|
||||
unsigned int *b_ptr;
|
||||
int64_t c;
|
||||
int64_t *c_ptr;
|
||||
int64_t c ;
|
||||
int64_t *c_ptr ;
|
||||
unsigned long d;
|
||||
unsigned long *d_ptr;
|
||||
unsigned long long e;
|
||||
unsigned long *d_ptr ;
|
||||
unsigned long long e ;
|
||||
unsigned long long *e_ptr;
|
||||
long f;
|
||||
long *f_ptr;
|
||||
long f ;
|
||||
long *f_ptr ;
|
||||
long long g;
|
||||
long long *g_ptr;
|
||||
|
||||
long long *g_ptr ;
|
||||
acl::string acl_string;
|
||||
acl::string *acl_string_ptr;
|
||||
|
||||
@ -33,6 +35,18 @@ struct list1
|
||||
base *b_ptr;
|
||||
std::list<base> bases_list;
|
||||
std::list<base> *bases_list_ptr;
|
||||
//Gson@optional
|
||||
std::list<base*> *bases_ptr_list_ptr;
|
||||
std::map<std::string,base> base_map;
|
||||
std::map<std::string,std::list<base> > base_list_map;
|
||||
std::vector<std::string> vector_string;
|
||||
std::vector<std::list<base> > vector_list_base;
|
||||
};
|
||||
|
||||
namespace hello
|
||||
{
|
||||
struct world : list1
|
||||
{
|
||||
int me;
|
||||
};
|
||||
}
|
||||
|
@ -2,22 +2,24 @@
|
||||
|
||||
struct base
|
||||
{
|
||||
std::string string;
|
||||
std::string *string_ptr;
|
||||
int a;
|
||||
int *a_ptr;
|
||||
unsigned int b;
|
||||
std::string string ;
|
||||
//Gson@optional
|
||||
std::string *string_ptr ;
|
||||
int a ;
|
||||
int *a_ptr ;
|
||||
unsigned int b ;
|
||||
unsigned int *b_ptr;
|
||||
int64_t c;
|
||||
int64_t *c_ptr;
|
||||
int64_t c ;
|
||||
int64_t *c_ptr ;
|
||||
unsigned long d;
|
||||
unsigned long *d_ptr;
|
||||
unsigned long long e;
|
||||
unsigned long *d_ptr ;
|
||||
unsigned long long e ;
|
||||
unsigned long long *e_ptr;
|
||||
long f;
|
||||
long *f_ptr;
|
||||
long f ;
|
||||
long *f_ptr ;
|
||||
long long g;
|
||||
long long *g_ptr;
|
||||
|
||||
long long *g_ptr ;
|
||||
acl::string acl_string;
|
||||
acl::string *acl_string_ptr;
|
||||
|
||||
@ -33,6 +35,18 @@ struct list1
|
||||
base *b_ptr;
|
||||
std::list<base> bases_list;
|
||||
std::list<base> *bases_list_ptr;
|
||||
//Gson@optional
|
||||
std::list<base*> *bases_ptr_list_ptr;
|
||||
std::map<std::string,base> base_map;
|
||||
std::map<std::string,std::list<base> > base_list_map;
|
||||
std::vector<std::string> vector_string;
|
||||
std::vector<std::list<base> > vector_list_base;
|
||||
};
|
||||
|
||||
namespace hello
|
||||
{
|
||||
struct world : list1
|
||||
{
|
||||
int me;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user