aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/util.h
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-12-21 12:29:36 -0500
committerMarcoFalke <falke.marco@gmail.com>2019-01-25 14:16:07 -0500
commitfaa1522e5ec5ec53b2b2b1ed36c11e84939bbb13 (patch)
tree8575b7dbb7409b486e5e38f575bf5ecebc06adb3 /src/rpc/util.h
parent5eb32d23841bbcd8eaf7ba49dc4ddfd822bd4773 (diff)
downloadbitcoin-faa1522e5ec5ec53b2b2b1ed36c11e84939bbb13.tar.xz
RPCHelpMan: Pass through Result and Examples
Diffstat (limited to 'src/rpc/util.h')
-rw-r--r--src/rpc/util.h56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/rpc/util.h b/src/rpc/util.h
index 9e97b3ae0b..4a9d4be787 100644
--- a/src/rpc/util.h
+++ b/src/rpc/util.h
@@ -106,10 +106,62 @@ struct RPCArg {
std::string ToDescriptionString(bool implicitly_required = false) const;
};
+struct RPCResult {
+ const std::string m_cond;
+ const std::string m_result;
+
+ explicit RPCResult(std::string result)
+ : m_cond{}, m_result{std::move(result)}
+ {
+ assert(!m_result.empty());
+ }
+
+ RPCResult(std::string cond, std::string result)
+ : m_cond{std::move(cond)}, m_result{std::move(result)}
+ {
+ assert(!m_cond.empty());
+ assert(!m_result.empty());
+ }
+};
+
+struct RPCResults {
+ const std::vector<RPCResult> m_results;
+
+ RPCResults()
+ : m_results{}
+ {
+ }
+
+ RPCResults(RPCResult result)
+ : m_results{{result}}
+ {
+ }
+
+ RPCResults(std::initializer_list<RPCResult> results)
+ : m_results{results}
+ {
+ }
+
+ /**
+ * Return the description string.
+ */
+ std::string ToDescriptionString() const;
+};
+
+struct RPCExamples {
+ const std::string m_examples;
+ RPCExamples(
+ std::string examples)
+ : m_examples(std::move(examples))
+ {
+ }
+ std::string ToDescriptionString() const;
+};
+
class RPCHelpMan
{
public:
- RPCHelpMan(const std::string& name, const std::string& description, const std::vector<RPCArg>& args);
+ RPCHelpMan(std::string name, std::string description, std::vector<RPCArg> args, RPCResults results, RPCExamples examples);
std::string ToString() const;
@@ -117,6 +169,8 @@ private:
const std::string m_name;
const std::string m_description;
const std::vector<RPCArg> m_args;
+ const RPCResults m_results;
+ const RPCExamples m_examples;
};
#endif // BITCOIN_RPC_UTIL_H