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

3 element generic row vector More...

#include <vector.h>

Collaboration diagram for rvector:

Public Member Functions

 rvector ()
 
 rvector (double d0, double d1, double d2)
 
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

double col [3] = {0.}
 

Detailed Description

3 element generic row vector

3 double precision numbers representing a 3 element row major vector.

Constructor & Destructor Documentation

rvector::rvector ( )
inline
57 {}
rvector::rvector ( double  d0,
double  d1,
double  d2 
)
inline
58  {
59  col[0] = d0;
60  col[1] = d1;
61  col[2] = d2;
62  }
double col[3]
Definition: vector.h:55

Member Function Documentation

json11::Json rvector::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
68  {
69  vector<double> v_col = vector<double>(col, col+sizeof(col)/sizeof(col[0]));
70  return json11::Json::object {
71  { "col" , v_col }
72  };
73  }
std::map< std::string, Json > object
Definition: json11.hpp:88
double col[3]
Definition: vector.h:55
void rvector::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
80  {
81  string error;
82  json11::Json parsed = json11::Json::parse(s,error);
83  if(error.empty()) {
84  auto p_col = parsed["col"].array_items();
85  for(size_t i = 0; i != p_col.size(); ++i) {
86  if(!p_col[i].is_null()) col[i] = p_col[i].number_value();
87  }
88  } else {
89  cerr<<"ERROR: <"<<error<<">"<<endl;
90  }
91  return;
92  }
Definition: json11.hpp:79
int i
Definition: rw_test.cpp:37
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
const array & array_items() const
Definition: json11.cpp:284
double col[3]
Definition: vector.h:55

Member Data Documentation

double rvector::col[3] = {0.}

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