JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
As_State.h
Go to the documentation of this file.
1 //
2 // Created by Nico on 08/05/2019.
3 //
4 
5 #ifndef JODA_AS_STATE_H
6 #define JODA_AS_STATE_H
7 
8 #include <glog/logging.h>
12 #include "Query_State.h"
14 
16 
17 struct asState {
18  template <typename Input>
19  inline asState(const Input &in, queryState &qs) {
20  fun = NOPROJ;
21  }
22 
23  template <typename Input>
24  inline void success(const Input &in, queryState &qs) {
25  if (setprojs.empty() && projs.size() == 1 &&
26  projs.front()->toString() == "*")
27  return; // If AS is only "*", then do not pass on projections
28  for (auto &proj : projs) {
29  qs.q->addProjection(std::move(proj));
30  }
31  for (auto &&proj : setprojs) {
32  qs.q->addProjection(std::move(proj));
33  }
34  }
35 
36  inline bool putValProv(std::unique_ptr<joda::query::IValueProvider> &&val) {
37  assert(val != nullptr && "Should not pass nullptr");
38  if (val == nullptr) return false;
39  if (valprov == nullptr) {
40  valprov = std::move(val);
41  return true;
42  }
43  DCHECK(false) << "Should not be full";
44  return false;
45  }
46 
47  std::string toPointer;
49  std::unique_ptr<joda::query::IValueProvider> valprov;
50  std::vector<std::unique_ptr<joda::query::IProjector>> projs;
51  std::vector<std::unique_ptr<joda::query::ISetProjector>> setprojs;
52 };
53 } // namespace joda::queryparsing::grammar
54 #endif // JODA_AS_STATE_H
projFun
Definition: As_State.h:15
@ NOPROJ
Definition: As_State.h:15
@ allCopyProj
Definition: As_State.h:15
@ arrFlatProj
Definition: As_State.h:15
@ valProvProj
Definition: As_State.h:15
Definition: As_State.h:17
std::vector< std::unique_ptr< joda::query::ISetProjector > > setprojs
Definition: As_State.h:51
void success(const Input &in, queryState &qs)
Definition: As_State.h:24
bool putValProv(std::unique_ptr< joda::query::IValueProvider > &&val)
Definition: As_State.h:36
asState(const Input &in, queryState &qs)
Definition: As_State.h:19
projFun fun
Definition: As_State.h:48
std::string toPointer
Definition: As_State.h:47
std::unique_ptr< joda::query::IValueProvider > valprov
Definition: As_State.h:49
std::vector< std::unique_ptr< joda::query::IProjector > > projs
Definition: As_State.h:50
Definition: Query_State.h:21
std::shared_ptr< joda::query::Query > q
Definition: Query_State.h:33