aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoinrpc.h
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2012-06-22 18:36:42 -0400
committerGavin Andresen <gavinandresen@gmail.com>2012-07-05 12:42:25 -0400
commit899d373b3ccb3003f8f6e518ba4cf7ba4028e58b (patch)
tree2e35daa5f4d32a335fee22b6a8a1b28a5a0df768 /src/bitcoinrpc.h
parent34420d655d8c1cf15e53803ca85e0ac2a2a62fe9 (diff)
downloadbitcoin-899d373b3ccb3003f8f6e518ba4cf7ba4028e58b.tar.xz
RPCTypeCheck method to make type-checking JSON Arrays easier.
Diffstat (limited to 'src/bitcoinrpc.h')
-rw-r--r--src/bitcoinrpc.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/bitcoinrpc.h b/src/bitcoinrpc.h
index 7a8273756d..b71d17ef29 100644
--- a/src/bitcoinrpc.h
+++ b/src/bitcoinrpc.h
@@ -7,6 +7,7 @@
#define _BITCOINRPC_H_ 1
#include <string>
+#include <list>
#include <map>
#include "json/json_spirit_reader_template.h"
@@ -21,6 +22,20 @@ int CommandLineRPC(int argc, char *argv[]);
/** Convert parameter values for RPC call from strings to command-specific JSON objects. */
json_spirit::Array RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams);
+/*
+ Type-check arguments; throws JSONRPCError if wrong type given. Does not check that
+ the right number of arguments are passed, just that any passed are the correct type.
+ Use like: RPCTypeCheck(params, boost::assign::list_of(str_type)(int_type)(obj_type));
+*/
+void RPCTypeCheck(const json_spirit::Array& params,
+ const std::list<json_spirit::Value_type>& typesExpected);
+/*
+ Check for expected keys/value types in an Object.
+ Use like: RPCTypeCheck(object, boost::assign::map_list_of("name", str_type)("value", int_type));
+*/
+void RPCTypeCheck(const json_spirit::Object& o,
+ const std::map<std::string, json_spirit::Value_type>& typesExpected);
+
typedef json_spirit::Value(*rpcfn_type)(const json_spirit::Array& params, bool fHelp);
class CRPCCommand