Files class introduces an abstraction of the filesystem api, and json parsing. This class handles reading and writing to JSON configuration files for the persistent data (Alarms, Timers, Stopwatches) within the application.
More...
#include <files.h>
|
| Files () |
| Files constructor takes in no parameters and executes no initializing logic.
|
|
std::vector< TimerData > | getTimers () |
| getTimers takes in no parameters. This method is made to fetch timers stored from a configuration file which is either existing or being created by the application and returns them to the caller of the method or an empty vector
|
|
void | saveTimers (const std::vector< TimerData > ×) |
|
std::vector< AlarmData > | getAlarms () |
| getAlarms takes in no parameters. This method is made to fetch alarms from a configuration file which is either existing or being created by the application and returns them to the caller of the method or an empty vector
|
|
|
std::string | getAppDataPath () |
| getAppDataPath returns the string that represents the file path which locates the configuration directory in storage for the application
|
|
nlohmann::json | deserializeJson (std::ifstream &inFile) |
| deserializeJson returns a valid JSON object
|
|
void | saveJsonToFile (const std::string &fileName, json j) |
| saveJsonToFile does as it says. It takes any json shape and saves it to a file found or created at the location provided in params
|
|
Files class introduces an abstraction of the filesystem api, and json parsing. This class handles reading and writing to JSON configuration files for the persistent data (Alarms, Timers, Stopwatches) within the application.
◆ Files()
Files constructor takes in no parameters and executes no initializing logic.
◆ deserializeJson()
json Files::deserializeJson |
( |
std::ifstream & | inFile | ) |
|
|
protected |
deserializeJson returns a valid JSON object
- Note
- json being returned can take any shape or form and must be checked by the caller
- Parameters
-
inFile | String reprisenting the path to the file which should be read from on the user's system |
◆ getAlarms()
std::vector< AlarmData > Files::getAlarms |
( |
| ) |
|
getAlarms takes in no parameters. This method is made to fetch alarms from a configuration file which is either existing or being created by the application and returns them to the caller of the method or an empty vector
- Returns
- A vector of AlarmData structures.
- See also
- AlarmData
alarmFileData return type { "error": boolean // did the read fail or not
"alarms": [ // array of AlarmData types
- See also
- AlarmData { "dow": int[], "time": { "hour": int, "minute": int }, "on": boolean, "meridiem": "string", "vibrate": { "on": boolean, "intensity": double } }, ... ] }
◆ getAppDataPath()
std::string Files::getAppDataPath |
( |
| ) |
|
|
inlineprotected |
getAppDataPath returns the string that represents the file path which locates the configuration directory in storage for the application
- Note
- This directory will be created if there is none in first search
◆ getTimers()
std::vector< TimerData > Files::getTimers |
( |
| ) |
|
getTimers takes in no parameters. This method is made to fetch timers stored from a configuration file which is either existing or being created by the application and returns them to the caller of the method or an empty vector
- Returns
- A vector of TimerData structures.
- See also
- TimerData
timerFileData json data structure { "error": boolean, "timers": [ // array of TimerData data.
- See also
- TimerData { "hours": int, "minutes": int, "seconds": int, "running": boolean, "paused": boolean }, ... ] }
◆ saveJsonToFile()
void Files::saveJsonToFile |
( |
const std::string & | fileName, |
|
|
json | j ) |
|
protected |
saveJsonToFile does as it says. It takes any json shape and saves it to a file found or created at the location provided in params
- Parameters
-
fileName | string representing the path to the file in question |
j | a valid json object taking any shape to be saved to the file |
◆ saveTimers()
void Files::saveTimers |
( |
const std::vector< TimerData > & | times | ) |
|
The documentation for this class was generated from the following files: