rex/src/loaders/Unit.cpp

80 lines
1.4 KiB
C++
Raw Normal View History

#include "Unit.h"
2017-06-20 06:06:33 +00:00
#include <iostream>
#include <fstream>
#include <cstdlib>
Unit::Unit() {}
2017-06-21 02:53:47 +00:00
// where the serialized json is broken down into object members
int Unit::load_root(Json::Value loader_root)
{
2017-06-21 02:53:47 +00:00
this->name = loader_root.get("name", "?").asString();
2017-06-21 02:53:47 +00:00
this->target = loader_root.get("target", "?").asString();
2017-06-21 02:53:47 +00:00
this->output = loader_root.get("output", "?").asString();
2017-06-21 02:53:47 +00:00
this->rectifier = loader_root.get("rectifier", "?").asString();
2017-06-21 02:53:47 +00:00
this->active = loader_root.get("active", "?").asString();
2017-06-21 02:53:47 +00:00
this->required = loader_root.get("required", "?").asString();
2017-06-21 02:53:47 +00:00
this->rectify = loader_root.get("rectify", "?").asString();
2017-06-21 02:53:47 +00:00
this->populated = true;
return 0;
}
2017-06-20 06:06:33 +00:00
2017-06-21 02:53:47 +00:00
// populates from a string json object
2017-06-20 06:06:33 +00:00
int Unit::load_string(std::string json_val)
{
2017-06-21 02:53:47 +00:00
// serialize
this->load_json_string( json_val, true );
// deserialize
this->load_root( this->json_root );
2017-06-20 06:06:33 +00:00
// exit successfully
this->populated = true;
2017-06-21 02:53:47 +00:00
return 0;
}
2017-06-20 06:06:33 +00:00
// getters for Unit type.
std::string Unit::get_name()
{
return this->name;
}
std::string Unit::get_target()
{
return this->target;
}
std::string Unit::get_output()
{
return this->output;
}
std::string Unit::get_rectifier()
{
return this->rectifier;
}
std::string Unit::get_active()
{
return this->active;
}
std::string Unit::get_required()
{
return this->required;
}
std::string Unit::get_rectify()
{
return this->rectify;
}