#include <util.h>
|
| | RPCHelpMan (std::string name, std::string description, std::vector< RPCArg > args, RPCResults results, RPCExamples examples) |
| | RPCHelpMan (std::string name, std::string description, std::vector< RPCArg > args, RPCResults results, RPCExamples examples, RPCMethodImpl fun) |
| UniValue | HandleRequest (const JSONRPCRequest &request) const |
| template<typename R> |
| auto | Arg (std::string_view key) const |
| | Helper to get a required or default-valued request argument.
|
| template<typename R> |
| auto | MaybeArg (std::string_view key) const |
| | Helper to get an optional request argument.
|
| std::string | ToString () const |
| UniValue | GetArgMap () const |
| | Return the named args that need to be converted from string to another JSON type.
|
| bool | IsValidNumArgs (size_t num_args) const |
| | If the supplied number of args is neither too small nor too high.
|
| std::vector< std::pair< std::string, bool > > | GetArgNames () const |
| | Return list of arguments and whether they are named-only.
|
|
| template<typename R> |
| R | ArgValue (size_t i) const |
| size_t | GetParamIndex (std::string_view key) const |
| | Return positional index of a parameter using its name as key.
|
Definition at line 418 of file util.h.
◆ RPCMethodImpl
◆ RPCHelpMan() [1/2]
| RPCHelpMan::RPCHelpMan |
( |
std::string | name, |
|
|
std::string | description, |
|
|
std::vector< RPCArg > | args, |
|
|
RPCResults | results, |
|
|
RPCExamples | examples ) |
◆ RPCHelpMan() [2/2]
◆ Arg()
template<typename R>
| auto RPCHelpMan::Arg |
( |
std::string_view | key | ) |
const |
|
inline |
Helper to get a required or default-valued request argument.
Use this function when the argument is required or when it has a default value. If the argument is optional and may not be provided, use MaybeArg instead.
This function only works during m_fun(), i.e., it should only be used in RPC method implementations. It internally checks whether the user-passed argument isNull() and parses (from JSON) and returns the user-passed argument, or the default value derived from the RPCArg documentation.
The instantiation of this helper for type R must match the corresponding RPCArg::Type.
- Returns
- The value of the RPC argument (or the default value) cast to type R.
- See also
- MaybeArg for handling optional arguments without default values.
Definition at line 444 of file util.h.
◆ ArgValue()
template<typename R>
| R RPCHelpMan::ArgValue |
( |
size_t | i | ) |
const |
|
private |
◆ GetArgMap()
| UniValue RPCHelpMan::GetArgMap |
( |
| ) |
const |
Return the named args that need to be converted from string to another JSON type.
Definition at line 833 of file util.cpp.
◆ GetArgNames()
| std::vector< std::pair< std::string, bool > > RPCHelpMan::GetArgNames |
( |
| ) |
const |
Return list of arguments and whether they are named-only.
Definition at line 745 of file util.cpp.
◆ GetParamIndex()
| size_t RPCHelpMan::GetParamIndex |
( |
std::string_view | key | ) |
const |
|
private |
Return positional index of a parameter using its name as key.
Definition at line 760 of file util.cpp.
◆ HandleRequest()
◆ IsValidNumArgs()
| bool RPCHelpMan::IsValidNumArgs |
( |
size_t | num_args | ) |
const |
If the supplied number of args is neither too small nor too high.
Definition at line 733 of file util.cpp.
◆ MaybeArg()
template<typename R>
| auto RPCHelpMan::MaybeArg |
( |
std::string_view | key | ) |
const |
|
inline |
Helper to get an optional request argument.
Use this function when the argument is optional and does not have a default value. If the argument is required or has a default value, use Arg instead.
This function only works during m_fun(), i.e., it should only be used in RPC method implementations. It internally checks whether the user-passed argument isNull() and parses (from JSON) and returns the user-passed argument, or a falsy value if no argument was passed.
The instantiation of this helper for type R must match the corresponding RPCArg::Type.
- Returns
- For trivially copyable types, a std::optional<R> is returned. For other types, a R* pointer to the argument is returned. If the argument is not provided, std::nullopt or a null pointer is returned.
- See also
- Arg for handling arguments that are required or have a default value.
Definition at line 476 of file util.h.
◆ ToString()
| std::string RPCHelpMan::ToString |
( |
| ) |
const |
◆ m_args
| const std::vector<RPCArg> RPCHelpMan::m_args |
|
private |
◆ m_description
| const std::string RPCHelpMan::m_description |
|
private |
◆ m_examples
◆ m_fun
◆ m_name
| const std::string RPCHelpMan::m_name |
◆ m_req
◆ m_results
The documentation for this class was generated from the following files: