JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
FilePosProvider.h
Go to the documentation of this file.
1 // INListProvider
2 // Created by Nico Schäfer on 12/7/17.
3 //
4 
5 #ifndef JODA_FILEPOSPROVIDER_H
6 #define JODA_FILEPOSPROVIDER_H
7 
9 
10 #include "IValueProvider.h"
11 
12 namespace joda::query {
17 template <bool start>
19  public:
20  FilePosProvider(std::vector<std::unique_ptr<IValueProvider>> &&parameters)
21  : IValueProvider(std::move(parameters)) {
22  checkParamSize(0);
23  }
24 
25  std::unique_ptr<IValueProvider> duplicate() const override {
26  return std::make_unique<FilePosProvider<start>>(duplicateParameters());
27  }
28 
29  bool isConst() const override { return false; }
30 
32  RJMemoryPoolAlloc &alloc) const override {
33  assert(isAtom() && "Did not check for atom before calling");
34  RJValue val;
35  auto& tmp = json.getOrigin();
36  auto *fileOrig = dynamic_cast<const FileOrigin *>(tmp.get());
37  if (fileOrig != nullptr) {
38  if (start)
39  val.SetInt64(fileOrig->getStart());
40  else
41  val.SetInt64(fileOrig->getEnd());
42  }
43  return val;
44  }
45  const RJValue *getValue(const RapidJsonDocument &json,
46  RJMemoryPoolAlloc &alloc) const override {
47  assert(!isAtom() && "Did not check for atom before calling");
48  return nullptr;
49  }
50 
51  std::string getName() const override {
52  return start ? "FILEPOSSTART" : "FILEPOSEND";
53  }
54 
55  joda::query::IValueType getReturnType() const override { return IV_Number; }
56 
57  inline static std::unique_ptr<IValueProvider> _FACTORY(
58  std::vector<std::unique_ptr<IValueProvider>> &&params) {
59  return std::make_unique<FilePosProvider<start>>(std::move(params));
60  }
61 
62  protected:
63 };
64 } // namespace joda::query
65 
66 #endif // JODA_FILEPOSPROVIDER_H
rapidjson::MemoryPoolAllocator< RJBaseAlloc > RJMemoryPoolAlloc
Definition: RJFwd.h:26
rapidjson::GenericValue< RJChar, RJMemoryPoolAlloc > RJValue
Definition: RJFwd.h:29
Definition: FileOrigin.h:17
Definition: RapidJsonDocument.h:22
const std::unique_ptr< const IOrigin > & getOrigin() const
Definition: RapidJsonDocument.cpp:25
Definition: FilePosProvider.h:18
static std::unique_ptr< IValueProvider > _FACTORY(std::vector< std::unique_ptr< IValueProvider >> &&params)
Definition: FilePosProvider.h:57
const RJValue * getValue(const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc) const override
Definition: FilePosProvider.h:45
std::unique_ptr< IValueProvider > duplicate() const override
Definition: FilePosProvider.h:25
FilePosProvider(std::vector< std::unique_ptr< IValueProvider >> &&parameters)
Definition: FilePosProvider.h:20
std::string getName() const override
Definition: FilePosProvider.h:51
joda::query::IValueType getReturnType() const override
Definition: FilePosProvider.h:55
RJValue getAtomValue(const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc) const override
Definition: FilePosProvider.h:31
bool isConst() const override
Definition: FilePosProvider.h:29
Definition: IValueProvider.h:143
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: AttributeStatAggregator.h:12
IValueType
Definition: IValueProvider.h:33
@ IV_Number
Definition: IValueProvider.h:35