53 #include <json_spirit_value.h> 65 extern template class json_spirit::Config_map<std::string>;
66 extern template class json_spirit::Value_impl<json_spirit::Config_map<std::string>>;
84 boost::mpl::bool_<boost::is_same<T, std::string>::value || boost::is_arithmetic<T>::value>
100 #define MIRA_JSON_TRAIT(B,T) \ 102 struct TypeTrait<T> \ 107 MIRA_JSON_TRAIT(
int,
char)
108 MIRA_JSON_TRAIT(
int,
uint8)
109 MIRA_JSON_TRAIT(
int,
uint16)
111 MIRA_JSON_TRAIT(
int,
int8)
112 MIRA_JSON_TRAIT(
int,
int16)
113 MIRA_JSON_TRAIT(
int,
int32)
114 MIRA_JSON_TRAIT(
double,
float)
117 MIRA_JSON_TRAIT(
double,
long double)
123 template <
typename T>
129 template <
typename T>
132 return static_cast<T
>(value);
161 static unsigned int get() {
return instance().mPrecision; }
164 unsigned int mPrecision;
201 void write(
const Value& value, std::ostream& ioStream,
202 bool formatted=
false,
int precision = -1);
214 std::string
write(
const Value& value,
bool formatted=
false,
223 void read(
const std::string& s,
Value& oValue);
231 void read(std::istream& ioStream,
Value& oValue);
240 inline void read(std::string::const_iterator& begin,
241 std::string::const_iterator& end,
267 const std::string& elementName);
298 const std::string& elementName);
322 const std::string& elementName);
353 const std::string& elementName);
378 template <
typename OStream>
397 template <
typename IStream>
406 template <
typename CharT>
410 is.seekg(-1, std::ios_base::cur);
void write(const Value &value, std::ostream &ioStream, bool formatted=false, int precision=-1)
Writes a json::Value into a given stream using the JSON format.
OStream & operator<<(OStream &os, const mira::JSONValue &value)
Definition: JSON.h:379
bool hasNumberElement(const Value &iValue, const std::string &element)
Query existence of number element/member in a json::Value Use this variant to only query whether the ...
static void reset()
Reset default precision for json::write() to initial default value (MIRA_JSON_DEFAULT_PRECISION).
Definition: JSON.h:158
Implementation of the CreationPolicy that is used by the Singleton template.
Definition: Singleton.h:149
static Type & instance()
Returns a reference to the singleton instance.
Definition: Singleton.h:508
json_spirit::mArray Array
A representation of an array (vector) in JSON.
Definition: JSON.h:188
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
IStream & operator>>(IStream &is, mira::JSONValue &value)
Definition: JSON.h:398
A struct used for return value of getElementIfExists()
Definition: JSON.h:281
void read(const std::string &s, Value &oValue)
Read a json::Value from a string that contains JSON format.
QueryValueResult getElementIfExists(const Value &iValue, const std::string &elementName)
Get a json::Value element/member from a json::Value if it exists, otherwise the returned result will ...
QueryNumberResult getNumberElementIfExists(const Value &iValue, const std::string &elementName)
Get a number element/member from a json::Value if it exists, otherwise the returned result will conta...
Type trait that indicates whether a type can be serialized as an atomic value.
Definition: IsAtomicSerializable.h:83
std::string error
empty if exists is true
Definition: JSON.h:339
Output stream adapter that can be assigned to any output stream and allows binary output using the <<...
Definition: BinaryStream.h:293
A struct used for return value of getNumberElementIfExists()
Definition: JSON.h:336
Commonly used exception classes.
A singleton template class that can be freely configured using policies that control the instantiatio...
Definition: Singleton.h:495
A singleton class that can be freely configured using policies that control the creation, instantiation, lifetime and thread-safety.
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
double getNumberElement(const Value &iValue, const std::string &elementName)
Get a number element/member from a json::Value See getElement() for basic syntax. ...
Value getElement(const Value &iValue, const std::string &elementName)
Get a json::Value element/member from a json::Value Syntax:
json_spirit::mObject Object
A representation of an object (class, struct) in JSON.
Definition: JSON.h:181
static const unsigned int MIRA_JSON_DEFAULT_PRECISION
Default value if not changed using set().
Definition: JSON.h:151
JSONDefaultPrecision()
Definition: JSON.h:148
json_spirit::mValue Value
A value is an abstract description of data in JSON (underlying data can either be one of the JSON bas...
Definition: JSON.h:174
JSONDefaultPrecision is a singleton that provides a mechanism to control the default precision for ou...
Definition: JSON.h:143
json::Array JSONArray
Imports the json::Array type into mira namespace.
Definition: JSON.h:365
Contains the BinaryIStream and BinaryOStream classes for fast and efficient streaming of binary data...
Value value
undefined if exists is false
Definition: JSON.h:283
std::string error
empty if exists is true
Definition: JSON.h:284
Provides type trait that indicates whether a type can be serialized as atomic value.
PropertyHint precision(int p)
Sets the attribute "precision".
Definition: PropertyHint.h:285
json::Object JSONObject
Imports the json::Object type into mira namespace.
Definition: JSON.h:363
bool exists
Definition: JSON.h:337
bool hasElement(const Value &iValue, const std::string &element)
Query existence of element/member in a json::Value Use this variant to only query whether the element...
json::Value JSONValue
Imports the json::Value type into mira namespace.
Definition: JSON.h:361
bool exists
Definition: JSON.h:282
double number
undefined if exists is false
Definition: JSON.h:338