libnick 2024.9.2
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
datafilebase.h
Go to the documentation of this file.
1
23#ifndef DATAFILEBASE_H
24#define DATAFILEBASE_H
25
26#include <filesystem>
27#include <string>
28#include <boost/json.hpp>
29#include "events/event.h"
30
31namespace Nickvision::App
32{
37 {
38 public:
46 DataFileBase(const std::string& key, const std::string& appName);
50 virtual ~DataFileBase() = default;
55 const std::string& getKey() const;
65 bool save();
66
67 protected:
68 mutable boost::json::object m_json;
69
70 private:
71 std::string m_key;
72 std::filesystem::path m_path;
74 };
75}
76
77#endif //DATAFILEBASE_H
A base class for json data files.
Definition datafilebase.h:37
DataFileBase(const std::string &key, const std::string &appName)
Constructs a DataFileBase, loading the file from disk.
const std::string & getKey() const
Events::Event< Events::EventArgs > & saved()
Gets the Saved event.
boost::json::object m_json
Definition datafilebase.h:68
virtual ~DataFileBase()=default
Destructs a DataFileBase.
bool save()
Saves the config file to disk.
An event that can have handlers subscribe to it, which in turn will be called when the event is invok...
Definition event.h:49
Definition appinfo.h:32