aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorAntonio Juarez <antonio.maria.juarez@live.com>2014-04-07 16:02:15 +0100
committerAntonio Juarez <antonio.maria.juarez@live.com>2014-04-07 16:02:15 +0100
commita401a02ddb3fb045d998cf650292cab3b3ebfd58 (patch)
tree61d021af997193aba90b95b70836c2d031334aff /contrib
parentjson rpc for wallet and bugfix (diff)
downloadmonero-a401a02ddb3fb045d998cf650292cab3b3ebfd58.tar.xz
Improvements in JSON RPC
Diffstat (limited to 'contrib')
-rw-r--r--contrib/epee/demo/demo_http_server/demo_http_server.cpp10
-rw-r--r--contrib/epee/demo/demo_http_server/demo_http_server.h12
-rw-r--r--contrib/epee/demo/demo_levin_server/demo_levin_server.cpp2
-rw-r--r--contrib/epee/demo/iface/transport_defs.h10
-rw-r--r--contrib/epee/include/console_handler.h2
-rw-r--r--contrib/epee/include/net/http_protocol_handler.inl2
-rw-r--r--contrib/epee/include/net/http_server_handlers_map2.h86
-rw-r--r--contrib/epee/include/serialization/keyvalue_serialization_overloads.h16
-rw-r--r--contrib/epee/include/storages/portable_storage.h18
9 files changed, 89 insertions, 69 deletions
diff --git a/contrib/epee/demo/demo_http_server/demo_http_server.cpp b/contrib/epee/demo/demo_http_server/demo_http_server.cpp
index fda53b9ad..85547e4c9 100644
--- a/contrib/epee/demo/demo_http_server/demo_http_server.cpp
+++ b/contrib/epee/demo/demo_http_server/demo_http_server.cpp
@@ -43,7 +43,7 @@ bool communicate(const std::string url, t_request& req, t_response& rsp, const s
{
epee::json_rpc::request<t_request> req_t = AUTO_VAL_INIT(req_t);
req_t.jsonrpc = "2.0";
- req_t.id = "10";
+ req_t.id = epee::serialization::storage_entry(10);
req_t.method = "command_example_1";
req_t.params = req;
epee::json_rpc::response<t_response, std::string> resp_t = AUTO_VAL_INIT(resp_t);
@@ -80,7 +80,7 @@ int main(int argc, char* argv[])
demo::demo_http_server srv;
- start_default_console(&srv);
+ start_default_console(&srv, "#");
std::string bind_param = "0.0.0.0";
std::string port = "83";
@@ -195,7 +195,7 @@ namespace demo
return true;
}
- bool demo_http_server::on_request_api_1(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res)
+ bool demo_http_server::on_request_api_1(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, connection_context& ctxt)
{
CHECK_AND_ASSERT_MES(req.sub == demo::get_test_data(), false, "wrong request");
res.m_success = true;
@@ -203,14 +203,14 @@ namespace demo
return true;
}
- bool demo_http_server::on_request_api_1_with_error(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, epee::json_rpc::error& error_resp)
+ bool demo_http_server::on_request_api_1_with_error(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, epee::json_rpc::error& error_resp, connection_context& ctxt)
{
error_resp.code = 232432;
error_resp.message = "bla bla bla";
return false;
}
- bool demo_http_server::on_request_api_2(const COMMAND_EXAMPLE_2::request& req, COMMAND_EXAMPLE_2::response& res)
+ bool demo_http_server::on_request_api_2(const COMMAND_EXAMPLE_2::request& req, COMMAND_EXAMPLE_2::response& res, connection_context& ctxt)
{
return true;
}
diff --git a/contrib/epee/demo/demo_http_server/demo_http_server.h b/contrib/epee/demo/demo_http_server/demo_http_server.h
index bb8f9bffa..088ead548 100644
--- a/contrib/epee/demo/demo_http_server/demo_http_server.h
+++ b/contrib/epee/demo/demo_http_server/demo_http_server.h
@@ -39,9 +39,11 @@ using namespace epee;
namespace demo
{
- class demo_http_server: public net_utils::http::i_http_server_handler
+ class demo_http_server: public net_utils::http::i_http_server_handler<epee::net_utils::connection_context_base>
{
public:
+ typedef epee::net_utils::connection_context_base connection_context;
+
demo_http_server():m_stop(false){}
bool run();
bool init(const std::string& bind_port = "11112", const std::string& bind_ip = "0.0.0.0");
@@ -52,7 +54,7 @@ namespace demo
private:
- CHAIN_HTTP_TO_MAP2(); //forward http requests to uri map
+ CHAIN_HTTP_TO_MAP2(connection_context); //forward http requests to uri map
BEGIN_URI_MAP2()
MAP_URI2("/requestr_uri_1", on_requestr_uri_1)
@@ -89,10 +91,10 @@ namespace demo
net_utils::http::http_response_info& response,
const net_utils::connection_context_base& m_conn_context);
- bool on_request_api_1(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res);
- bool on_request_api_2(const COMMAND_EXAMPLE_2::request& req, COMMAND_EXAMPLE_2::response& res);
+ bool on_request_api_1(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, connection_context& ctxt);
+ bool on_request_api_2(const COMMAND_EXAMPLE_2::request& req, COMMAND_EXAMPLE_2::response& res, connection_context& ctxt);
- bool on_request_api_1_with_error(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, epee::json_rpc::error& error_resp);
+ bool on_request_api_1_with_error(const COMMAND_EXAMPLE_1::request& req, COMMAND_EXAMPLE_1::response& res, epee::json_rpc::error& error_resp, connection_context& ctxt);
net_utils::boosted_http_server_custum_handling m_net_server;
std::atomic<bool> m_stop;
diff --git a/contrib/epee/demo/demo_levin_server/demo_levin_server.cpp b/contrib/epee/demo/demo_levin_server/demo_levin_server.cpp
index 215b1dd48..a99a1f564 100644
--- a/contrib/epee/demo/demo_levin_server/demo_levin_server.cpp
+++ b/contrib/epee/demo/demo_levin_server/demo_levin_server.cpp
@@ -101,7 +101,7 @@ int main(int argc, char* argv[])
demo::demo_levin_server srv;
- start_default_console(&srv);
+ start_default_console(&srv, "#");
std::string bind_param = "0.0.0.0";
std::string port = "12345";
diff --git a/contrib/epee/demo/iface/transport_defs.h b/contrib/epee/demo/iface/transport_defs.h
index 97f6caadd..8463eb903 100644
--- a/contrib/epee/demo/iface/transport_defs.h
+++ b/contrib/epee/demo/iface/transport_defs.h
@@ -1,7 +1,7 @@
#pragma once
#include "serialization/keyvalue_serialization.h"
-
+#include "storages/portable_storage_base.h"
namespace demo
{
@@ -41,6 +41,8 @@ namespace demo
std::list<bool> m_list_of_bool;
some_test_subdata m_subobj;
std::list<some_test_data> m_list_of_self;
+ epee::serialization::storage_entry m_storage_entry_int;
+ epee::serialization::storage_entry m_storage_entry_string;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(m_str)
@@ -67,6 +69,8 @@ namespace demo
KV_SERIALIZE(m_list_of_double)
KV_SERIALIZE(m_list_of_bool)
KV_SERIALIZE(m_list_of_self)
+ KV_SERIALIZE(m_storage_entry_int)
+ KV_SERIALIZE(m_storage_entry_string)
END_KV_SERIALIZE_MAP()
};
@@ -162,6 +166,8 @@ namespace demo
|| b.m_list_of_bool != a.m_list_of_bool
|| b.m_subobj != a.m_subobj
|| b.m_list_of_self != a.m_list_of_self
+ || b.m_storage_entry_int.which() != a.m_storage_entry_int.which()
+ || b.m_storage_entry_string.which() != a.m_storage_entry_string.which()
)
return false;
return true;
@@ -208,6 +214,8 @@ namespace demo
s.m_subobj.m_str = "subszzzzzzzz";
s.m_list_of_self.push_back(s);
+ s.m_storage_entry_int = epee::serialization::storage_entry(uint64_t(22222));;
+ s.m_storage_entry_string = epee::serialization::storage_entry(std::string("sdsvsdvs"));
return s;
}
} \ No newline at end of file
diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h
index 65414a265..5798d2def 100644
--- a/contrib/epee/include/console_handler.h
+++ b/contrib/epee/include/console_handler.h
@@ -311,7 +311,7 @@ namespace epee
bool start_default_console(t_server* ptsrv, t_handler handlr, const std::string& prompt, const std::string& usage = "")
{
std::shared_ptr<async_console_handler> console_handler = std::make_shared<async_console_handler>();
- boost::thread(boost::bind(&async_console_handler::run<t_server, t_handler>, console_handler, ptsrv, handlr, prompt, usage)).detach();
+ boost::thread([=](){console_handler->run<t_server, t_handler>(ptsrv, handlr, prompt, usage);}).detach();
return true;
}
diff --git a/contrib/epee/include/net/http_protocol_handler.inl b/contrib/epee/include/net/http_protocol_handler.inl
index b8eeb5993..78b46427e 100644
--- a/contrib/epee/include/net/http_protocol_handler.inl
+++ b/contrib/epee/include/net/http_protocol_handler.inl
@@ -587,7 +587,7 @@ namespace net_utils
{
std::string buf = "HTTP/1.1 ";
buf += boost::lexical_cast<std::string>(response.m_response_code) + " " + response.m_response_comment + "\r\n" +
- "Server: Siski v0.1\r\n"
+ "Server: Epee-based\r\n"
"Content-Length: ";
buf += boost::lexical_cast<std::string>(response.m_body.size()) + "\r\n";
buf += "Content-Type: ";
diff --git a/contrib/epee/include/net/http_server_handlers_map2.h b/contrib/epee/include/net/http_server_handlers_map2.h
index 0b6ffa095..af4e035f8 100644
--- a/contrib/epee/include/net/http_server_handlers_map2.h
+++ b/contrib/epee/include/net/http_server_handlers_map2.h
@@ -120,7 +120,7 @@ namespace epee
{
std::string jsonrpc;
std::string method;
- std::string id;
+ epee::serialization::storage_entry id;
t_param params;
BEGIN_KV_SERIALIZE_MAP()
@@ -158,7 +158,7 @@ namespace epee
{
std::string jsonrpc;
t_param result;
- std::string id;
+ epee::serialization::storage_entry id;
t_error error;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(jsonrpc)
@@ -173,7 +173,7 @@ namespace epee
{
std::string jsonrpc;
t_param result;
- std::string id;
+ epee::serialization::storage_entry id;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(jsonrpc)
KV_SERIALIZE(id)
@@ -186,7 +186,7 @@ namespace epee
{
std::string jsonrpc;
t_error error;
- std::string id;
+ epee::serialization::storage_entry id;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(jsonrpc)
KV_SERIALIZE(id)
@@ -213,6 +213,9 @@ namespace epee
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(rsp), response_info.m_body); \
return true; \
} \
+ epee::serialization::storage_entry id_; \
+ id_ = epee::serialization::storage_entry(std::string()); \
+ ps.get_value("id", id_, nullptr); \
std::string callback_name; \
if(!ps.get_value("method", callback_name, nullptr)) \
{ \
@@ -225,18 +228,39 @@ namespace epee
} \
if(false) return true; //just a stub to have "else if"
-#define MAP_JON_RPC_WE(method_name, callback_f, command_type) \
- else if(callback_name == method_name) \
-{ \
+
+#define PREPARE_OBJECTS_FROM_JSON(command_type) \
handled = true; \
boost::value_initialized<epee::json_rpc::request<command_type::request> > req_; \
epee::json_rpc::request<command_type::request>& req = static_cast<epee::json_rpc::request<command_type::request>&>(req_);\
- req.load(ps); \
+ if(!req.load(ps)) \
+ { \
+ epee::json_rpc::error_response fail_resp = AUTO_VAL_INIT(fail_resp); \
+ fail_resp.jsonrpc = "2.0"; \
+ fail_resp.id = req.id; \
+ fail_resp.error.code = -32602; \
+ fail_resp.error.message = "Invalid params"; \
+ epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
+ return true; \
+ } \
uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
boost::value_initialized<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> > resp_; \
epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error>& resp = static_cast<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> &>(resp_); \
resp.jsonrpc = "2.0"; \
- resp.id = req.id; \
+ resp.id = req.id;
+
+#define FINALIZE_OBJECTS_TO_JSON(method_name) \
+ uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
+ epee::serialization::store_t_to_json(resp, response_info.m_body); \
+ uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
+ response_info.m_mime_tipe = "application/json"; \
+ response_info.m_header_info.m_content_type = " application/json"; \
+ LOG_PRINT( query_info.m_URI << "[" << method_name << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2);
+
+#define MAP_JON_RPC_WE(method_name, callback_f, command_type) \
+ else if(callback_name == method_name) \
+{ \
+ PREPARE_OBJECTS_FROM_JSON(command_type) \
epee::json_rpc::error_response fail_resp = AUTO_VAL_INIT(fail_resp); \
fail_resp.jsonrpc = "2.0"; \
fail_resp.id = req.id; \
@@ -245,27 +269,14 @@ namespace epee
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
return true; \
} \
- uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
- epee::serialization::store_t_to_json(resp, response_info.m_body); \
- uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
- response_info.m_mime_tipe = "application/json"; \
- response_info.m_header_info.m_content_type = " application/json"; \
- LOG_PRINT( query_info.m_URI << "[" << method_name << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \
+ FINALIZE_OBJECTS_TO_JSON(method_name) \
return true;\
}
#define MAP_JON_RPC_WERI(method_name, callback_f, command_type) \
else if(callback_name == method_name) \
{ \
- handled = true; \
- boost::value_initialized<epee::json_rpc::request<command_type::request> > req_; \
- epee::json_rpc::request<command_type::request>& req = static_cast<epee::json_rpc::request<command_type::request>&>(req_);\
- req.load(ps); \
- uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
- boost::value_initialized<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> > resp_; \
- epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error>& resp = static_cast<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> &>(resp_); \
- resp.jsonrpc = "2.0"; \
- resp.id = req.id; \
+ PREPARE_OBJECTS_FROM_JSON(command_type) \
epee::json_rpc::error_response fail_resp = AUTO_VAL_INIT(fail_resp); \
fail_resp.jsonrpc = "2.0"; \
fail_resp.id = req.id; \
@@ -274,28 +285,14 @@ namespace epee
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
return true; \
} \
- uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
- epee::serialization::store_t_to_json(resp, response_info.m_body); \
- uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
- response_info.m_mime_tipe = "application/json"; \
- response_info.m_header_info.m_content_type = " application/json"; \
- LOG_PRINT( query_info.m_URI << "[" << method_name << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \
+ FINALIZE_OBJECTS_TO_JSON(method_name) \
return true;\
}
-
#define MAP_JON_RPC(method_name, callback_f, command_type) \
else if(callback_name == method_name) \
{ \
- handled = true; \
- boost::value_initialized<epee::json_rpc::request<command_type::request> > req_; \
- epee::json_rpc::request<command_type::request>& req = static_cast<epee::json_rpc::request<command_type::request>&>(req_);\
- req.load(ps); \
- uint64_t ticks1 = epee::misc_utils::get_tick_count(); \
- boost::value_initialized<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> > resp_; \
- epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error>& resp = static_cast<epee::json_rpc::response<command_type::response, epee::json_rpc::dummy_error> &>(resp_); \
- resp.jsonrpc = "2.0"; \
- resp.id = req.id; \
+ PREPARE_OBJECTS_FROM_JSON(command_type) \
if(!callback_f(req.params, resp.result, m_conn_context)) \
{ \
epee::json_rpc::error_response fail_resp = AUTO_VAL_INIT(fail_resp); \
@@ -306,18 +303,13 @@ namespace epee
epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(fail_resp), response_info.m_body); \
return true; \
} \
- uint64_t ticks2 = epee::misc_utils::get_tick_count(); \
- epee::serialization::store_t_to_json(resp, response_info.m_body); \
- uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
- response_info.m_mime_tipe = "application/json"; \
- response_info.m_header_info.m_content_type = " application/json"; \
- LOG_PRINT( query_info.m_URI << "[" << method_name << "] processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms", LOG_LEVEL_2); \
+ FINALIZE_OBJECTS_TO_JSON(method_name) \
return true;\
}
-
#define END_JSON_RPC_MAP() \
epee::json_rpc::error_response rsp; \
+ rsp.id = id_; \
rsp.jsonrpc = "2.0"; \
rsp.error.code = -32601; \
rsp.error.message = "Method not found"; \
diff --git a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
index 2ad9a82a4..54535a404 100644
--- a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
+++ b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h
@@ -280,7 +280,9 @@ namespace epee
return unserialize_stl_container_t_obj(d, stg, hparent_section, pname);
}
};
- typedef boost::mpl::vector<uint64_t, uint32_t, uint16_t, uint8_t, int64_t, int32_t, int16_t, int8_t, double, bool, std::string>::type base_serializable_types;
+ template<class t_storage>
+ struct base_serializable_types: public boost::mpl::vector<uint64_t, uint32_t, uint16_t, uint8_t, int64_t, int32_t, int16_t, int8_t, double, bool, std::string, typename t_storage::meta_entry>::type
+ {};
//-------------------------------------------------------------------------------------------------------------------
template<bool> struct selector;
template<>
@@ -330,37 +332,37 @@ namespace epee
template<class t_type, class t_storage>
bool kv_serialize(const t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
- return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types, typename std::remove_const<t_type>::type>::value>::kv_serialize(d, stg, hparent_section, pname);
+ return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_serialize(d, stg, hparent_section, pname);
}
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>
bool kv_unserialize(t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
- return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types, typename std::remove_const<t_type>::type>::value>::kv_unserialize(d, stg, hparent_section, pname);
+ return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_unserialize(d, stg, hparent_section, pname);
}
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>
bool kv_serialize(const std::vector<t_type>& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
- return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types, typename std::remove_const<t_type>::type>::value>::kv_serialize(d, stg, hparent_section, pname);
+ return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_serialize(d, stg, hparent_section, pname);
}
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>
bool kv_unserialize(std::vector<t_type>& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
- return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types, typename std::remove_const<t_type>::type>::value>::kv_unserialize(d, stg, hparent_section, pname);
+ return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_unserialize(d, stg, hparent_section, pname);
}
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>
bool kv_serialize(const std::list<t_type>& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
- return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types, typename std::remove_const<t_type>::type>::value>::kv_serialize(d, stg, hparent_section, pname);
+ return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_serialize(d, stg, hparent_section, pname);
}
//-------------------------------------------------------------------------------------------------------------------
template<class t_type, class t_storage>
bool kv_unserialize(std::list<t_type>& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname)
{
- return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types, typename std::remove_const<t_type>::type>::value>::kv_unserialize(d, stg, hparent_section, pname);
+ return kv_serialization_overloads_impl_is_base_serializable_types<boost::mpl::contains<base_serializable_types<t_storage>, typename std::remove_const<t_type>::type>::value>::kv_unserialize(d, stg, hparent_section, pname);
}
}
} \ No newline at end of file
diff --git a/contrib/epee/include/storages/portable_storage.h b/contrib/epee/include/storages/portable_storage.h
index 8f4ebc6ae..c244dac19 100644
--- a/contrib/epee/include/storages/portable_storage.h
+++ b/contrib/epee/include/storages/portable_storage.h
@@ -48,12 +48,14 @@ namespace epee
public:
typedef epee::serialization::hsection hsection;
typedef epee::serialization::harray harray;
+ typedef storage_entry meta_entry;
portable_storage(){}
virtual ~portable_storage(){}
hsection open_section(const std::string& section_name, hsection hparent_section, bool create_if_notexist = false);
template<class t_value>
bool get_value(const std::string& value_name, t_value& val, hsection hparent_section);
+ bool get_value(const std::string& value_name, storage_entry& val, hsection hparent_section);
template<class t_value>
bool set_value(const std::string& value_name, const t_value& target, hsection hparent_section);
@@ -221,10 +223,24 @@ namespace epee
//CATCH_ENTRY("portable_storage::template<>get_value", false);
}
//---------------------------------------------------------------------------------------------------------------
+ inline
+ bool portable_storage::get_value(const std::string& value_name, storage_entry& val, hsection hparent_section)
+ {
+ //TRY_ENTRY();
+ if(!hparent_section) hparent_section = &m_root;
+ storage_entry* pentry = find_storage_entry(value_name, hparent_section);
+ if(!pentry)
+ return false;
+
+ val = *pentry;
+ return true;
+ //CATCH_ENTRY("portable_storage::template<>get_value", false);
+ }
+ //---------------------------------------------------------------------------------------------------------------
template<class t_value>
bool portable_storage::set_value(const std::string& value_name, const t_value& v, hsection hparent_section)
{
- BOOST_MPL_ASSERT(( boost::mpl::contains<storage_entry::types, t_value> ));
+ BOOST_MPL_ASSERT(( boost::mpl::contains<boost::mpl::push_front<storage_entry::types, storage_entry>::type, t_value> ));
TRY_ENTRY();
if(!hparent_section)
hparent_section = &m_root;