5 #ifndef JODA_VIRTUALOBJECT_H
6 #define JODA_VIRTUALOBJECT_H
8 #include <glog/logging.h>
34 size_t start_ = 0, end_ = 0, size_ = 0;
38 auto iterateMemberRetAll(F &&lambda)
const {
43 ret.emplace_back(lambda(o));
48 template <
typename Ret,
typename F>
49 auto iterateMemberRetOne(F &&lambda, Ret &&init)
const {
58 void iterateMember(F &&lambda)
const {
61 DCHECK(end_ - start_ >= size_);
62 for (
size_t j = 0; j < size_; ++j) {
63 const auto &member = *it;
73 template <
typename Handler>
74 bool Accept(Handler &handler)
const {
75 if (RAPIDJSON_UNLIKELY(!handler.StartObject()))
return false;
77 if (!iterateMemberRetOne<bool>(
80 if (!prev)
return false;
82 DCHECK(name !=
nullptr);
83 if (RAPIDJSON_UNLIKELY(
84 !handler.Key(name->c_str(), name->size(),
true)))
87 if (member.
val !=
nullptr) {
88 if (RAPIDJSON_UNLIKELY(!member.val->Accept(handler)))
91 if (member.obj == nullptr) {
92 if (RAPIDJSON_UNLIKELY(!RJValue().Accept(handler)))
95 if (RAPIDJSON_UNLIKELY(!member.obj->Accept(handler)))
104 return handler.EndObject(size_);
rapidjson::MemoryPoolAllocator< RJBaseAlloc > RJMemoryPoolAlloc
Definition: RJFwd.h:26
rapidjson::GenericValue< RJChar, RJMemoryPoolAlloc > RJValue
Definition: RJFwd.h:29
Definition: ViewStructure.h:14
const KEY * getKey(const ID &id) const
Definition: ViewStructure.cpp:32
size_t ID
Definition: ViewStructure.h:26
MemberIterator beginMember() const
Definition: ViewStructure.cpp:51
Definition: VirtualObject.h:13
VirtualObject & operator=(const VirtualObject &o)=delete
std::vector< std::string > attributes() const
Definition: VirtualObject.cpp:29
VirtualObject(const VirtualObject &o)=delete
void reserve(size_t r)
Definition: VirtualObject.cpp:23
size_t size() const
Definition: VirtualObject.cpp:7
bool Accept(Handler &handler) const
Definition: VirtualObject.h:74
void addMember(ViewStructure::ID, const RJValue *val)
Definition: VirtualObject.cpp:9
VirtualObject(VirtualObject &&o)=default
VirtualObject & operator=(VirtualObject &&o)=default
RJValue deepCopy(RJMemoryPoolAlloc &alloc) const
Definition: VirtualObject.cpp:35
Definition: ViewStructure.h:55
const RJValue * val
Definition: ViewStructure.h:65
ViewStructure::ID key
Definition: ViewStructure.h:64