Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/util.h
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | EvalDescriptorStringOrObject(const UniValue &scanobject, | ||||
FlatSigningProvider &provider); | FlatSigningProvider &provider); | ||||
/** | /** | ||||
* Returns, given services flags, a list of humanly readable (known) | * Returns, given services flags, a list of humanly readable (known) | ||||
* network services. | * network services. | ||||
*/ | */ | ||||
UniValue GetServicesNames(ServiceFlags services); | UniValue GetServicesNames(ServiceFlags services); | ||||
/** | |||||
* Serializing JSON objects depends on the outer type. Only arrays and | |||||
* dictionaries can be nested in json. The top-level outer type is "NONE". | |||||
*/ | |||||
enum class OuterType { | |||||
ARR, | |||||
OBJ, | |||||
NONE, // Only set on first recursion | |||||
}; | |||||
struct RPCArg { | struct RPCArg { | ||||
enum class Type { | enum class Type { | ||||
OBJ, | OBJ, | ||||
ARR, | ARR, | ||||
STR, | STR, | ||||
NUM, | NUM, | ||||
BOOL, | BOOL, | ||||
//! Special type where the user must set the keys e.g. to define | //! Special type where the user must set the keys e.g. to define | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | struct RPCArg { | ||||
//! Should be empty unless it is supposed to override the | //! Should be empty unless it is supposed to override the | ||||
//! auto-generated type strings. Vector length is either 0 | //! auto-generated type strings. Vector length is either 0 | ||||
//! or 2, m_type_str.at(0) will override the type of the | //! or 2, m_type_str.at(0) will override the type of the | ||||
//! value in a key-value pair, m_type_str.at(1) will | //! value in a key-value pair, m_type_str.at(1) will | ||||
//! override the type in the argument description. | //! override the type in the argument description. | ||||
const std::vector<std::string> m_type_str; | const std::vector<std::string> m_type_str; | ||||
RPCArg(const std::string &name, const Type &type, const Fallback &fallback, | RPCArg(const std::string name, const Type type, const Fallback fallback, | ||||
const std::string &description, | const std::string description, | ||||
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_fallback{fallback}, | : m_name{std::move(name)}, m_type{std::move(type)}, | ||||
m_description{description}, | m_fallback{std::move(fallback)}, m_description{std::move( | ||||
m_oneline_description{oneline_description}, m_type_str{type_str} { | description)}, | ||||
m_oneline_description{std::move(oneline_description)}, | |||||
m_type_str{std::move(type_str)} { | |||||
CHECK_NONFATAL(type != Type::ARR && type != Type::OBJ); | CHECK_NONFATAL(type != Type::ARR && type != Type::OBJ); | ||||
} | } | ||||
RPCArg(const std::string &name, const Type &type, const Fallback &fallback, | RPCArg(const std::string name, const Type type, const Fallback fallback, | ||||
const std::string &description, const std::vector<RPCArg> &inner, | const std::string description, const std::vector<RPCArg> inner, | ||||
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_fallback{fallback}, | : m_name{std::move(name)}, m_type{std::move(type)}, m_inner{std::move( | ||||
m_description{description}, | inner)}, | ||||
m_oneline_description{oneline_description}, m_type_str{type_str} { | m_fallback{std::move(fallback)}, m_description{std::move( | ||||
description)}, | |||||
m_oneline_description{std::move(oneline_description)}, | |||||
m_type_str{std::move(type_str)} { | |||||
CHECK_NONFATAL(type == Type::ARR || type == Type::OBJ); | CHECK_NONFATAL(type == Type::ARR || type == Type::OBJ); | ||||
} | } | ||||
bool IsOptional() const; | bool IsOptional() const; | ||||
/** | /** | ||||
* Return the type string of the argument. | * Return the type string of the argument. | ||||
* Set oneline to allow it to be overridden by a custom oneline type string | * Set oneline to allow it to be overridden by a custom oneline type string | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |