libdisplaydevice latest
C++ library to modify display devices.
display_device::FileSettingsPersistence Class Reference

Implementation of the SettingsPersistenceInterface, that saves/loads the persistent settings to/from the file. More...

#include <src/common/include/display_device/file_settings_persistence.h>

Inheritance diagram for display_device::FileSettingsPersistence:
[legend]
Collaboration diagram for display_device::FileSettingsPersistence:
[legend]

Public Member Functions

bool clear () override
 
 FileSettingsPersistence (std::filesystem::path filepath)
 
std::optional< std::vector< std::uint8_t > > load () const override
 
bool store (const std::vector< std::uint8_t > &data) override
 
- Public Member Functions inherited from display_device::SettingsPersistenceInterface
virtual ~SettingsPersistenceInterface ()=default
 Default virtual destructor.
 

Detailed Description

Implementation of the SettingsPersistenceInterface, that saves/loads the persistent settings to/from the file.

Constructor & Destructor Documentation

◆ FileSettingsPersistence()

display_device::FileSettingsPersistence::FileSettingsPersistence ( std::filesystem::path filepath)
explicit

Default constructor. Does not perform any operations on the file yet.

Parameters
filepathA non-empty filepath. Throws on empty.

Member Function Documentation

◆ clear()

bool display_device::FileSettingsPersistence::clear ( )
nodiscardoverridevirtual

Remove the file specified in constructor (if it exists).

See also
SettingsPersistenceInterface::clear for more details.

Implements display_device::SettingsPersistenceInterface.

◆ load()

std::optional< std::vector< std::uint8_t > > display_device::FileSettingsPersistence::load ( ) const
nodiscardoverridevirtual

Read the data from the file specified in constructor.

Note
If file does not exist, an empty data list will be returned instead of null optional.
See also
SettingsPersistenceInterface::load for more details.

Implements display_device::SettingsPersistenceInterface.

◆ store()

bool display_device::FileSettingsPersistence::store ( const std::vector< std::uint8_t > & data)
nodiscardoverridevirtual

Store the data in the file specified in constructor.

Warning
The method does not create missing directories!
See also
SettingsPersistenceInterface::store for more details.

Implements display_device::SettingsPersistenceInterface.


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