Bitcoin Core  24.99.0
P2P Digital Currency
Public Types | Public Member Functions | Public Attributes | List of all members
RPCArg Struct Reference

#include <util.h>

Collaboration diagram for RPCArg:
[legend]

Public Types

enum class  Type {
  OBJ , ARR , STR , NUM ,
  BOOL , OBJ_USER_KEYS , AMOUNT , STR_HEX ,
  RANGE
}
 
enum class  Optional { NO , OMITTED_NAMED_ARG , OMITTED }
 
using DefaultHint = std::string
 
using Default = UniValue
 
using Fallback = std::variant< Optional, DefaultHint, Default >
 

Public Member Functions

 RPCArg (const std::string name, const Type type, const Fallback fallback, const std::string description, RPCArgOptions opts={})
 
 RPCArg (const std::string name, const Type type, const Fallback fallback, const std::string description, const std::vector< RPCArg > inner, RPCArgOptions opts={})
 
bool IsOptional () const
 
std::string GetFirstName () const
 Return the first of all aliases. More...
 
std::string GetName () const
 Return the name, throws when there are aliases. More...
 
std::string ToString (bool oneline) const
 Return the type string of the argument. More...
 
std::string ToStringObj (bool oneline) const
 Return the type string of the argument when it is in an object (dict). More...
 
std::string ToDescriptionString () const
 Return the description string, including the argument type and whether the argument is required. More...
 

Public Attributes

const std::string m_names
 The name of the arg (can be empty for inner args, can contain multiple aliases separated by | for named request arguments) More...
 
const Type m_type
 
const std::vector< RPCArgm_inner
 Only used for arrays or dicts. More...
 
const Fallback m_fallback
 
const std::string m_description
 
const RPCArgOptions m_opts
 

Detailed Description

Definition at line 146 of file util.h.

Member Typedef Documentation

◆ Default

Definition at line 176 of file util.h.

◆ DefaultHint

using RPCArg::DefaultHint = std::string

Definition at line 175 of file util.h.

◆ Fallback

using RPCArg::Fallback = std::variant<Optional, DefaultHint, Default>

Definition at line 177 of file util.h.

Member Enumeration Documentation

◆ Optional

enum RPCArg::Optional
strong
Enumerator
NO 

Required arg.

OMITTED_NAMED_ARG 

Optional arg that is a named argument and has a default value of null.

When possible, the default value should be specified.

OMITTED 

Optional argument with default value omitted because they are implicitly clear.

That is, elements in an array or object may not exist by default. When possible, the default value should be specified.

Definition at line 159 of file util.h.

◆ Type

enum RPCArg::Type
strong
Enumerator
OBJ 
ARR 
STR 
NUM 
BOOL 
OBJ_USER_KEYS 

Special type where the user must set the keys e.g. to define multiple addresses; as opposed to e.g. an options object where the keys are predefined.

AMOUNT 

Special type representing a floating point amount (can be either NUM or STR)

STR_HEX 

Special type that is a STR with only hex chars.

RANGE 

Special type that is a NUM or [NUM,NUM].

Definition at line 147 of file util.h.

Constructor & Destructor Documentation

◆ RPCArg() [1/2]

RPCArg::RPCArg ( const std::string  name,
const Type  type,
const Fallback  fallback,
const std::string  description,
RPCArgOptions  opts = {} 
)
inline

Definition at line 186 of file util.h.

◆ RPCArg() [2/2]

RPCArg::RPCArg ( const std::string  name,
const Type  type,
const Fallback  fallback,
const std::string  description,
const std::vector< RPCArg inner,
RPCArgOptions  opts = {} 
)
inline

Definition at line 201 of file util.h.

Member Function Documentation

◆ GetFirstName()

std::string RPCArg::GetFirstName ( ) const

Return the first of all aliases.

Definition at line 680 of file util.cpp.

Here is the caller graph for this function:

◆ GetName()

std::string RPCArg::GetName ( ) const

Return the name, throws when there are aliases.

Definition at line 685 of file util.cpp.

Here is the caller graph for this function:

◆ IsOptional()

bool RPCArg::IsOptional ( ) const

Definition at line 691 of file util.cpp.

◆ ToDescriptionString()

std::string RPCArg::ToDescriptionString ( ) const

Return the description string, including the argument type and whether the argument is required.

Definition at line 700 of file util.cpp.

Here is the caller graph for this function:

◆ ToString()

std::string RPCArg::ToString ( bool  oneline) const

Return the type string of the argument.

Set oneline to allow it to be overridden by a custom oneline type string (m_opts.oneline_description).

Definition at line 989 of file util.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToStringObj()

std::string RPCArg::ToStringObj ( bool  oneline) const

Return the type string of the argument when it is in an object (dict).

Set oneline to get the oneline representation (less whitespace)

Definition at line 952 of file util.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_description

const std::string RPCArg::m_description

Definition at line 183 of file util.h.

◆ m_fallback

const Fallback RPCArg::m_fallback

Definition at line 182 of file util.h.

◆ m_inner

const std::vector<RPCArg> RPCArg::m_inner

Only used for arrays or dicts.

Definition at line 181 of file util.h.

◆ m_names

const std::string RPCArg::m_names

The name of the arg (can be empty for inner args, can contain multiple aliases separated by | for named request arguments)

Definition at line 179 of file util.h.

◆ m_opts

const RPCArgOptions RPCArg::m_opts

Definition at line 184 of file util.h.

◆ m_type

const Type RPCArg::m_type

Definition at line 180 of file util.h.


The documentation for this struct was generated from the following files: