CloudConfigRK
|
Abstract base class of all storage methods that use a CloudConfigData structure. More...
#include <CloudConfigRK.h>
Public Member Functions | |
CloudConfigStorageData () | |
Default constructor. | |
CloudConfigStorageData (CloudConfigDataHeader *header, size_t dataSize) | |
Constructor with header. More... | |
CloudConfigStorageData & | withData (CloudConfigDataHeader *header, size_t dataSize) |
Specify the data header and data location. More... | |
virtual CloudConfigDataHeader * | getDataHeader () |
Gets a pointer to the CloudConfigDataHeader structure. | |
void | validate () |
Validate the CloudConfigDataHeader. More... | |
const char *const | getJsonData () const |
Gets a pointer to the JSON data for reading (const) More... | |
size_t | getMaxJsonDataSize () const |
Returns the maximum size of the JSON data in characters. More... | |
char * | getJsonData () |
Gets a pointer to the JSON data for writing (not const) More... | |
size_t | getTotalSize () const |
Gets the total size of the buffer including both the header and the JSON data. More... | |
virtual bool | updateData (const char *json) |
This method is called after subclasses update the JSON data. More... | |
virtual bool | save ()=0 |
Save the data in the storage subclass. Must be implemented in subclasses! More... | |
Public Member Functions inherited from CloudConfigStorage | |
CloudConfigStorage () | |
Constructor. Base class constructor is empty. | |
bool | hasJsonData () const |
Returns true if there is JSON data field is not empty. | |
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... | |
Protected Attributes | |
CloudConfigDataHeader * | header |
Pointer to the header with data after it. | |
size_t | dataSize |
Size of the JSON data, not including sizeof(CloudConfigDataHeader) | |
Protected Attributes inherited from CloudConfigStorage | |
JSONValue | jsonObj |
The JSONValue object for the outermost JSON object (or array) More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from CloudConfigStorage | |
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... | |
Protected Member Functions inherited from CloudConfigStorage | |
virtual | ~CloudConfigStorage () |
Destructor. Base class destructor is empty. Also, you can't delete one of these. | |
CloudConfigStorage (const CloudConfigStorage &)=delete | |
This class is not copyable. | |
CloudConfigStorage & | operator= (const CloudConfigStorage &)=delete |
This class is not copyable. | |
Abstract base class of all storage methods that use a CloudConfigData structure.
Classes that include a CloudConfigDataHeader (Retained, EEPROM, File) all use this class as a base class as it contains handy common features that simplify those implementations.
CloudConfigStorageData::CloudConfigStorageData | ( | CloudConfigDataHeader * | header, |
size_t | dataSize | ||
) |
Constructor with header.
This constructor is basically the same as using the default contructor then using withData()
header | The pointer to the CloudConfigDataHeader structure |
dataSize | The size of the data after the header. The total size is sizeof(CloudConfigDataHeader) + dataSize. |
char* CloudConfigStorageData::getJsonData | ( | ) |
Gets a pointer to the JSON data for writing (not const)
This is right after the CloudConfigDataHeader structure. This method is not available on all storage classes. For example, CloudStorageStatic stores the data in program flash, so it can't be written to.
|
virtual |
Gets a pointer to the JSON data for reading (const)
This is right after the CloudConfigDataHeader structure.
Implements CloudConfigStorage.
|
inline |
Returns the maximum size of the JSON data in characters.
The buffer is one byte larger than this because there is always a trailling null to make it a c-string.
|
inline |
Gets the total size of the buffer including both the header and the JSON data.
This is the buffer size; the actual JSON string could be shorter as it's variable length.
|
pure virtual |
Save the data in the storage subclass. Must be implemented in subclasses!
Implemented in CloudConfigStorageFile< SIZE >, CloudConfigStorageEEPROM< SIZE >, and CloudConfigStorageRetained.
|
virtual |
This method is called after subclasses update the JSON data.
The default implementation in this class is usually sufficient, but it can be overridden by subclasses if necessary.
Reimplemented from CloudConfigStorage.
void CloudConfigStorageData::validate | ( | ) |
Validate the CloudConfigDataHeader.
If not valid, then resets the entire structure to default values. This is common when the structure is first initialized.
CloudConfigStorageData & CloudConfigStorageData::withData | ( | CloudConfigDataHeader * | header, |
size_t | dataSize | ||
) |
Specify the data header and data location.
header | The pointer to the CloudConfigDataHeader structure |
dataSize | The size of the data after the header. The total size is sizeof(CloudConfigDataHeader) + dataSize. |