JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
IProjector.h
Go to the documentation of this file.
1 //
2 // Created by Nico on 11/14/17.
3 //
4 
5 #ifndef JODA_IPROJECTOR_H
6 #define JODA_IPROJECTOR_H
8 #include <rapidjson/pointer.h>
9 
10 namespace joda::query {
15 class IProjector {
16  public:
22  IProjector(const std::string &to) : ptr(to.c_str()), ptr_str(to){};
23 
24  virtual ~IProjector() = default;
25 
34  virtual void project(const RapidJsonDocument &json, RJDocument &newDoc,
35  bool view = false) {
36  auto val = this->getVal(json, newDoc.GetAllocator());
37  if (!val.IsNull()) ptr.Set(newDoc, val);
38  }
39 
44  std::string getToPointer() const { return ptr_str; }
49  const RJPointer &getRawToPointer() const { return ptr; }
50 
55  virtual std::string getType() = 0;
56 
62  virtual std::string toString() { return "'" + ptr_str + "':"; }
63 
69  virtual std::vector<std::string> getMaterializeAttributes() const = 0;
70 
71  protected:
72  virtual RJValue getVal(const RapidJsonDocument &json,
73  RJMemoryPoolAlloc &alloc) = 0;
74 
76  std::string ptr_str;
77 };
78 } // namespace joda::query
79 #endif // JODA_IPROJECTOR_H
rapidjson::GenericDocument< RJChar, RJMemoryPoolAlloc, RJBaseAlloc > RJDocument
Definition: RJFwd.h:28
rapidjson::MemoryPoolAllocator< RJBaseAlloc > RJMemoryPoolAlloc
Definition: RJFwd.h:26
rapidjson::GenericPointer< RJValue, RJBaseAlloc > RJPointer
Definition: RJFwd.h:30
rapidjson::GenericValue< RJChar, RJMemoryPoolAlloc > RJValue
Definition: RJFwd.h:29
Definition: RapidJsonDocument.h:22
Definition: IProjector.h:15
virtual RJValue getVal(const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc)=0
virtual std::string toString()
Definition: IProjector.h:62
virtual std::string getType()=0
const RJPointer & getRawToPointer() const
Definition: IProjector.h:49
std::string ptr_str
Definition: IProjector.h:76
virtual std::vector< std::string > getMaterializeAttributes() const =0
IProjector(const std::string &to)
Definition: IProjector.h:22
virtual void project(const RapidJsonDocument &json, RJDocument &newDoc, bool view=false)
Definition: IProjector.h:34
std::string getToPointer() const
Definition: IProjector.h:44
RJPointer ptr
Definition: IProjector.h:75
virtual ~IProjector()=default
Definition: AttributeStatAggregator.h:12