mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #2 from sehraf/pr_improve_json
Multiple fixes on json handling by sehraf
This commit is contained in:
commit
41f7235ed0
@ -293,16 +293,25 @@ public:
|
||||
std::string cipher_version;
|
||||
};
|
||||
|
||||
class RsGroupInfo
|
||||
class RsGroupInfo : RsSerializable
|
||||
{
|
||||
public:
|
||||
RsGroupInfo();
|
||||
RsGroupInfo();
|
||||
|
||||
RsNodeGroupId id;
|
||||
std::string name;
|
||||
uint32_t flag;
|
||||
RsNodeGroupId id;
|
||||
std::string name;
|
||||
uint32_t flag;
|
||||
|
||||
std::set<RsPgpId> peerIds;
|
||||
std::set<RsPgpId> peerIds;
|
||||
|
||||
// RsSerializable interface
|
||||
public:
|
||||
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
|
||||
RS_SERIAL_PROCESS(id);
|
||||
RS_SERIAL_PROCESS(name);
|
||||
RS_SERIAL_PROCESS(flag);
|
||||
RS_SERIAL_PROCESS(peerIds);
|
||||
}
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
|
||||
|
@ -169,23 +169,23 @@ template<> void RsTypeSerializer::print_data(const std::string& n, const bool &
|
||||
}
|
||||
template<> void RsTypeSerializer::print_data(const std::string& n, const int32_t& V)
|
||||
{
|
||||
std::cerr << " [int32_t ] " << n << ": " << V << std::endl;
|
||||
std::cerr << " [int32_t ] " << n << ": " << std::to_string(V) << std::endl;
|
||||
}
|
||||
template<> void RsTypeSerializer::print_data(const std::string& n, const uint8_t & V)
|
||||
{
|
||||
std::cerr << " [uint8_t ] " << n << ": " << V << std::endl;
|
||||
std::cerr << " [uint8_t ] " << n << ": " << std::to_string(V) << std::endl;
|
||||
}
|
||||
template<> void RsTypeSerializer::print_data(const std::string& n, const uint16_t& V)
|
||||
{
|
||||
std::cerr << " [uint16_t ] " << n << ": " << V << std::endl;
|
||||
std::cerr << " [uint16_t ] " << n << ": " << std::to_string(V) << std::endl;
|
||||
}
|
||||
template<> void RsTypeSerializer::print_data(const std::string& n, const uint32_t& V)
|
||||
{
|
||||
std::cerr << " [uint32_t ] " << n << ": " << V << std::endl;
|
||||
std::cerr << " [uint32_t ] " << n << ": " << std::to_string(V) << std::endl;
|
||||
}
|
||||
template<> void RsTypeSerializer::print_data(const std::string& n, const uint64_t& V)
|
||||
{
|
||||
std::cerr << " [uint64_t ] " << n << ": " << V << std::endl;
|
||||
std::cerr << " [uint64_t ] " << n << ": " << std::to_string(V) << std::endl;
|
||||
}
|
||||
template<> void RsTypeSerializer::print_data(const std::string& n, const time_t& V)
|
||||
{
|
||||
|
@ -94,21 +94,25 @@
|
||||
{\
|
||||
for (auto&& arrEl : jDoc[arrKey].GetArray())\
|
||||
{\
|
||||
Value arrKeyT;\
|
||||
arrKeyT.SetString(memberName.c_str(), memberName.length());\
|
||||
\
|
||||
RsGenericSerializer::SerializeContext elCtx(\
|
||||
nullptr, 0, ctx.mFlags, &allocator );\
|
||||
elCtx.mJson.AddMember(arrKey, arrEl, allocator);\
|
||||
elCtx.mJson.AddMember(arrKeyT, arrEl, allocator);\
|
||||
\
|
||||
T el;\
|
||||
serial_process(j, elCtx, el, memberName); \
|
||||
ok = ok && elCtx.mOk;\
|
||||
\
|
||||
ctx.mOk &= ok;\
|
||||
if(ok) v.INSERT_FUN(el);\
|
||||
else break;\
|
||||
}\
|
||||
}\
|
||||
\
|
||||
ctx.mOk = false;\
|
||||
else\
|
||||
{\
|
||||
ctx.mOk = false;\
|
||||
}\
|
||||
\
|
||||
} while(false)
|
||||
|
||||
@ -351,8 +355,10 @@ struct RsTypeSerializer
|
||||
else break;
|
||||
}
|
||||
}
|
||||
|
||||
ctx.mOk = false;
|
||||
else
|
||||
{
|
||||
ctx.mOk = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -479,10 +485,12 @@ struct RsTypeSerializer
|
||||
case RsGenericSerializer::PRINT:
|
||||
{
|
||||
if(v.empty())
|
||||
std::cerr << " Empty array"<< std::endl;
|
||||
else
|
||||
std::cerr << " Array of " << v.size() << " elements:"
|
||||
std::cerr << " Empty vector \"" << memberName << "\""
|
||||
<< std::endl;
|
||||
else
|
||||
std::cerr << " Vector of " << v.size() << " elements: \""
|
||||
<< memberName << "\"" << std::endl;
|
||||
|
||||
for(uint32_t i=0;i<v.size();++i)
|
||||
{
|
||||
std::cerr << " " ;
|
||||
@ -541,9 +549,12 @@ struct RsTypeSerializer
|
||||
}
|
||||
case RsGenericSerializer::PRINT:
|
||||
{
|
||||
if(v.empty()) std::cerr << " Empty set"<< std::endl;
|
||||
else std::cerr << " Set of " << v.size() << " elements:"
|
||||
<< std::endl;
|
||||
if(v.empty())
|
||||
std::cerr << " Empty set \"" << memberName << "\""
|
||||
<< std::endl;
|
||||
else
|
||||
std::cerr << " Set of " << v.size() << " elements: \""
|
||||
<< memberName << "\"" << std::endl;
|
||||
break;
|
||||
}
|
||||
case RsGenericSerializer::TO_JSON:
|
||||
@ -594,9 +605,12 @@ struct RsTypeSerializer
|
||||
}
|
||||
case RsGenericSerializer::PRINT:
|
||||
{
|
||||
if(v.empty()) std::cerr << " Empty list"<< std::endl;
|
||||
else std::cerr << " List of " << v.size() << " elements:"
|
||||
<< std::endl;
|
||||
if(v.empty())
|
||||
std::cerr << " Empty list \"" << memberName << "\""
|
||||
<< std::endl;
|
||||
else
|
||||
std::cerr << " List of " << v.size() << " elements: \""
|
||||
<< memberName << "\"" << std::endl;
|
||||
break;
|
||||
}
|
||||
case RsGenericSerializer::TO_JSON:
|
||||
|
Loading…
Reference in New Issue
Block a user