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

3x3 element generic matrix More...

#include <matrix.h>

Collaboration diagram for rmatrix:

Public Member Functions

 rmatrix ()
 
 rmatrix (rvector rv0, rvector rv1, rvector rv2)
 
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

rvector row [3]
 

Detailed Description

3x3 element generic matrix

3 rvector elements representing 3 rows of a matrix

Constructor & Destructor Documentation

rmatrix::rmatrix ( )
inline
45 {}
rmatrix::rmatrix ( rvector  rv0,
rvector  rv1,
rvector  rv2 
)
inline
46  {
47  row[0] = rv0;
48  row[1] = rv1;
49  row[2] = rv2;
50  }
rvector row[3]
Definition: matrix.h:43

Member Function Documentation

json11::Json rmatrix::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
56  {
57  vector<rvector> v_row = vector<rvector>(row, row+sizeof(row)/sizeof(row[0]));
58  return json11::Json::object {
59  { "row" , v_row }
60  };
61  }
std::map< std::string, Json > object
Definition: json11.hpp:88
rvector row[3]
Definition: matrix.h:43
void rmatrix::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
69  {
70  string error;
71  json11::Json parsed = json11::Json::parse(s,error);
72  if(error.empty()) {
73  auto p_row = parsed["row"].array_items();
74  for(size_t i = 0; i != p_row.size(); ++i) {
75  if(!p_row[i].is_null()) row[i].from_json(p_row[i].dump());
76  }
77  } else {
78  cerr<<"ERROR: <"<<error<<">"<<endl;
79  }
80  return;
81  }
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)
static void dump(NullStruct, string &out)
Definition: json11.cpp:53
const array & array_items() const
Definition: json11.cpp:284
void from_json(const string &s)
Set class contents from JSON string.
Definition: matrix.h:69
rvector row[3]
Definition: matrix.h:43

Member Data Documentation

rvector rmatrix::row[3]

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