JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
IsXBoolProvider.h
Go to the documentation of this file.
1 //
2 // Created by Nico Schäfer on 11/24/17.
3 //
4 
5 #ifndef JODA_ISXBOOLPROVIDER_H
6 #define JODA_ISXBOOLPROVIDER_H
7 #include <rapidjson/fwd.h>
8 
9 #include "IValueProvider.h"
10 
11 namespace joda::query {
19 template <joda::query::IValueType T>
21  public:
22  explicit IsXBoolProvider(
23  std::vector<std::unique_ptr<IValueProvider>> &&parameters)
24  : IValueProvider(std::move(parameters)) {
25  checkParamSize(1);
26 
27  if (!params[0]->isAny() && params[0]->isConst()) {
28  cons = true;
29  consRes = T == IV_Any || T == params[0]->getReturnType();
30  }
31  }
32 
33  std::unique_ptr<IValueProvider> duplicate() const override {
34  return std::make_unique<IsXBoolProvider>(duplicateParameters());
35  }
36 
37  bool isConst() const override { return cons; }
38 
40  RJMemoryPoolAlloc &alloc) const override;
41 
42  const RJValue *getValue(const RapidJsonDocument &json,
43  RJMemoryPoolAlloc &alloc) const override {
44  assert(!isAtom() && "Did not check for atom before calling");
45  return nullptr;
46  }
47 
48  std::string getName() const override;
49 
50  joda::query::IValueType getReturnType() const override { return IV_Bool; }
51 
53 
54  protected:
55  bool cons = false;
56  bool consRes = false;
57 };
58 } // namespace joda::query
59 
60 #endif // JODA_ISXBOOLPROVIDER_H
#define CREATE_FACTORY(FCLASS)
Definition: IValueProvider.h:20
rapidjson::MemoryPoolAllocator< RJBaseAlloc > RJMemoryPoolAlloc
Definition: RJFwd.h:26
rapidjson::GenericValue< RJChar, RJMemoryPoolAlloc > RJValue
Definition: RJFwd.h:29
Definition: RapidJsonDocument.h:22
Definition: IValueProvider.h:143
virtual bool isAny() const
Definition: IValueProvider.h:214
std::vector< std::unique_ptr< IValueProvider > > params
Definition: IValueProvider.h:373
void checkParamSize(unsigned int expected)
Definition: IValueProvider.cpp:112
virtual bool isAtom() const
Definition: IValueProvider.h:215
std::vector< std::unique_ptr< IValueProvider > > duplicateParameters() const
Definition: IValueProvider.cpp:104
Definition: IsXBoolProvider.h:20
bool consRes
Definition: IsXBoolProvider.h:56
std::unique_ptr< IValueProvider > duplicate() const override
Definition: IsXBoolProvider.h:33
bool cons
Definition: IsXBoolProvider.h:55
const RJValue * getValue(const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc) const override
Definition: IsXBoolProvider.h:42
std::string getName() const override
bool isConst() const override
Definition: IsXBoolProvider.h:37
joda::query::IValueType getReturnType() const override
Definition: IsXBoolProvider.h:50
RJValue getAtomValue(const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc) const override
IsXBoolProvider(std::vector< std::unique_ptr< IValueProvider >> &&parameters)
Definition: IsXBoolProvider.h:22
Definition: AttributeStatAggregator.h:12
IValueType
Definition: IValueProvider.h:33
@ IV_Bool
Definition: IValueProvider.h:36
@ IV_Any
Definition: IValueProvider.h:39