diff options
| author | MarcoFalke <[email protected]> | 2018-12-21 12:29:36 -0500 |
|---|---|---|
| committer | MarcoFalke <[email protected]> | 2019-01-25 14:16:07 -0500 |
| commit | faa1522e5ec5ec53b2b2b1ed36c11e84939bbb13 (patch) | |
| tree | 8575b7dbb7409b486e5e38f575bf5ecebc06adb3 /src/rpc/util.h | |
| parent | Merge #15223: Doc: add information about security to the JSON-RPC doc (diff) | |
| download | discoin-faa1522e5ec5ec53b2b2b1ed36c11e84939bbb13.tar.xz discoin-faa1522e5ec5ec53b2b2b1ed36c11e84939bbb13.zip | |
RPCHelpMan: Pass through Result and Examples
Diffstat (limited to 'src/rpc/util.h')
| -rw-r--r-- | src/rpc/util.h | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/src/rpc/util.h b/src/rpc/util.h index 9e97b3ae0..4a9d4be78 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 |