19 #ifndef __TPIE_JSONPRINT_H__
20 #define __TPIE_JSONPRINT_H__
28 template <
typename R,
typename T,
typename ... TT>
29 bool reflect(R & r, T && v, TT && ... vs);
39 static constexpr
bool write =
false;
40 static constexpr
bool arithmetic =
true;
41 static constexpr
bool string =
true;
42 static constexpr
bool trivialSerializable =
false;
47 void begin(
const char *);
49 void beginArray(
size_t);
51 void name(
const char * name);
53 void beginStaticArray(
size_t x) {beginArray(x);}
54 void endStaticArray() {endArray();}
55 bool operator()(
const uint8_t & v) {writeUint(v);
return true;}
56 bool operator()(
const uint16_t & v) {writeUint(v);
return true;}
57 bool operator()(
const uint32_t & v) {writeUint(v);
return true;}
58 bool operator()(
const uint64_t & v) {writeUint(v);
return true;}
59 bool operator()(
const int8_t & v) {writeInt(v);
return true;}
60 bool operator()(
const int16_t & v) {writeInt(v);
return true;}
61 bool operator()(
const int32_t & v) {writeInt(v);
return true;}
62 bool operator()(
const int64_t & v) {writeInt(v);
return true;}
63 bool operator()(
const float & v) {writeDouble(v);
return true;}
64 bool operator()(
const double & v) {writeDouble(v);
return true;}
65 bool operator()(
const std::string & v) {writeString(v);
return true;}
67 void writeUint(uint64_t v);
68 void writeInt(int64_t v);
69 void writeDouble(
double v);
70 void writeString(
const std::string & v);
81 JSONPrinter(
const T & t,
bool pretty): t(t), pretty(pretty) {}
83 friend std::ostream & operator << (std::ostream & o,
const JSONPrinter & p) {
104 #endif //__TPIE_JSONPRINT_H__
refletor for json printing to an ostream
helper struct for printing
JSONPrinter< T > json_printer(const T &t, bool pretty=true)
create a json print wrapper around t