8 #ifndef SCARAB_PARAM_JSON_HH_ 9 #define SCARAB_PARAM_JSON_HH_ 16 #include "rapidjson/fwd.h" 17 #include "rapidjson/prettywriter.h" 18 #include "rapidjson/writer.h" 28 LOGGER( dlog_param_json,
"param_json" );
51 param_ptr_t read_document(
const rapidjson::Document& a_document );
52 param_ptr_t read_value(
const rapidjson::Value& a_value );
89 virtual bool write_file(
const param& a_to_write,
const std::string& a_filename,
const param_node& a_options =
param_node() );
92 template<
class XWriter >
93 bool write_param(
const param& a_to_write, XWriter* a_writer );
94 template<
class XWriter >
95 bool write_param_null(
const param& a_to_write, XWriter* a_writer );
96 template<
class XWriter >
97 bool write_param_value(
const param_value& a_to_write, XWriter* a_writer );
98 template<
class XWriter >
99 bool write_param_array(
const param_array& a_to_write, XWriter* a_writer );
100 template<
class XWriter >
101 bool write_param_node(
const param_node& a_to_write, XWriter* a_writer );
105 template<
class XWriter >
124 LWARN( dlog_param_json,
"parameter not written: <" << a_to_write <<
">" );
127 template<
class XWriter >
134 template<
class XWriter >
140 a_writer->String( a_to_write.
as_string().c_str() );
143 else if( a_to_write.
is_bool() )
145 a_writer->Bool( a_to_write.
as_bool() );
148 else if( a_to_write.
is_int() )
150 a_writer->Int64( a_to_write.
as_int() );
153 else if( a_to_write.
is_uint() )
155 a_writer->Uint64( a_to_write.
as_uint() );
160 a_writer->Double( a_to_write.
as_double() );
165 template<
class XWriter >
169 a_writer->StartArray();
174 LERROR( dlog_param_json,
"Error while writing parameter array" );
178 a_writer->EndArray();
181 template<
class XWriter >
185 a_writer->StartObject();
188 a_writer->String( it.name().c_str() );
191 LERROR( dlog_param_json,
"Error while writing parameter node" );
195 a_writer->EndObject();
virtual bool is_node() const
bool write_param(const param &a_to_write, XWriter *a_writer)
bool write_param_array(const param_array &a_to_write, XWriter *a_writer)
virtual bool is_value() const
bool write_param_value(const param_value &a_to_write, XWriter *a_writer)
rapidjson::PrettyWriter< rapidjson::StringBuffer > rj_pretty_string_writer
bool write_param_null(const param &a_to_write, XWriter *a_writer)
Contains the logger class and macros, based on Kasper's KLogger class.
rapidjson::PrettyWriter< rapidjson::FileWriteStream > rj_pretty_file_writer
bool write_param_node(const param_node &a_to_write, XWriter *a_writer)
std::string as_string() const
virtual bool is_null() const
std::unique_ptr< param > param_ptr_t
rapidjson::Writer< rapidjson::FileWriteStream > rj_file_writer
param_array_const_iterator const_iterator
virtual bool is_array() const
rapidjson::Writer< rapidjson::StringBuffer > rj_string_writer
LOGGER(mtlog,"authentication")