pushing local
This commit is contained in:
@@ -19,10 +19,10 @@ Conf::Conf( std::string filename ): JSON_Loader()
|
||||
this->load_json_file( filename, true );
|
||||
|
||||
// find the path to the plan file
|
||||
if ( this->get_key( this->plan_path, "plan_path", true) != 0 ) { throw CONF_PLANPATH_INVALID(); }
|
||||
if (this->get_serialized(this->plan_path, "plan_path", true) != 0 ) { throw CONF_PLANPATH_INVALID(); }
|
||||
|
||||
// find the path to the unit definitions file
|
||||
if ( this->get_key( this->units_path, "units_path", true) != 0 ) { throw CONF_UNITSPATH_INVALID(); }
|
||||
if (this->get_serialized(this->units_path, "units_path", true) != 0 ) { throw CONF_UNITSPATH_INVALID(); }
|
||||
};
|
||||
|
||||
std::string Conf::get_plan_path()
|
||||
|
||||
@@ -70,7 +70,7 @@ void JSON_Loader::load_json_string( std::string input, bool verbose )
|
||||
Json::Reader json_reader;
|
||||
|
||||
// the deserialized json type to contain what's read by the reader
|
||||
Json::Value json_root;
|
||||
// Json::Value json_root;
|
||||
|
||||
// create the ifstream file handle
|
||||
std::ifstream json_file_ifstream( input.c_str(), std::ifstream::binary );
|
||||
@@ -112,11 +112,11 @@ std::string JSON_Loader::as_string()
|
||||
return this->json_root.asString();
|
||||
}
|
||||
|
||||
// returns the string representation of the value of a key
|
||||
// returns the serialized representation of the value of a key
|
||||
// the Jason::Value object to assign the fetched value to
|
||||
// verbosity flag
|
||||
// exit or not on failure
|
||||
int JSON_Loader::get_key( Json::Value &input, std::string key, bool verbose)
|
||||
int JSON_Loader::get_serialized(Json::Value &input, std::string key, bool verbose)
|
||||
{
|
||||
// throw if the class is not ready to be used.
|
||||
if ( ! this->populated ) { throw JSON_Loader_NotReady(); }
|
||||
@@ -129,7 +129,6 @@ int JSON_Loader::get_key( Json::Value &input, std::string key, bool verbose)
|
||||
}
|
||||
|
||||
// key was not found
|
||||
// shouldn't the be handled further up?
|
||||
if ( verbose )
|
||||
{
|
||||
// verbose mode tells the user what key we were looking for.
|
||||
|
||||
@@ -27,10 +27,11 @@ class JSON_Loader
|
||||
void load_json_string( std::string input, bool verbose );
|
||||
|
||||
// return as a JSONCPP serialized object
|
||||
Json::Value as_serialized();
|
||||
std::string as_string();
|
||||
// deprecated -- these aren't really used.
|
||||
// Json::Value as_serialized();
|
||||
// std::string as_string();
|
||||
|
||||
// safely handle key retrieval (if we want it to be safe)
|
||||
int get_key( Json::Value &input, std::string key, bool verbose);
|
||||
// safely handle deserialized type retrieval (if we want it to be safe)
|
||||
int get_serialized(Json::Value &input, std::string key, bool verbose);
|
||||
};
|
||||
#endif //FTESTS_JLOADER_H
|
||||
|
||||
@@ -1,16 +1,28 @@
|
||||
#include "Suite.h"
|
||||
/*
|
||||
Suite::Suite( std::string filename ): JSON_Loader()
|
||||
/* Suite loads a file and deserializes the Unit JSON object to Unit types as a vector member
|
||||
* Suite { vector<Unit> }
|
||||
|
||||
Suite::Suite(): JSON_Loader()
|
||||
{
|
||||
load_file( filename );
|
||||
// empty
|
||||
};
|
||||
|
||||
void Suite::load_units_file( std::string filename, bool verbose )
|
||||
{
|
||||
// will use json_root staging buffer on each run to append to this->units vector as valid units are found.
|
||||
this->load_json_file( filename, verbose );
|
||||
|
||||
|
||||
// refill the json_root buffer with a json object in the
|
||||
if ( this->get_serialized( Json::Value jbuf, "units", verbose ) != 0)
|
||||
{
|
||||
this->json_root = jbuf;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int Suite::load_file(std::string filename): JSON_Loader( filename )
|
||||
{
|
||||
Json::Value raw_units = this->get_root()["units"];
|
||||
Json::Value raw_units = this->get_serialized("")
|
||||
for ( int index = 0; index < raw_units.size(); index++ )
|
||||
{
|
||||
this->units.push_back( Unit( raw_units[ index ] ) );
|
||||
@@ -20,7 +32,7 @@ int Suite::load_file(std::string filename): JSON_Loader( filename )
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Unit Suite::get_unit(std::string provided_name)
|
||||
/* Unit Suite::get_unit(std::string provided_name)
|
||||
|
||||
* returns a unit from a unitholder object by name
|
||||
* this will need reworked. maybe should return int, populate a pointer.
|
||||
@@ -47,4 +59,8 @@ Unit Suite::get_unit(std::string provided_name)
|
||||
}
|
||||
return * returnable;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
|
||||
ca
|
||||
@@ -9,15 +9,18 @@
|
||||
class Suite: public JSON_Loader
|
||||
{
|
||||
private:
|
||||
// storage for the definitions we are amassing from the unit definition files
|
||||
std::vector<Unit> units;
|
||||
|
||||
public:
|
||||
// constructor
|
||||
Suite( std::string filename );
|
||||
// constructor, empty
|
||||
Suite();
|
||||
|
||||
int load_file( std::string filename );
|
||||
// returns the unit type identified by name or null
|
||||
Unit get_unit(std::string provided_name);
|
||||
// load a unit definitions file and add valid unit definitions to this->units
|
||||
void load_units_file( std::string filename );
|
||||
|
||||
// returns the unit identified by name
|
||||
void get_unit(Unit & result, std::string provided_name);
|
||||
};
|
||||
|
||||
#endif //FTESTS_UNITS_H
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define FTESTS_LOADERS_H
|
||||
|
||||
#include "JSON_Loader.h"
|
||||
//#include "Suite.h"
|
||||
#include "Suite.h"
|
||||
//#include "Plan.h"
|
||||
#include "Conf.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user