PerSt Pile   version 0.0.1
Persistent storage pile used for storing key/value pairs
PerSt Class Reference

Interface class for persistent storage. More...

#include <perst.h>

+ Inheritance diagram for PerSt:

Classes

struct  KbData
 Structure used for iterating the whole tree. More...
 

Public Types

enum  EntryType { EGROUP, EARRAY, EVALUE }
 Indicate the type of an entry. More...
 
enum  KbForEachResult { KBFER_CONTINUE, KBFER_BREAK, KBFER_SKIP_KIDS }
 Values that the kbForEach can return. More...
 
typedef KbForEachResult(* kbForEach) (KbData *data, const PERST_STRING &name, EntryType kind)
 Callback used for iteration; use false to terminate.
 

Public Member Functions

virtual ~PerSt ()
 Destructor. More...
 
virtual PERST_STRING location ()
 Storage location.
 
int arrayIndex () const
 Get current index of an array.
 
PERST_STRING group () const
 Tell the name of current group (arrays are also groups).
 
PERST_SLIST groupPath () const
 Tell the full path of current group (arrays are also groups).
 
- Public Member Functions inherited from PerstInterface
virtual bool beginGroup (const PERST_STRING &name)=0
 Starts a group; internal state is altered.
 
virtual bool endGroup (const PERST_STRING &name="")=0
 Ends a group; internal state is altered.
 
virtual bool beginWriteArray (const PERST_STRING &name, int predicted_count=-1)=0
 Starts writing an array; internal state is altered.
 
virtual int beginReadArray (const PERST_STRING &name)=0
 Starts reading an array; internal state is altered.
 
virtual bool endArray (const PERST_STRING &name="")=0
 Ends an array; internal state is altered.
 
virtual bool setArrayIndex (int index)=0
 Set current index of an array.
 
virtual bool hasKey (const PERST_STRING &name)=0
 Tell if a given key exists (relative to current group).
 
virtual bool hasKey (const PERST_SLIST &name)=0
 Tell if a given path exists (relative to current group).
 
virtual PERST_STRING valueS (const PERST_STRING &name)=0
 Get the string value for a key; the value type MUST be string.
 
virtual PERST_SLIST valueSList (const PERST_STRING &name)=0
 Get the string list for a key; the value type MUST be an array of strings.
 
virtual int64_t valueInt (const PERST_STRING &name)=0
 Get the integer value for a key; the value type MUST be integer.
 
virtual uint64_t valueUInt (const PERST_STRING &name)=0
 Get the integer value for a key; the value type MUST be integer.
 
virtual double valueDbl (const PERST_STRING &name)=0
 Get the real value for a key; the value type MUST be real.
 
PERST_STRING valueS (const PERST_STRING &name, const PERST_STRING &default_val)
 Get the string value for a key; the value type MUST be string.
 
PERST_SLIST valueSList (const PERST_STRING &name, const PERST_SLIST &default_val)
 Get the string list for a key; the value type MUST be an array of strings.
 
int64_t valueInt (const PERST_STRING &name, int64_t default_val)
 Get the integer value for a key; the value type MUST be integer.
 
uint64_t valueUInt (const PERST_STRING &name, uint64_t default_val)
 Get the integer value for a key; the value type MUST be integer.
 
double valueDbl (const PERST_STRING &name, double default_val)
 Get the real value for a key; the value type MUST be real.
 
virtual bool setValue (const PERST_STRING &name, const PERST_STRING &value)=0
 Set the string value for a key.
 
virtual bool setValue (const PERST_STRING &name, const PERST_SLIST &value)=0
 Set the string list for a key.
 
virtual bool setValue (const PERST_STRING &name, int64_t value)=0
 Set the integer value for a key.
 
virtual bool setValue (const PERST_STRING &name, uint64_t value)=0
 Set the integer value for a key.
 
virtual bool setValue (const PERST_STRING &name, int value)
 Set the integer value for a key.
 
virtual bool setValue (const PERST_STRING &name, double value)=0
 Set the real value for a key.
 

Protected Member Functions

 PerSt ()
 Default constructor. More...
 
bool setArrayIndexInternal (int value)
 Alters internal state by appending the group name. More...
 
bool endArrayInternal (const PERST_STRING &name)
 Alters internal state by removing last group name. More...
 
bool beginGroupInternal (const PERST_STRING &name)
 Alters internal state by appending the group name. More...
 
bool endGroupInternal (const PERST_STRING &name="")
 Alters internal state by removing last group name. More...
 
bool preSaveValue (const PERST_STRING &name)
 Makes sure that a value can be saved. More...
 
virtual void setLocation (const PERST_STRING &value)
 Storage location.
 

Detailed Description

Interface class for persistent storage.

The string type is currently either QString, if Qt is available, or std::string.

The class maintains an internal group path; as a result even read methods are not const.

Member Enumeration Documentation

Indicate the type of an entry.

Enumerator
EGROUP 

The entry is a group.

EARRAY 

The entry is an array.

EVALUE 

The entry is a value.

Values that the kbForEach can return.

Enumerator
KBFER_CONTINUE 

Normal return, iteration continues.

KBFER_BREAK 

Break iteration, exit immediatelly.

KBFER_SKIP_KIDS 

Same as continue but skip kids, if any.

Constructor & Destructor Documentation

PerSt::PerSt ( )
protected

Default constructor.

Only the implementation is allowed to use the constructor.

PerSt::~PerSt ( )
virtual

Destructor.

Member Function Documentation

bool PerSt::beginGroupInternal ( const PERST_STRING &  name)
protected

Alters internal state by appending the group name.

Returns
false if the name is empty, true otherwise.
bool PerSt::endArrayInternal ( const PERST_STRING &  name)
protected

Alters internal state by removing last group name.

The method ends the group with the index as name.

Returns
false if we're not inside an array.
bool PerSt::endGroupInternal ( const PERST_STRING &  name = "")
protected

Alters internal state by removing last group name.

Returns
false if we're at the root or the name does not match, true otherwise.
bool PerSt::preSaveValue ( const PERST_STRING &  name)
protected

Makes sure that a value can be saved.

Returns
false if no group is defined or name is empty.
bool PerSt::setArrayIndexInternal ( int  value)
protected

Alters internal state by appending the group name.

PerSt::beginGroup PerSt::endGroup PerSt::beginWriteArray PerSt::beginReadArray PerSt::endArray PerSt::arrayIndex PerSt::setArrayIndex PerSt::group PerSt::groupPath PerSt::hasKey(PERST_STRING) PerSt::hasKey(PERST_SLIST) PerSt::valueS PerSt::valueSList PerSt::valueInt PerSt::valueDbl PerSt::setValueThe method begins a new group with the index as name.

Returns
false if the index is negative.

The documentation for this class was generated from the following files: