JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
AtomProvider.h
Go to the documentation of this file.
1 #include <utility>
2 
3 //
4 // Created by Nico Schäfer on 11/13/17.
5 //
6 
7 #ifndef JODA_ATOMPROVIDER_H
8 #define JODA_ATOMPROVIDER_H
9 
10 #define JODA_TRUE_STRING "true"
11 #define JODA_FALSE_STRING "false"
12 
13 #include <rapidjson/fwd.h>
14 
15 #include "IValueProvider.h"
16 namespace joda::query {
17 
21 template <typename T>
23  public:
25  : val(std::move(val)){
26 
27  };
28 
29  std::unique_ptr<IValueProvider> duplicate() const override {
30  return std::make_unique<AtomProvider<T>>(val);
31  };
32  std::string toString() const override;
33 
34  bool isConst() const override { return true; };
36  RJMemoryPoolAlloc &alloc) const override;
37 
38  const RJValue *getValue(const RapidJsonDocument &json,
39  RJMemoryPoolAlloc &alloc) const override {
40  assert(!isAtom() && "Did not check for atom before calling");
41  return nullptr;
42  };
43 
44  std::string getName() const override;
46 
47  protected:
48  T val;
49 };
50 
51 template class AtomProvider<double>;
52 
54 
55 template class AtomProvider<int64_t>;
56 
58 
59 template class AtomProvider<u_int64_t>;
60 
62 
63 /*
64  * Bool
65  */
66 
67 template class AtomProvider<bool>;
68 
70 
71 template class AtomProvider<std::string>;
72 
74 
79 template <>
81 
82 template <>
84 
85 template <>
86 std::string AtomProvider<int64_t>::toString() const;
87 
88 template <>
89 std::string AtomProvider<double>::toString() const;
90 
91 template <>
92 std::string AtomProvider<bool>::toString() const;
93 
94 template <typename T>
95 inline std::string AtomProvider<T>::getName() const {
96  return toString();
97 };
98 
99 } // namespace joda::query
100 #endif // JODA_ATOMPROVIDER_H
rapidjson::MemoryPoolAllocator< RJBaseAlloc > RJMemoryPoolAlloc
Definition: RJFwd.h:26
rapidjson::GenericValue< RJChar, RJMemoryPoolAlloc > RJValue
Definition: RJFwd.h:29
Definition: RapidJsonDocument.h:22
Definition: AtomProvider.h:22
RJValue getAtomValue(const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc) const override
const RJValue * getValue(const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc) const override
Definition: AtomProvider.h:38
std::string toString() const override
joda::query::IValueType getReturnType() const override
T val
Definition: AtomProvider.h:48
std::unique_ptr< IValueProvider > duplicate() const override
Definition: AtomProvider.h:29
AtomProvider(T val)
Definition: AtomProvider.h:24
std::string getName() const override
Definition: AtomProvider.h:95
bool isConst() const override
Definition: AtomProvider.h:34
Definition: IValueProvider.h:143
virtual bool isAtom() const
Definition: IValueProvider.h:215
Definition: AttributeStatAggregator.h:12
AtomProvider< int64_t > Int64Provider
Definition: AtomProvider.h:57
AtomProvider< u_int64_t > UInt64Provider
Definition: AtomProvider.h:61
AtomProvider< double > DoubleProvider
Definition: AtomProvider.h:53
AtomProvider< std::string > StringProvider
Definition: AtomProvider.h:73
AtomProvider< bool > BoolProvider
Definition: AtomProvider.h:69
IValueType
Definition: IValueProvider.h:33