Move Config constructor to header.

This commit is contained in:
tastytea 2020-03-06 05:43:45 +01:00
parent d99520c2ea
commit f5c53df354
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 9 additions and 9 deletions

View File

@ -17,6 +17,8 @@
#ifndef FEDIPOTATO_CONFIG_HPP
#define FEDIPOTATO_CONFIG_HPP
#include "directories.hpp"
#include <nlohmann/json.hpp>
#if __has_include(<filesystem>)
@ -58,7 +60,13 @@ public:
*
* @since 0.1.0
*/
explicit Config(string_view application_name, string_view filename);
explicit Config(const string_view application_name,
const string_view filename)
: _filename{filename}
, _filepath{Directories(application_name).config() /= filename}
{
read();
}
//! Copy constructor
Config(const Config &other) = default;

View File

@ -15,7 +15,6 @@
*/
#include "config.hpp"
#include "directories.hpp"
#include <fstream>
#include <iomanip>
@ -27,13 +26,6 @@ using std::ifstream;
using std::ofstream;
using std::setw;
Config::Config(const string_view application_name, const string_view filename)
: _filename{filename}
, _filepath{Directories(application_name).config() /= filename}
{
read();
}
void Config::read()
{
if (!fs::exists(_filepath))