From fb87c61e8690428acf6f362cbf5cd3d5fb7b2e8f Mon Sep 17 00:00:00 2001 From: Chris Punches Date: Fri, 23 Jun 2017 14:03:25 -0400 Subject: [PATCH] finished rework of suite --- src/loaders/JSON_Loader.h | 2 +- src/loaders/Suite.cpp | 9 ++++----- src/loaders/Suite.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/loaders/JSON_Loader.h b/src/loaders/JSON_Loader.h index dd7b63b..8f0e872 100644 --- a/src/loaders/JSON_Loader.h +++ b/src/loaders/JSON_Loader.h @@ -29,7 +29,7 @@ class JSON_Loader // return as a JSONCPP serialized object // deprecated -- these aren't really used. // Json::Value as_serialized(); - // std::string as_string(); + std::string as_string(); // safely handle deserialized type retrieval (if we want it to be safe) int get_serialized(Json::Value &input, std::string key, bool verbose); diff --git a/src/loaders/Suite.cpp b/src/loaders/Suite.cpp index b01be62..4b1bd08 100644 --- a/src/loaders/Suite.cpp +++ b/src/loaders/Suite.cpp @@ -55,11 +55,10 @@ void Suite::load_units_file( std::string filename, bool verbose ) /// Suite::get_unit - returns a contained Unit identified by name attribute. /// +/// \param result - the unit type receiving the unit's value /// \param provided_name - The name of the unit being fetched. -/// \return - The unit being fetched. -Unit Suite::get_unit(std::string provided_name) +void Suite::get_unit(Unit & result, std::string provided_name) { - Unit * returnable; bool foundMatch = false; for ( int i = 0; i < this->units.size(); i++ ) @@ -67,16 +66,16 @@ Unit Suite::get_unit(std::string provided_name) std::string unit_name = this->units[i].get_name(); if ( unit_name == provided_name ) { - returnable = & this->units[i]; + result = this->units[i]; foundMatch = true; break; } } + if (! foundMatch ) { std::cerr << "Unit name \"" << provided_name << "\" was referenced but not defined!" << std::endl; throw Suite_InvalidUnitMember(); } - return * returnable; } diff --git a/src/loaders/Suite.h b/src/loaders/Suite.h index d5432a2..1c1a24b 100644 --- a/src/loaders/Suite.h +++ b/src/loaders/Suite.h @@ -23,7 +23,7 @@ class Suite: public JSON_Loader void load_units_file( std::string filename, bool verbose ); // returns the unit identified by name - // void get_unit(Unit & result, std::string provided_name); + void get_unit(Unit & result, std::string provided_name); }; #endif //FTESTS_UNITS_H