Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/util.h
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | RPCArg(const std::string &name, const Type &type, const bool opt, | ||||
const std::string &oneline_description = "", | const std::string &oneline_description = "", | ||||
const std::vector<std::string> &type_str = {}) | const std::vector<std::string> &type_str = {}) | ||||
: m_name{name}, m_type{type}, m_inner{inner}, m_optional{opt}, | : m_name{name}, m_type{type}, m_inner{inner}, m_optional{opt}, | ||||
m_default_value{default_val}, m_description{description}, | m_default_value{default_val}, m_description{description}, | ||||
m_oneline_description{oneline_description}, m_type_str{type_str} { | m_oneline_description{oneline_description}, m_type_str{type_str} { | ||||
assert(type == Type::ARR || type == Type::OBJ); | assert(type == Type::ARR || type == Type::OBJ); | ||||
} | } | ||||
// Remove once PR14796 backport is completed | |||||
RPCArg(const std::string &name, const Type &type, const bool optional, | |||||
const std::string &oneline_description = "") | |||||
: m_name{name}, m_type{type}, m_optional{optional}, | |||||
m_oneline_description{oneline_description} { | |||||
assert(type != Type::ARR && type != Type::OBJ); | |||||
} | |||||
// Remove once PR14796 backport is completed | |||||
RPCArg(const std::string &name, const Type &type, | |||||
const std::vector<RPCArg> &inner, const bool optional, | |||||
const std::string &oneline_description = "") | |||||
: m_name{name}, m_type{type}, m_inner{inner}, m_optional{optional}, | |||||
m_oneline_description{oneline_description} { | |||||
assert(type == Type::ARR || type == Type::OBJ); | |||||
} | |||||
// Remove once PR14796 backport is completed | |||||
std::string ToString() const; | |||||
/** | /** | ||||
* Return the type string of the argument. | * Return the type string of the argument. | ||||
* Set oneline to allow it to be overrided by a custom oneline type string | * Set oneline to allow it to be overrided by a custom oneline type string | ||||
* (m_oneline_description). | * (m_oneline_description). | ||||
*/ | */ | ||||
std::string ToString(bool oneline) const; | std::string ToString(bool oneline) const; | ||||
/** | /** | ||||
* Return the type string of the argument when it is in an object (dict). | * Return the type string of the argument when it is in an object (dict). | ||||
* Set oneline to get the oneline representation (less whitespace) | * Set oneline to get the oneline representation (less whitespace) | ||||
*/ | */ | ||||
std::string ToStringObj(bool oneline) const; | std::string ToStringObj(bool oneline) const; | ||||
/** | /** | ||||
* Return the description string, including the argument type and whether | * Return the description string, including the argument type and whether | ||||
* the argument is required. | * the argument is required. | ||||
* implicitly_required is set for arguments in an array, which are neither | * implicitly_required is set for arguments in an array, which are neither | ||||
* optional nor required. | * optional nor required. | ||||
*/ | */ | ||||
std::string ToDescriptionString(bool implicitly_required = false) const; | std::string ToDescriptionString(bool implicitly_required = false) const; | ||||
private: | |||||
// Remove once PR14796 backport is completed | |||||
std::string ToStringObj() const; | |||||
}; | }; | ||||
class RPCHelpMan { | class RPCHelpMan { | ||||
public: | public: | ||||
RPCHelpMan(const std::string &name, const std::string &description, | RPCHelpMan(const std::string &name, const std::string &description, | ||||
const std::vector<RPCArg> &args) | const std::vector<RPCArg> &args) | ||||
: m_name{name}, m_description{description}, m_args{args} {} | : m_name{name}, m_description{description}, m_args{args} {} | ||||
std::string ToString() const; | std::string ToString() const; | ||||
// Remove once PR14796 backport is completed | |||||
std::string ToStringWithArgs() const; | |||||
private: | private: | ||||
const std::string m_name; | const std::string m_name; | ||||
const std::string m_description; | const std::string m_description; | ||||
const std::vector<RPCArg> m_args; | const std::vector<RPCArg> m_args; | ||||
}; | }; | ||||
#endif // BITCOIN_RPC_UTIL_H | #endif // BITCOIN_RPC_UTIL_H |