Uniot Core
0.8.1
Loading...
Searching...
No Matches
uniot::CBORStorage Class Reference

#include <CBORStorage.h>

Inheritance diagram for uniot::CBORStorage:
[legend]

Public Member Functions

 CBORStorage (const String &path)
 Constructs a new CBORStorage object.
 
virtual ~CBORStorage ()
 Virtual destructor.
 
CBORObjectobject ()
 Get access to the underlying CBORObject.
 
virtual bool store () override
 Store the CBOR object to the filesystem.
 
virtual bool restore () override
 Restore the CBOR object from the filesystem.
 
virtual bool clean () override
 Clean the CBOR object and remove the storage file.
 
- Public Member Functions inherited from uniot::Storage
 Storage (const String &path)
 Constructs a Storage object for a specific file.
 
virtual ~Storage ()
 Destructor.
 

Protected Attributes

CBORObject mCbor
 The CBOR object used for data serialization/deserialization.
 
- Protected Attributes inherited from uniot::Storage
Bytes mData
 The byte array containing the data to be stored or the loaded data.
 
String mPath
 The file path where data is stored.
 

Additional Inherited Members

- Static Public Member Functions inherited from uniot::Storage
static void unmount ()
 Explicitly unmounts the filesystem.
 
- Protected Member Functions inherited from uniot::Storage
void setPath (const String &path)
 Sets the file path, ensuring it starts with "/".
 

Constructor & Destructor Documentation

◆ CBORStorage()

uniot::CBORStorage::CBORStorage ( const String & path)
inline

Constructs a new CBORStorage object.

Parameters
pathThe filesystem path where the CBOR data will be stored

◆ ~CBORStorage()

virtual uniot::CBORStorage::~CBORStorage ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

◆ clean()

virtual bool uniot::CBORStorage::clean ( )
inlineoverridevirtual

Clean the CBOR object and remove the storage file.

Resets the CBOR object to its initial state and removes the associated file.

Return values
trueClean operation was successful
falseClean operation failed (e.g., file system error)

Reimplemented from uniot::Storage.

Reimplemented in uniot::WifiStorage.

◆ object()

CBORObject & uniot::CBORStorage::object ( )
inline

Get access to the underlying CBORObject.

Return values
CBORObject&The internal CBOR object

◆ restore()

virtual bool uniot::CBORStorage::restore ( )
inlineoverridevirtual

Restore the CBOR object from the filesystem.

Loads data from storage and deserializes it into the CBOR object.

Return values
trueRestoration operation was successful
falseRestoration operation failed (e.g., file system error)

Reimplemented from uniot::Storage.

Reimplemented in uniot::Credentials, uniot::Date, uniot::NetworkController, and uniot::WifiStorage.

◆ store()

virtual bool uniot::CBORStorage::store ( )
inlineoverridevirtual

Store the CBOR object to the filesystem.

Checks if the CBOR object has been modified (is dirty), and if so, serializes it and persists the data to storage.

Return values
trueStorage operation was successful
falseStorage operation failed (e.g., file system error)

Reimplemented from uniot::Storage.

Reimplemented in uniot::Credentials, uniot::Date, uniot::LispDevice, uniot::NetworkController, and uniot::WifiStorage.

Member Data Documentation

◆ mCbor

CBORObject uniot::CBORStorage::mCbor
protected

The CBOR object used for data serialization/deserialization.


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