9#include "MantidKernel/DllConfig.h"
14#include <json/value.h>
22template <
typename T>
class Matrix;
28template <
typename T>
struct ToCpp {
39template <>
struct ToCpp<long long> {
47template <>
struct ToCpp<unsigned int> {
51template <>
struct ToCpp<unsigned long long int> {
59template <>
struct ToCpp<float> {
63template <>
struct ToCpp<double> {
72template <
typename T>
struct ToCpp<
std::vector<T>> {
74 std::vector<T> arrayValues;
75 arrayValues.reserve(
value.size());
77 for (
const auto &elem :
value) {
79 arrayValues.emplace_back(toCpp(elem));
80 }
catch (Json::Exception &exc) {
81 throw std::invalid_argument(
"Mixed-type JSON array values not supported:" + std::string(exc.what()));
99MANTID_KERNEL_DLL std::unique_ptr<Property>
decodeAsProperty(
const std::string &name,
const Json::Value &
value);
101namespace pwvjdetail {
106template <
typename ValueType>
struct JsonType {
using Type = ValueType; };
111template <>
struct JsonType<unsigned long> {
using Type = Json::UInt64; };
112template <>
struct JsonType<unsigned long long> {
using Type = Json::UInt64; };
122 return Json::Value(
static_cast<JsonValueType
>(
value));
130template <
typename ValueType> Json::Value
encodeAsJson(
const std::vector<ValueType> &vectorValue) {
131 Json::Value jsonArray(Json::arrayValue);
132 for (
const auto &element : vectorValue) {
144template <>
inline Json::Value
encodeAsJson(
const std::vector<bool> &vectorValue) {
145 Json::Value jsonArray(Json::arrayValue);
146 for (
const auto element : vectorValue) {
157template <
typename ValueType> Json::Value
encodeAsJson(
const std::shared_ptr<ValueType> &) {
158 throw std::runtime_error(
"Unable to encode shared_ptr<T> as Json::Value.");
double value
The value of the point.
Marks code as not implemented yet.
Type decode(const Json::Value &value)
Attempt to decode the given Json::Value as the given Type.
MANTID_KERNEL_DLL std::unique_ptr< Property > decodeAsProperty(const std::string &name, const Json::Value &value)
Attempt to create a Property of the most appropriate type from a string name and Json value object.
MANTID_KERNEL_DLL::Json::Value encodeAsJson(const OptionalBool &)
Encode an OptionalBool as a Json::Value.
MANTID_KERNEL_DLL PropertyManager_sptr createPropertyManager(const Json::Value &keyValues)
Attempt to create a PropertyManager from the Json::Value.
std::shared_ptr< PropertyManager > PropertyManager_sptr
Typedef for a shared pointer to a PropertyManager.
Helper class which provides the Collimation Length for SANS instruments.
bool operator()(const Json::Value &value)
double operator()(const Json::Value &value)
float operator()(const Json::Value &value)
int operator()(const Json::Value &value)
long operator()(const Json::Value &value)
long long operator()(const Json::Value &value)
std::string operator()(const Json::Value &value)
std::vector< T > operator()(const Json::Value &value)
unsigned int operator()(const Json::Value &value)
unsigned long long int operator()(const Json::Value &value)
General type to convert a Json::Value to a set C++ type.
T operator()(const Json::Value &)