Merge pull request #12 from zhengshuxin/master

Merge from acl
This commit is contained in:
郑树新 2016-10-12 22:04:06 +08:00 committed by GitHub
commit 6ae0600e10
10 changed files with 32 additions and 347 deletions

View File

@ -1,321 +0,0 @@
#include "stdafx.h"
#include "struct.h"
#include "struct.h"
#include "gson.h"
#include "acl_cpp/stdlib/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 ||!(result = gson(*string_ptr,&obj.string_ptr), result.first))
return std::make_pair(false,"required [base.string_ptr] failed:{"+result.second+"}");
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 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));
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"];
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()||!(result = gson(*bases_ptr_list_ptr->get_obj(), &obj.bases_ptr_list_ptr), result.first))
return std::make_pair(false, "required [list1.bases_ptr_list_ptr] 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.

View File

@ -1,15 +0,0 @@
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);
//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.

15
app/gson/src/stdafx.h Normal file
View File

@ -0,0 +1,15 @@
// stdafx.h : 标准系统包含文件的包含文件,
// 或是常用但不常更改的项目特定的包含文件
//
#pragma once
//#include <iostream>
//#include <tchar.h>
// TODO: 在此处引用程序要求的附加头文件
#include "lib_acl.h"
#include "acl_cpp/lib_acl.hpp"
#include "lib_protocol.h"

View File

@ -143,7 +143,8 @@ OBJS_DST = $(patsubst %.cpp, $(OBJ_PATH_DST)/%.o, $(notdir $(wildcard src/*.cpp)
$(patsubst %.cpp, $(OBJ_PATH_DST)/%.o, $(notdir $(wildcard src/mime/internal/*.cpp))) \
$(patsubst %.cpp, $(OBJ_PATH_DST)/%.o, $(notdir $(wildcard src/connpool/*.cpp))) \
$(patsubst %.cpp, $(OBJ_PATH_DST)/%.o, $(notdir $(wildcard src/redis/*.cpp))) \
$(patsubst %.cpp, $(OBJ_PATH_DST)/%.o, $(notdir $(wildcard src/disque/*.cpp)))
$(patsubst %.cpp, $(OBJ_PATH_DST)/%.o, $(notdir $(wildcard src/disque/*.cpp))) \
$(patsubst %.cpp, $(OBJ_PATH_DST)/%.o, $(notdir $(wildcard src/serialize/*.cpp)))
OBJS_DEF = $(patsubst %.cpp, $(DEF_PATH_DST)/%.inc, $(notdir $(wildcard src/*.cpp))) \
$(patsubst %.cpp, $(DEF_PATH_DST)/%.inc, $(notdir $(wildcard src/stdlib/*.cpp))) \
@ -163,7 +164,8 @@ OBJS_DEF = $(patsubst %.cpp, $(DEF_PATH_DST)/%.inc, $(notdir $(wildcard src/*.cp
$(patsubst %.cpp, $(DEF_PATH_DST)/%.inc, $(notdir $(wildcard src/mime/internal/*.cpp))) \
$(patsubst %.cpp, $(DEF_PATH_DST)/%.inc, $(notdir $(wildcard src/connpool/*.cpp))) \
$(patsubst %.cpp, $(DEF_PATH_DST)/%.inc, $(notdir $(wildcard src/redis/*.cpp))) \
$(patsubst %.cpp, $(DEF_PATH_DST)/%.inc, $(notdir $(wildcard src/disque/*.cpp)))
$(patsubst %.cpp, $(DEF_PATH_DST)/%.inc, $(notdir $(wildcard src/disque/*.cpp))) \
$(patsubst %.cpp, $(DEF_PATH_DST)/%.inc, $(notdir $(wildcard src/serialize/*.cpp)))
###########################################################
.PHONY = static shared clean
@ -281,6 +283,8 @@ $(OBJ_PATH_DST)/%.o: ./src/redis/%.cpp
$(COMPILE_OBJ)
$(OBJ_PATH_DST)/%.o: ./src/disque/%.cpp
$(COMPILE_OBJ)
$(OBJ_PATH_DST)/%.o: ./src/serialize/%.cpp
$(COMPILE_OBJ)
$(DEF_PATH_DST)/%.inc: ./src/%.cpp
$(CREATE_DEF)
@ -320,6 +324,8 @@ $(DEF_PATH_DST)/%.inc: ./src/redis/%.cpp
$(CREATE_DEF)
$(DEF_PATH_DST)/%.inc: ./src/disque/%.cpp
$(CREATE_DEF)
$(DEF_PATH_DST)/%.inc: ./src/serialize/%.cpp
$(CREATE_DEF)
clean:
rm -f $(LIB_PATH_DST)/lib_acl_cpp.a

View File

@ -11,7 +11,7 @@
#include "acl_cpp/stdlib/final_tpl.hpp"
#include "acl_cpp/stdlib/json.hpp"
# ifdef ACL_USE_CPP11
# include "acl_cpp/stdlib/gsoner.hpp"
# include "acl_cpp/serialize/gsoner.hpp"
# endif
#include "acl_cpp/stdlib/locker.hpp"
#include "acl_cpp/stdlib/log.hpp"

View File

@ -511,6 +511,7 @@ copy $(TargetName).pdb ..\dist\lib\win64\$(TargetName).pdb /Y
<ClCompile Include="src\redis\redis_string.cpp" />
<ClCompile Include="src\redis\redis_transaction.cpp" />
<ClCompile Include="src\redis\redis_zset.cpp" />
<ClCompile Include="src\serialize\gsoner.cpp" />
<ClCompile Include="src\session\memcache_session.cpp" />
<ClCompile Include="src\session\redis_session.cpp" />
<ClCompile Include="src\session\session.cpp" />
@ -523,7 +524,6 @@ copy $(TargetName).pdb ..\dist\lib\win64\$(TargetName).pdb /Y
<ClCompile Include="src\stdlib\dns_service.cpp" />
<ClCompile Include="src\stdlib\escape.cpp" />
<ClCompile Include="src\stdlib\internal\win_iconv.cpp" />
<ClCompile Include="src\stdlib\gsoner.cpp" />
<ClCompile Include="src\stdlib\json.cpp" />
<ClCompile Include="src\stdlib\locker.cpp" />
<ClCompile Include="src\stdlib\log.cpp" />
@ -674,6 +674,7 @@ copy $(TargetName).pdb ..\dist\lib\win64\$(TargetName).pdb /Y
<ClInclude Include="include\acl_cpp\redis\redis_string.hpp" />
<ClInclude Include="include\acl_cpp\redis\redis_transaction.hpp" />
<ClInclude Include="include\acl_cpp\redis\redis_zset.hpp" />
<ClInclude Include="include\acl_cpp\serialize\gsoner.hpp" />
<ClInclude Include="include\acl_cpp\session\memcache_session.hpp" />
<ClInclude Include="include\acl_cpp\session\redis_session.hpp" />
<ClInclude Include="include\acl_cpp\session\session.hpp" />
@ -686,7 +687,6 @@ copy $(TargetName).pdb ..\dist\lib\win64\$(TargetName).pdb /Y
<ClInclude Include="include\acl_cpp\stdlib\dns_service.hpp" />
<ClInclude Include="include\acl_cpp\stdlib\escape.hpp" />
<ClInclude Include="include\acl_cpp\stdlib\final_tpl.hpp" />
<ClInclude Include="include\acl_cpp\stdlib\gsoner.hpp" />
<ClInclude Include="include\acl_cpp\stdlib\json.hpp" />
<ClInclude Include="include\acl_cpp\stdlib\locker.hpp" />
<ClInclude Include="include\acl_cpp\stdlib\log.hpp" />

View File

@ -235,8 +235,8 @@
<ClCompile Include="src\db\db_service_sqlite.cpp">
<Filter>Source Files\db</Filter>
</ClCompile>
<ClCompile Include="src\stdlib\gsoner.cpp">
<Filter>Source Files\stdlib</Filter>
<ClCompile Include="src\serialize\gsoner.cpp">
<Filter>Source Files\serialize</Filter>
</ClCompile>
<ClCompile Include="src\stdlib\json.cpp">
<Filter>Source Files\stdlib</Filter>
@ -717,6 +717,9 @@
<ClInclude Include="include\acl_cpp\mime\rfc822.hpp">
<Filter>Header Files\mime</Filter>
</ClInclude>
<ClInclude Include="include\acl_cpp\serialize\gsoner.hpp">
<Filter>Header Files\serialize</Filter>
</ClInclude>
<ClInclude Include="include\acl_cpp\session\memcache_session.hpp">
<Filter>Header Files\session</Filter>
</ClInclude>
@ -741,9 +744,6 @@
<ClInclude Include="include\acl_cpp\stdlib\final_tpl.hpp">
<Filter>Header Files\stdlib</Filter>
</ClInclude>
<ClInclude Include="include\acl_cpp\stdlib\gsoner.hpp">
<Filter>Header Files\stdlib</Filter>
</ClInclude>
<ClInclude Include="include\acl_cpp\stdlib\json.hpp">
<Filter>Header Files\stdlib</Filter>
</ClInclude>

View File

@ -1274,7 +1274,7 @@ void gsoner::gen_gson()
write_source("#include \"stdafx.h\"\n");
write_source(get_include_files());
write_source("#include \"" + gen_header_filename_ + "\"\n");
write_source("#include \"acl_cpp/stdlib/gson_helper.ipp\"\n");
write_source("#include \"acl_cpp/serialize/gson_helper.ipp\"\n");
write_header(namespace_start);
write_source(namespace_start);