5 #ifndef JODA_ISetPROJECTOR_H
6 #define JODA_ISetPROJECTOR_H
7 #include <rapidjson/pointer.h>
34 std::vector<std::unique_ptr<RJDocument>> &newDocs,
35 bool view =
false) = 0;
72 unsigned long multiplicate(std::vector<std::unique_ptr<RJDocument>> &newDocs,
74 auto origDocs = newDocs.size();
75 newDocs.reserve(origDocs * times);
77 for (
auto i = 0; i < times - 1; ++i) {
78 for (
size_t j = 0; j < origDocs; ++j) {
79 assert(j < newDocs.size() && j >= 0 &&
"Stay in range of array");
80 auto doc = std::make_unique<RJDocument>(&newDocs[j]->GetAllocator());
81 doc->CopyFrom(*newDocs[j], doc->GetAllocator());
82 newDocs.push_back(std::move(doc));
89 unsigned long origDocs,
int i,
RJValue &val) {
90 for (
unsigned long j = origDocs * i; j < origDocs * (i + 1); ++j) {
91 assert(j < newDocs.size() && j >= 0 &&
"Stay in range of array");
93 newval.CopyFrom(val, newDocs.front()->GetAllocator());
94 ptr.Set(*newDocs[j], newval);
rapidjson::GenericPointer< RJValue, RJBaseAlloc > RJPointer
Definition: RJFwd.h:30
rapidjson::GenericValue< RJChar, RJMemoryPoolAlloc > RJValue
Definition: RJFwd.h:29
Definition: RapidJsonDocument.h:22
Definition: ISetProjector.h:16
ISetProjector(const std::string &to)
Definition: ISetProjector.h:23
RJPointer getRawToPointer() const
Definition: ISetProjector.h:47
virtual ~ISetProjector()=default
virtual std::vector< std::string > getAttributes() const =0
void fillArrayRangeWithVal(std::vector< std::unique_ptr< RJDocument >> &newDocs, unsigned long origDocs, int i, RJValue &val)
Definition: ISetProjector.h:88
virtual std::string getToPointer() const final
Definition: ISetProjector.h:41
virtual std::string getType()=0
unsigned long multiplicate(std::vector< std::unique_ptr< RJDocument >> &newDocs, int times)
Definition: ISetProjector.h:72
RJPointer ptr
Definition: ISetProjector.h:69
std::string ptr_str
Definition: ISetProjector.h:70
virtual std::string toString()
Definition: ISetProjector.h:60
virtual void project(const RapidJsonDocument &json, std::vector< std::unique_ptr< RJDocument >> &newDocs, bool view=false)=0
Definition: AttributeStatAggregator.h:12