Abstract base class of all storage methods.
More...
#include <CloudConfigRK.h>
|
| CloudConfigStorage () |
| Constructor. Base class constructor is empty.
|
|
bool | hasJsonData () const |
| Returns true if there is JSON data field is not empty.
|
|
virtual CloudConfigDataHeader * | getDataHeader () |
| Gets a pointer to the data header. More...
|
|
virtual const char *const | getJsonData () const =0 |
| Gets a const pointer to the JSON data. More...
|
|
virtual void | setup ()=0 |
| Called from setup(). Optional. Only needed if the storage method wants setup processing time.
|
|
virtual void | parse () |
| Called after the JSON data is updated to parse the data using the JSON parser. More...
|
|
virtual void | loop () |
| Called from loop(). Optional. Only needed if the storage method wants loop processing time.
|
|
JSONValue | getJSONValue () |
| Gets the top level (outer) JSONValue object. More...
|
|
JSONValue | getJSONValueForKey (const char *key) |
| Gets the value for a given key in the top-level outer JSON object. More...
|
|
JSONValue | getJSONValueAtIndex (size_t index) |
| Gets the value for a given index in the a JSON array in the top-level outer JSON array. More...
|
|
virtual bool | updateData (const char *json) |
| This method is called to update the data in storage method and parse it again. More...
|
|
|
static JSONValue | getJSONValueForKey (JSONValue parentObj, const char *key) |
| Gets the value for a given key in the a JSON object. More...
|
|
static JSONValue | getJSONValueAtIndex (JSONValue parentObj, size_t index) |
| Gets the value for a given index in the a JSON array. More...
|
|
|
JSONValue | jsonObj |
| The JSONValue object for the outermost JSON object (or array) More...
|
|
Abstract base class of all storage methods.
All storage methods are subclasses of either CloudStorage directly (CloudStorageStatic) or of CloudConfigStorageData (everything else, like CloudStorageEEPROM, CloudStorageRetained, or CloudStorageFile).
◆ getDataHeader()
Gets a pointer to the data header.
This is only available in classes derived from CloudConfigStorageData, which is all of them except CloudConfigDataStatic, which is not updateable and therefore does not need the structure.
Reimplemented in CloudConfigStorageData.
◆ getJsonData()
virtual const char* const CloudConfigStorage::getJsonData |
( |
| ) |
const |
|
pure virtual |
Gets a const pointer to the JSON data.
The CloudConfigStorageData class has an overload that can get a mutable pointer so the data can be updated, but this base class does not have one, because the CloudConfigDataStatic can't update the data in program flash from the device.
Implemented in CloudConfigStorageStatic, and CloudConfigStorageData.
◆ getJSONValue()
JSONValue CloudConfigStorage::getJSONValue |
( |
| ) |
|
|
inline |
Gets the top level (outer) JSONValue object.
This is typically an object, but could be an array.
◆ getJSONValueAtIndex() [1/2]
JSONValue CloudConfigStorage::getJSONValueAtIndex |
( |
JSONValue |
parentObj, |
|
|
size_t |
index |
|
) |
| |
|
static |
Gets the value for a given index in the a JSON array.
- Parameters
-
parentObj | A JSONValue for a JSON object to look in |
index | 0 = first entry, 1 = second entry, ... |
- Returns
- A JSONValue object for that key. If the key does not exist in that object, an empty JSONValue object that returns false for isValid() is returned.
There is no call to determine the length of the array; iterate until an invalid object is returned.
◆ getJSONValueAtIndex() [2/2]
JSONValue CloudConfigStorage::getJSONValueAtIndex |
( |
size_t |
index | ) |
|
|
inline |
Gets the value for a given index in the a JSON array in the top-level outer JSON array.
- Parameters
-
index | 0 = first entry, 1 = second entry, ... |
- Returns
- A JSONValue object for that key. If the key does not exist in that object, an empty JSONValue object that returns false for isValid() is returned.
This method is not commonly used because the top-level object is usually a JSON object (surrounded by { }) not a JSON array (surrounded by [ ]).
There is no call to determine the length of the array; iterate until an invalid object is returned.
◆ getJSONValueForKey() [1/2]
JSONValue CloudConfigStorage::getJSONValueForKey |
( |
const char * |
key | ) |
|
|
inline |
Gets the value for a given key in the top-level outer JSON object.
- Parameters
-
key | The name of the key-value pair |
- Returns
- A JSONValue object for that key. If the key does not exist in that object, an empty JSONValue object that returns false for isValid() is returned.
◆ getJSONValueForKey() [2/2]
JSONValue CloudConfigStorage::getJSONValueForKey |
( |
JSONValue |
parentObj, |
|
|
const char * |
key |
|
) |
| |
|
static |
Gets the value for a given key in the a JSON object.
- Parameters
-
parentObj | A JSONValue for a JSON object to look in |
key | The name of the key-value pair |
- Returns
- A JSONValue object for that key. If the key does not exist in that object, an empty JSONValue object that returns false for isValid() is returned.
◆ parse()
virtual void CloudConfigStorage::parse |
( |
| ) |
|
|
inlinevirtual |
Called after the JSON data is updated to parse the data using the JSON parser.
You normally don't need to override this, but it is virtual in case you do.
◆ updateData()
virtual bool CloudConfigStorage::updateData |
( |
const char * |
json | ) |
|
|
inlinevirtual |
◆ jsonObj
JSONValue CloudConfigStorage::jsonObj |
|
protected |
The documentation for this class was generated from the following files: