COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
jsonclass.h
Go to the documentation of this file.
1 #ifndef JSONCLASS_H
2 #define JSONCLASS_H
3 
4 #include "support/configCosmos.h"
5 #include "support/cosmos-errno.h"
6 
7 namespace Cosmos
8 {
9  namespace Support
10  {
11  class Json
12 {
13 public:
14  Json(string json="");
15 
18  enum class Type : uint16_t
19  {
20  Undefined,
21  Null,
22  False,
23  True,
24  Number,
25  String,
26  Array,
27  Object
28  };
29 
30 
33  struct Value
34  {
35 // string name;
37  string svalue;
38  double nvalue;
39  bool bvalue;
40  map<string, Value> object;
41  vector<Value> array;
42  string::iterator begin;
43  string::iterator end;
44  };
45 
46  typedef pair<string, Value> Member;
47  typedef map<string, Value> Object;
48  typedef vector<Value> Array;
49 
52 // struct Member
53 // {
54 // string name;
55 // Value value;
56 // };
57 
60 // struct Object
61 // {
62 // vector <Member> members;
63 // };
64 
65  int32_t extract_contents(string json);
66 // int32_t extract_members(string::iterator begin, string::iterator end, vector<Member> &members);
67 // int32_t extract_values(string::iterator begin, string::iterator end, vector <Member> &members);
68  int32_t extract_members(string::iterator &begin, string::iterator &end, Object &members);
69  int32_t extract_values(string::iterator &begin, string::iterator &end, Array &values);
70  int32_t extract_string(string::iterator &bit, string::iterator &eit, string &ostring);
71  int32_t extract_name(string::iterator &bit, string::iterator &eit, string &name);
72  int32_t extract_value(string::iterator &bit, string::iterator &eit, Value &value);
73  int32_t extract_member(string::iterator &bit, string::iterator &eit, Member &value);
74 // int32_t extract_member(string::iterator &bit, string::iterator &eit, Member &value);
75  int32_t skip_character(string::iterator &bit, string::iterator &eit, const char character);
76  int32_t skip_to_character(string::iterator &bit, string::iterator &eit, string characters);
77  int32_t skip_white(string::iterator &bit, string::iterator &eit);
78 
79  string Content;
83 // vector <Member> Members;
84 
85  private:
86 
87  string::iterator begin;
88  string::iterator end;
89 };
90 
91 
92  }
93 }
94 #endif // JSONCLASS_H
Definition: agentclass.cpp:54
Definition: jsonclass.h:33
string svalue
Definition: jsonclass.h:37
int32_t extract_member(string::iterator &bit, string::iterator &eit, Member &value)
Definition: jsonclass.cpp:141
bool bvalue
Definition: jsonclass.h:39
int32_t extract_members(string::iterator &begin, string::iterator &end, Object &members)
Definition: jsonclass.cpp:89
int32_t extract_values(string::iterator &begin, string::iterator &end, Array &values)
Definition: jsonclass.cpp:112
Type
Definition: jsonclass.h:18
int32_t skip_character(string::iterator &bit, string::iterator &eit, const char character)
Definition: jsonclass.cpp:449
int32_t extract_contents(string json)
Definition: jsonclass.cpp:16
Json(string json="")
Definition: jsonclass.cpp:8
string::iterator end
Definition: jsonclass.h:43
vector< Value > array
Definition: jsonclass.h:41
string::iterator begin
Definition: jsonclass.h:87
map< string, Value > object
Definition: jsonclass.h:40
int32_t extract_name(string::iterator &bit, string::iterator &eit, string &name)
Definition: jsonclass.cpp:500
string Content
Definition: jsonclass.h:79
Headers and definitions common to all COSMOS.
string::iterator begin
Definition: jsonclass.h:42
string name
Definition: cubesat2obj.cpp:6
COSMOS Error Codes.
int32_t extract_string(string::iterator &bit, string::iterator &eit, string &ostring)
Definition: jsonclass.cpp:543
Type JType
Definition: jsonclass.h:80
double nvalue
Definition: jsonclass.h:38
Object ObjectContents
Definition: jsonclass.h:81
Definition: jsonclass.h:11
map< string, Value > Object
Definition: jsonclass.h:47
int32_t extract_value(string::iterator &bit, string::iterator &eit, Value &value)
Definition: jsonclass.cpp:158
pair< string, Value > Member
Definition: jsonclass.h:46
int32_t skip_to_character(string::iterator &bit, string::iterator &eit, string characters)
Definition: jsonclass.cpp:473
vector< Value > Array
Definition: jsonclass.h:48
string::iterator end
Definition: jsonclass.h:88
Array ArrayContents
Definition: jsonclass.h:82
int32_t skip_white(string::iterator &bit, string::iterator &eit)
Definition: jsonclass.cpp:433