PerSt Pile   version 0.0.1
Persistent storage pile used for storing key/value pairs
perst.h
Go to the documentation of this file.
1 
10 #ifndef GUARD_PERST_H_INCLUDE
11 #define GUARD_PERST_H_INCLUDE
12 
13 #include <perst/perst-config.h>
14 #include <perst/perst_interface.h>
15 
17 class PERST_EXPORT PerSt : public PerstInterface {
18 
19 public:
20  struct KbData;
21 
23  enum EntryType {
26  EVALUE
27  };
28 
33  KBFER_SKIP_KIDS
34  };
35 
37  typedef KbForEachResult (*kbForEach) (
38  KbData * data,
39  const PERST_STRING & name,
40  EntryType kind);
41 
43  struct KbData {
44  kbForEach group_start_;
45  kbForEach group_end_;
46  kbForEach array_start_;
47  kbForEach array_end_;
48  kbForEach value_;
49  void * opaque_;
50  };
51 
52 protected:
53 
55  PerSt ();
56 
57 public:
58 
60  virtual ~PerSt();
61 
63  virtual PERST_STRING location () {
64  return location_;
65  }
66 
68  int
69  arrayIndex () const {
70  return array_index_;
71  }
72 
74  PERST_STRING
75  group () const {
76  return current_group_name_;
77  }
78 
80  PERST_SLIST
81  groupPath () const {
82  return current_group_path_;
83  }
84 
85 protected:
86 
88  bool
89  setArrayIndexInternal (
90  int value);
91 
93  bool endArrayInternal (
94  const PERST_STRING & name);
95 
97  bool
98  beginGroupInternal (
99  const PERST_STRING & name);
100 
102  bool
103  endGroupInternal (
104  const PERST_STRING &name = "");
105 
107  bool
108  preSaveValue (
109  const PERST_STRING & name);
110 
111 
113  virtual void setLocation (
114  const PERST_STRING & value) {
115  location_ = value;
116  }
117 
118 private:
119  PERST_STRING location_;
121  PERST_SLIST current_group_path_;
123  PERST_STRING current_group_name_;
124  int array_index_;
125  std::list<int> array_indices_;
126 };
127 
128 #endif // GUARD_PERST_H_INCLUDE
PERST_SLIST groupPath() const
Tell the full path of current group (arrays are also groups).
Definition: perst.h:81
PERST_STRING group() const
Tell the name of current group (arrays are also groups).
Definition: perst.h:75
Definition: perst.h:25
int arrayIndex() const
Get current index of an array.
Definition: perst.h:69
Interface class for persistent storage.
Definition: perst_interface.h:17
Structure used for iterating the whole tree.
Definition: perst.h:43
Definition: perst.h:31
KbForEachResult
Values that the kbForEach can return.
Definition: perst.h:30
EntryType
Indicate the type of an entry.
Definition: perst.h:23
Interface class for persistent storage.
Definition: perst.h:17
Definition: perst.h:24
virtual PERST_STRING location()
Storage location.
Definition: perst.h:63
virtual void setLocation(const PERST_STRING &value)
Storage location.
Definition: perst.h:113
Definition: perst.h:32