readded confs, some basic exception handling, and reworking conf now
This commit is contained in:
@@ -1,15 +1,28 @@
|
||||
#include "Conf.h"
|
||||
|
||||
class CONF_PLANPATH_INVALID: public std::runtime_error
|
||||
{
|
||||
public:
|
||||
CONF_PLANPATH_INVALID(): std::runtime_error("conf: The supplied path for the plan definition file is invalid.") {}
|
||||
};
|
||||
|
||||
class CONF_UNITSPATH_INVALID: public std::runtime_error
|
||||
{
|
||||
public:
|
||||
CONF_UNITSPATH_INVALID(): std::runtime_error("conf: The supplied path for the unit definition file is invalid.") {}
|
||||
};
|
||||
|
||||
|
||||
Conf::Conf( std::string filename ): JSON_Loader()
|
||||
{
|
||||
// Conf is always loaded from file.
|
||||
// load the conf file.
|
||||
this->load_json_file( filename, true );
|
||||
|
||||
// always load plan_path, it is required to function.
|
||||
this->get_key( this->plan_path, "plan_path", true, false );
|
||||
// find the path to the plan file
|
||||
if (! this->get_key( this->plan_path, "plan_path", true) ) { throw CONF_PLANPATH_INVALID(); }
|
||||
|
||||
// always load units_path, it is required to function.
|
||||
this->get_key( this->units_path, "units_path", true, false );
|
||||
// find the path to the unit definitions file
|
||||
if (! this->get_key( this->units_path, "units_path", true) ) { throw CONF_UNITSPATH_INVALID(); }
|
||||
};
|
||||
|
||||
std::string Conf::get_plan_path()
|
||||
|
||||
Reference in New Issue
Block a user