COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
propstruc Struct Reference

Propellant Tank (PROP) structure. More...

#include <jsondef.h>

Collaboration diagram for propstruc:

Public Member Functions

json11::Json to_json () const
 Convert class contents to JSON object. More...
 
void from_json (const string &s)
 Set class contents from JSON string. More...
 

Public Attributes

float cap = 0.f
 Propellant capacity in kg. More...
 
float lev = 0.f
 Propellant level in kg. More...
 

Detailed Description

Propellant Tank (PROP) structure.

Member Function Documentation

json11::Json propstruc::to_json ( ) const
inline

Convert class contents to JSON object.

Returns a json11 JSON object of the class

Returns
A json11 JSON object containing every member variable within the class
2851  {
2852  return json11::Json::object {
2853  { "cap" , cap },
2854  { "lev" , lev }
2855  };
2856  }
std::map< std::string, Json > object
Definition: json11.hpp:88
float cap
Propellant capacity in kg.
Definition: jsondef.h:2843
float lev
Propellant level in kg.
Definition: jsondef.h:2845
void propstruc::from_json ( const string &  s)
inline

Set class contents from JSON string.

Parses the provided JSON-formatted string and sets the class data. String should be formatted like the string returned from to_json()

Parameters
sJSON-formatted string to set class contents to
Returns
n/a
2864  {
2865  string error;
2866  json11::Json parsed = json11::Json::parse(s,error);
2867  if(error.empty()) {
2868  if(!parsed["cap"].is_null()) { cap = parsed["cap"].number_value(); }
2869  if(!parsed["lev"].is_null()) { lev = parsed["lev"].number_value(); }
2870  } else {
2871  cerr<<"ERROR: <"<<error<<">"<<endl;
2872  }
2873  return;
2874  }
Definition: json11.hpp:79
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
float cap
Propellant capacity in kg.
Definition: jsondef.h:2843
float lev
Propellant level in kg.
Definition: jsondef.h:2845
double number_value() const
Definition: json11.cpp:280

Member Data Documentation

float propstruc::cap = 0.f

Propellant capacity in kg.

float propstruc::lev = 0.f

Propellant level in kg.


The documentation for this struct was generated from the following file: