A base class for thread-safe json data files.  
 More...
#include <jsonfilebase.h>
 | 
| bool  | contains (const std::string &key) const noexcept | 
|   | Gets whether or not the json object contains a key.  
  | 
| template<SupportedJsonValue T>  | 
| T  | get (const std::string &key, const T &defaultValue) const noexcept | 
|   | Gets a value from the json object.  
  | 
| template<SupportedJsonValue T>  | 
| void  | set (const std::string &key, const T &value) noexcept | 
|   | Sets a value in the json object.  
  | 
A base class for thread-safe json data files. 
 
◆ JsonFileBase()
      
        
          | Nickvision::Helpers::JsonFileBase::JsonFileBase  | 
          ( | 
          const std::filesystem::path & |           path | ) | 
           | 
        
      
 
Constructs a JsonFileBase, loading the file from disk. 
- Parameters
 - 
  
    | path | The path to the json file  | 
  
   
- Exceptions
 - 
  
    | std::invalid_argument | Thrown if the path is empty  | 
  
   
 
 
◆ ~JsonFileBase()
  
  
      
        
          | virtual Nickvision::Helpers::JsonFileBase::~JsonFileBase  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
virtualdefaultnoexcept   | 
  
 
 
◆ contains()
  
  
      
        
          | bool Nickvision::Helpers::JsonFileBase::contains  | 
          ( | 
          const std::string & |           key | ) | 
           const | 
         
       
   | 
  
protectednoexcept   | 
  
 
Gets whether or not the json object contains a key. 
 
 
◆ get()
template<SupportedJsonValue T> 
  
  
      
        
          | T Nickvision::Helpers::JsonFileBase::get  | 
          ( | 
          const std::string & |           key,  | 
         
        
           | 
           | 
          const T & |           defaultValue ) const | 
         
       
   | 
  
inlineprotectednoexcept   | 
  
 
Gets a value from the json object. 
- Template Parameters
 - 
  
    | T | The type of the value to get  | 
  
   
- Parameters
 - 
  
    | key | The key of the value to get  | 
    | defaultValue | The default value to return if the key is not found or if the value is not of the expected type  | 
  
   
- Returns
 - The value associated with the key 
 
 
 
◆ getPath()
  
  
      
        
          | const std::filesystem::path & Nickvision::Helpers::JsonFileBase::getPath  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
noexcept   | 
  
 
Gets the path of the json file. 
- Returns
 - The path of the json file 
 
 
 
◆ save()
  
  
      
        
          | bool Nickvision::Helpers::JsonFileBase::save  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
noexcept   | 
  
 
Saves the config file to disk. 
- Returns
 - True if saved to disk, else false 
 
 
 
◆ saved()
Gets the Saved event. 
- Returns
 - The Saved event 
 
 
 
◆ set()
template<SupportedJsonValue T> 
  
  
      
        
          | void Nickvision::Helpers::JsonFileBase::set  | 
          ( | 
          const std::string & |           key,  | 
         
        
           | 
           | 
          const T & |           value ) | 
         
       
   | 
  
inlineprotectednoexcept   | 
  
 
Sets a value in the json object. 
- Template Parameters
 - 
  
    | T | The type of the value to set  | 
  
   
- Parameters
 - 
  
    | key | The key of the value to set  | 
    | value | The value to set  | 
  
   
 
 
◆ toJson()
  
  
      
        
          | boost::json::value Nickvision::Helpers::JsonFileBase::toJson  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
overridevirtualnoexcept   | 
  
 
 
The documentation for this class was generated from the following file: