diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-01-18 01:05:58 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-03-04 22:38:03 +0000 |
commit | e396146aeebd61d6a26003045d554f6e94d5f028 (patch) | |
tree | d0abbc7b2feb1325435c149c9f9309063e9fc670 /contrib | |
parent | various: remove unused variables (diff) | |
download | monero-e396146aeebd61d6a26003045d554f6e94d5f028.tar.xz |
default initialize rpc structures
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/epee/demo/iface/transport_defs.h | 12 | ||||
-rw-r--r-- | contrib/epee/include/misc_language.h | 5 | ||||
-rw-r--r-- | contrib/epee/include/net/jsonrpc_structs.h | 14 | ||||
-rw-r--r-- | contrib/epee/tests/src/net/test_net.h | 13 |
4 files changed, 35 insertions, 9 deletions
diff --git a/contrib/epee/demo/iface/transport_defs.h b/contrib/epee/demo/iface/transport_defs.h index 746694aa3..8638b5db9 100644 --- a/contrib/epee/demo/iface/transport_defs.h +++ b/contrib/epee/demo/iface/transport_defs.h @@ -81,7 +81,7 @@ namespace demo { const static int ID = 1000; - struct request + struct request_t { std::string example_string_data; some_test_data sub; @@ -91,9 +91,10 @@ namespace demo KV_SERIALIZE(sub) END_KV_SERIALIZE_MAP() }; + typedef epee::misc_utils::struct_init<request_t> request; - struct response + struct response_t { bool m_success; std::list<some_test_data> subs; @@ -104,6 +105,7 @@ namespace demo END_KV_SERIALIZE_MAP() }; }; + typedef epee::misc_utils::struct_init<response_t> response; @@ -111,7 +113,7 @@ namespace demo { const static int ID = 1001; - struct request + struct request_t { std::string example_string_data2; @@ -119,8 +121,9 @@ namespace demo KV_SERIALIZE(example_string_data2) END_KV_SERIALIZE_MAP() }; + typedef epee::misc_utils::struct_init<request_t> request; - struct response + struct response_t { bool m_success; @@ -129,6 +132,7 @@ namespace demo KV_SERIALIZE(m_success) END_KV_SERIALIZE_MAP() }; + typedef epee::misc_utils::struct_init<response_t> response; }; diff --git a/contrib/epee/include/misc_language.h b/contrib/epee/include/misc_language.h index 7e4eb337d..5f7202150 100644 --- a/contrib/epee/include/misc_language.h +++ b/contrib/epee/include/misc_language.h @@ -159,5 +159,10 @@ namespace misc_utils return slc; } + template<typename T> struct struct_init: T + { + struct_init(): T{} {} + }; + } } diff --git a/contrib/epee/include/net/jsonrpc_structs.h b/contrib/epee/include/net/jsonrpc_structs.h index 9df9e2596..b61c369f2 100644 --- a/contrib/epee/include/net/jsonrpc_structs.h +++ b/contrib/epee/include/net/jsonrpc_structs.h @@ -18,6 +18,8 @@ namespace epee epee::serialization::storage_entry id; t_param params; + request(): id{}, params{} {} + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(jsonrpc) KV_SERIALIZE(id) @@ -30,6 +32,9 @@ namespace epee { int64_t code; std::string message; + + error(): code(0) {} + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(code) KV_SERIALIZE(message) @@ -55,6 +60,9 @@ namespace epee t_param result; epee::serialization::storage_entry id; t_error error; + + response(): result{}, id(), error{} {} + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(jsonrpc) KV_SERIALIZE(id) @@ -69,6 +77,9 @@ namespace epee std::string jsonrpc; t_param result; epee::serialization::storage_entry id; + + response(): result{}, id{} {} + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(jsonrpc) KV_SERIALIZE(id) @@ -82,6 +93,9 @@ namespace epee std::string jsonrpc; t_error error; epee::serialization::storage_entry id; + + response(): error{}, id{} {} + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(jsonrpc) KV_SERIALIZE(id) diff --git a/contrib/epee/tests/src/net/test_net.h b/contrib/epee/tests/src/net/test_net.h index 51b1f1ec6..f99639afc 100644 --- a/contrib/epee/tests/src/net/test_net.h +++ b/contrib/epee/tests/src/net/test_net.h @@ -62,7 +62,7 @@ namespace tests { const static int ID = 1000; - struct request + struct request_t { std::string example_string_data; @@ -75,9 +75,9 @@ namespace tests SERIALIZE_T(sub) END_NAMED_SERIALIZE_MAP() }; + typedef epee::misc_utils::struct_init<request_t> request; - - struct response + struct response_t { bool m_success; uint64_t example_id_data; @@ -89,13 +89,14 @@ namespace tests SERIALIZE_STL_CONTAINER_T(subs) END_NAMED_SERIALIZE_MAP() }; + typedef epee::misc_utils::struct_init<response_t> response; }; struct COMMAND_EXAMPLE_2 { const static int ID = 1001; - struct request + struct request_t { std::string example_string_data2; uint64_t example_id_data; @@ -105,8 +106,9 @@ namespace tests SERIALIZE_STL_ANSI_STRING(example_string_data2) END_NAMED_SERIALIZE_MAP() }; + typedef epee::misc_utils::struct_init<request_t> request; - struct response + struct response_t { bool m_success; uint64_t example_id_data; @@ -116,6 +118,7 @@ namespace tests SERIALIZE_POD(m_success) END_NAMED_SERIALIZE_MAP() }; + typedef epee::misc_utils::struct_init<response_t> response; }; typedef boost::uuids::uuid uuid; |