libnick 2024.9.2
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
Nickvision::App::DataFileBase Class Reference

A base class for json data files. More...

#include <datafilebase.h>

Public Member Functions

 DataFileBase (const std::string &key, const std::string &appName)
 Constructs a DataFileBase, loading the file from disk.
 
virtual ~DataFileBase ()=default
 Destructs a DataFileBase.
 
const std::string & getKey () const
 
Events::Event< Events::EventArgs > & saved ()
 Gets the Saved event.
 
bool save ()
 Saves the config file to disk.
 

Protected Attributes

boost::json::object m_json
 

Detailed Description

A base class for json data files.

Constructor & Destructor Documentation

◆ DataFileBase()

Nickvision::App::DataFileBase::DataFileBase ( const std::string & key,
const std::string & appName )

Constructs a DataFileBase, loading the file from disk.

Parameters
keyThe key of the config file
appNameThe name of the application the data file belongs to
Exceptions
std::invalid_argumentThrown if key is empty
std::invalid_argumentThrown if appName is empty

◆ ~DataFileBase()

virtual Nickvision::App::DataFileBase::~DataFileBase ( )
virtualdefault

Destructs a DataFileBase.

Member Function Documentation

◆ getKey()

const std::string & Nickvision::App::DataFileBase::getKey ( ) const

Gets the key of the config file.

Returns
The key of the config file

◆ save()

bool Nickvision::App::DataFileBase::save ( )

Saves the config file to disk.

Returns
True if saved to disk, else false

◆ saved()

Events::Event< Events::EventArgs > & Nickvision::App::DataFileBase::saved ( )

Gets the Saved event.

Returns
The Saved event

Member Data Documentation

◆ m_json

boost::json::object Nickvision::App::DataFileBase::m_json
mutableprotected

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