JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
ViewCursor.h
Go to the documentation of this file.
1 //
2 // Created by Nico on 27/08/2019.
3 //
4 
5 #ifndef JODA_VIEWCURSOR_H
6 #define JODA_VIEWCURSOR_H
7 
8 #include <joda/misc/RJFwd.h>
9 #include <memory>
10 #include <vector>
11 #include "ViewStructure.h"
12 
13 class ViewCursor {
14  public:
16  ViewObjectMember(const std::string &name, const RJValue *val)
17  : name(name), val(val){};
18 
19  ViewObjectMember(std::string &&name, const RJValue *val)
20  : name(std::move(name)), val(val){};
21  std::string name;
22  const RJValue *val;
23  };
24 
25  public:
26  ViewCursor(const RJValue *doc, ViewCursor *,
27  const std::vector<std::string> *viewPaths);
28  void followAtt(const std::string &attr);
29  void follow(const RJPointer &ptr);
30  void setNextDestination(const RJValue *nextDestination);
31  void unfollow();
32 
33  const RJValue *getVal() const;
34  const ViewCursor *getPreviousCursor() const;
35  bool isBase(const std::string &currPointer) const;
36  bool isShared(const std::string &currPointer) const;
37  void getOverwrites(
38  const std::string &curr,
39  std::vector<ViewCursor::ViewObjectMember> &previousOverwrites);
40 
41  void reset();
42 
43  private:
44  std::vector<const RJValue *> _stack;
45  ViewCursor *previousCursor;
46  const std::vector<std::string> *viewPaths;
47  const RJValue *nextDestination = nullptr;
48  bool nextDestinationSet = false;
49 };
50 
51 #endif // JODA_VIEWCURSOR_H
rapidjson::GenericPointer< RJValue, RJBaseAlloc > RJPointer
Definition: RJFwd.h:30
rapidjson::GenericValue< RJChar, RJMemoryPoolAlloc > RJValue
Definition: RJFwd.h:29
Definition: ViewCursor.h:13
void follow(const RJPointer &ptr)
Definition: ViewCursor.cpp:93
void unfollow()
Definition: ViewCursor.cpp:85
bool isBase(const std::string &currPointer) const
Definition: ViewCursor.cpp:120
bool isShared(const std::string &currPointer) const
Definition: ViewCursor.cpp:132
const ViewCursor * getPreviousCursor() const
Definition: ViewCursor.cpp:15
const RJValue * getVal() const
Definition: ViewCursor.cpp:13
ViewCursor(const RJValue *doc, ViewCursor *, const std::vector< std::string > *viewPaths)
Definition: ViewCursor.cpp:9
void getOverwrites(const std::string &curr, std::vector< ViewCursor::ViewObjectMember > &previousOverwrites)
Definition: ViewCursor.cpp:19
void reset()
Definition: ViewCursor.cpp:103
void setNextDestination(const RJValue *nextDestination)
Definition: ViewCursor.cpp:115
void followAtt(const std::string &attr)
Definition: ViewCursor.cpp:53
Definition: ViewCursor.h:15
std::string name
Definition: ViewCursor.h:20
ViewObjectMember(const std::string &name, const RJValue *val)
Definition: ViewCursor.h:16
ViewObjectMember(std::string &&name, const RJValue *val)
Definition: ViewCursor.h:19
const RJValue * val
Definition: ViewCursor.h:22