Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/util.h
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | enum class Type { | ||||
STR_HEX, | STR_HEX, | ||||
}; | }; | ||||
//! The name of the arg (can be empty for inner args) | //! The name of the arg (can be empty for inner args) | ||||
const std::string m_name; | const std::string m_name; | ||||
const Type m_type; | const Type m_type; | ||||
//! Only used for arrays or dicts | //! Only used for arrays or dicts | ||||
const std::vector<RPCArg> m_inner; | const std::vector<RPCArg> m_inner; | ||||
const bool m_optional; | const bool m_optional; | ||||
//! Should be empty unless it is supposed to override the auto-generated | |||||
RPCArg(const std::string &name, const Type &type, const bool optional) | //! summary line | ||||
: m_name{name}, m_type{type}, m_optional{optional} { | const std::string m_oneline_description; | ||||
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); | assert(type != Type::ARR && type != Type::OBJ); | ||||
} | } | ||||
RPCArg(const std::string &name, const Type &type, | RPCArg(const std::string &name, const Type &type, | ||||
const std::vector<RPCArg> &inner, const bool optional) | const std::vector<RPCArg> &inner, const bool optional, | ||||
: m_name{name}, m_type{type}, m_inner{inner}, m_optional{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); | assert(type == Type::ARR || type == Type::OBJ); | ||||
} | } | ||||
std::string ToString() const; | std::string ToString() const; | ||||
private: | private: | ||||
std::string ToStringObj() const; | std::string ToStringObj() const; | ||||
}; | }; | ||||
class RPCHelpMan { | class RPCHelpMan { | ||||
public: | public: | ||||
RPCHelpMan(const std::string &name, const std::vector<RPCArg> &args) | RPCHelpMan(const std::string &name, const std::string &description, | ||||
: m_name{name}, m_args{args} {} | const std::vector<RPCArg> &args) | ||||
: m_name{name}, m_description{description}, m_args{args} {} | |||||
std::string ToString() const; | std::string ToString() const; | ||||
private: | private: | ||||
const std::string m_name; | const std::string m_name; | ||||
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 |