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

Classes

class  Json
 
class  JsonArray
 
class  JsonBoolean
 
class  JsonDouble
 
class  JsonInt
 
class  JsonNull
 
class  JsonObject
 
class  JsonString
 
class  JsonValue
 
struct  NullStruct
 
struct  Statics
 
class  Value
 

Enumerations

enum  JsonParse { STANDARD, COMMENTS }
 

Functions

static void dump (NullStruct, string &out)
 
static void dump (double value, string &out)
 
static void dump (int value, string &out)
 
static void dump (bool value, string &out)
 
static void dump (const string &value, string &out)
 
static void dump (const Json::array &values, string &out)
 
static void dump (const Json::object &values, string &out)
 
static const Staticsstatics ()
 
static const Jsonstatic_null ()
 
static string esc (char c)
 
static bool in_range (long x, long lower, long upper)
 

Variables

static const int max_depth = 200
 

Enumeration Type Documentation

Enumerator
STANDARD 
COMMENTS 
73  {
75 };
Definition: json11.hpp:74
Definition: json11.hpp:74

Function Documentation

static void json11::dump ( NullStruct  ,
string &  out 
)
static
53  {
54  out += "null";
55 }
static void json11::dump ( double  value,
string &  out 
)
static
57  {
58  if (std::isfinite(value)) {
59  char buf[32];
60  snprintf(buf, sizeof buf, "%.17g", value);
61  out += buf;
62  } else {
63  out += "null";
64  }
65 }
char buf[128]
Definition: rw_test.cpp:40
static void json11::dump ( int  value,
string &  out 
)
static
67  {
68  char buf[32];
69  snprintf(buf, sizeof buf, "%d", value);
70  out += buf;
71 }
char buf[128]
Definition: rw_test.cpp:40
static void json11::dump ( bool  value,
string &  out 
)
static
73  {
74  out += value ? "true" : "false";
75 }
static void json11::dump ( const string &  value,
string &  out 
)
static
77  {
78  out += '"';
79  for (size_t i = 0; i < value.length(); i++) {
80  const char ch = value[i];
81  if (ch == '\\') {
82  out += "\\\\";
83  } else if (ch == '"') {
84  out += "\\\"";
85  } else if (ch == '\b') {
86  out += "\\b";
87  } else if (ch == '\f') {
88  out += "\\f";
89  } else if (ch == '\n') {
90  out += "\\n";
91  } else if (ch == '\r') {
92  out += "\\r";
93  } else if (ch == '\t') {
94  out += "\\t";
95  } else if (static_cast<uint8_t>(ch) <= 0x1f) {
96  char buf[8];
97  snprintf(buf, sizeof buf, "\\u%04x", ch);
98  out += buf;
99  } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
100  && static_cast<uint8_t>(value[i+2]) == 0xa8) {
101  out += "\\u2028";
102  i += 2;
103  } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
104  && static_cast<uint8_t>(value[i+2]) == 0xa9) {
105  out += "\\u2029";
106  i += 2;
107  } else {
108  out += ch;
109  }
110  }
111  out += '"';
112 }
size_t i
Definition: json11.cpp:361
char buf[128]
Definition: rw_test.cpp:40
static void json11::dump ( const Json::array values,
string &  out 
)
static
114  {
115  bool first = true;
116  out += "[";
117  for (const auto &value : values) {
118  if (!first)
119  out += ", ";
120  value.dump(out);
121  first = false;
122  }
123  out += "]";
124 }
static void json11::dump ( const Json::object values,
string &  out 
)
static
126  {
127  bool first = true;
128  out += "{";
129  for (const auto &kv : values) {
130  if (!first)
131  out += ", ";
132  dump(kv.first, out);
133  out += ": ";
134  kv.second.dump(out);
135  first = false;
136  }
137  out += "}";
138 }
static void dump(const Json::object &values, string &out)
Definition: json11.cpp:126
static const Statics& json11::statics ( )
static
238  {
239  static const Statics s {};
240  return s;
241 }
static const Json& json11::static_null ( )
static
243  {
244  // This has to be separate, not in Statics, because Json() accesses statics().null.
245  static const Json json_null;
246  return json_null;
247 }
static string json11::esc ( char  c)
inlinestatic
337  {
338  char buf[12];
339  if (static_cast<uint8_t>(c) >= 0x20 && static_cast<uint8_t>(c) <= 0x7f) {
340  snprintf(buf, sizeof buf, "'%c' (%d)", c, c);
341  } else {
342  snprintf(buf, sizeof buf, "(%d)", c);
343  }
344  return string(buf);
345 }
char buf[128]
Definition: rw_test.cpp:40
static bool json11::in_range ( long  x,
long  lower,
long  upper 
)
inlinestatic
347  {
348  return (x >= lower && x <= upper);
349 }
x
Definition: inputfile.py:6

Variable Documentation

const int json11::max_depth = 200
static