LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
line::reg::Args Class Reference

Named-argument reader over the parsed JSON object. More...

#include <line/reg/api_json.h>

Public Member Functions

 Args (const Json &j, std::string function)
bool has (const char *key) const
const Jsonget (const char *key)
 Required argument; throws when absent.
const Jsonopt (const char *key)
 Optional argument; returns nullptr when absent.
template<class T>
Matrix< T > matrix (const char *key)
template<class T>
Matrix< T > matrix_or_empty (const char *key)
template<class T>
std::vector< T > vector_or_empty (const char *key)
template<class T>
std::vector< T > vector (const char *key)
 Required vector argument; absent is an error, not an empty vector.
template<class T>
std::vector< Matrix< T > > matrices (const char *key)
 Required list of matrices, e.g.
template<class T>
std::vector< Matrix< T > > matrices_or_empty (const char *key)
template<class T>
number (const char *key)
 Required numeric argument, at the arithmetic of the call.
std::size_t count (const char *key)
 A required nonnegative count.
std::size_t count (const char *key, std::size_t fallback)
unsigned uinteger (const char *key)
 The same as count(), for the arguments the port declares unsigned.
unsigned uinteger (const char *key, unsigned fallback)
int required_integer (const char *key)
bool boolean (const char *key, bool fallback)
 A flag.
std::string text (const char *key, const std::string &fallback)
 A string-valued option, e.g.
std::vector< int > ints (const char *key)
std::vector< int > ints_or_empty (const char *key)
int integer (const char *key, int fallback)
template<class T>
scalar (const char *key, const T &fallback)
void unsupported (const char *key, const std::string &why)
 Refuse an argument the JSON boundary cannot carry, naming it, rather than proceeding as if it had not been given.
void done () const

Detailed Description

Named-argument reader over the parsed JSON object.

Every read marks the key; done() then refuses any key the function did not ask for, naming it and listing what the function does accept. Silently ignoring an unknown key is how a caller ends up with the default value of the argument they thought they were setting.

Definition at line 391 of file api_json.h.

Constructor & Destructor Documentation

◆ Args()

line::reg::Args::Args ( const Json & j,
std::string function )
inline

Definition at line 393 of file api_json.h.

Member Function Documentation

◆ boolean()

bool line::reg::Args::boolean ( const char * key,
bool fallback )
inline

A flag.

Accepts a JSON boolean or the integers 0 and 1, nothing else.

Definition at line 505 of file api_json.h.

References line::InputError::InputError(), line::reg::int_vector_from_json(), and opt().

◆ count() [1/2]

std::size_t line::reg::Args::count ( const char * key)
inline

A required nonnegative count.

Refuses a negative value naming the argument rather than wrapping it around into a huge unsigned.

Definition at line 475 of file api_json.h.

References line::InputError::InputError(), and required_integer().

Referenced by count(), uinteger(), and uinteger().

◆ count() [2/2]

std::size_t line::reg::Args::count ( const char * key,
std::size_t fallback )
inline

Definition at line 483 of file api_json.h.

References count(), and has().

◆ done()

void line::reg::Args::done ( ) const
inline

Definition at line 561 of file api_json.h.

References line::InputError::InputError().

◆ get()

const Json & line::reg::Args::get ( const char * key)
inline

Required argument; throws when absent.

Definition at line 403 of file api_json.h.

References line::InputError::InputError().

Referenced by ints(), matrices(), matrix(), number(), required_integer(), and vector().

◆ has()

bool line::reg::Args::has ( const char * key) const
inline

Definition at line 400 of file api_json.h.

Referenced by count(), and matrices_or_empty().

◆ integer()

int line::reg::Args::integer ( const char * key,
int fallback )
inline

◆ ints()

std::vector< int > line::reg::Args::ints ( const char * key)
inline

Definition at line 525 of file api_json.h.

References get(), and line::reg::int_vector_from_json().

◆ ints_or_empty()

std::vector< int > line::reg::Args::ints_or_empty ( const char * key)
inline

Definition at line 529 of file api_json.h.

References line::reg::int_vector_from_json(), and opt().

◆ matrices()

template<class T>
std::vector< Matrix< T > > line::reg::Args::matrices ( const char * key)
inline

Required list of matrices, e.g.

the per-class D1c of an MMAP. A single matrix is NOT silently promoted to a one-element list: the two shapes mean different models and the caller must say which one it meant.

Definition at line 446 of file api_json.h.

References get(), line::InputError::InputError(), and line::reg::matrix_from_json().

Referenced by matrices_or_empty().

◆ matrices_or_empty()

template<class T>
std::vector< Matrix< T > > line::reg::Args::matrices_or_empty ( const char * key)
inline

Definition at line 459 of file api_json.h.

References has(), and matrices().

◆ matrix()

template<class T>
Matrix< T > line::reg::Args::matrix ( const char * key)
inline

Definition at line 418 of file api_json.h.

References get(), and line::reg::matrix_from_json().

◆ matrix_or_empty()

template<class T>
Matrix< T > line::reg::Args::matrix_or_empty ( const char * key)
inline

Definition at line 423 of file api_json.h.

References line::Matrix< T >::Matrix(), line::reg::matrix_from_json(), and opt().

◆ number()

template<class T>
T line::reg::Args::number ( const char * key)
inline

Required numeric argument, at the arithmetic of the call.

Definition at line 467 of file api_json.h.

References get(), and line::reg::number_from_json().

◆ opt()

const Json * line::reg::Args::opt ( const char * key)
inline

Optional argument; returns nullptr when absent.

Definition at line 411 of file api_json.h.

Referenced by boolean(), integer(), ints_or_empty(), matrix_or_empty(), scalar(), text(), and vector_or_empty().

◆ required_integer()

int line::reg::Args::required_integer ( const char * key)
inline

Definition at line 498 of file api_json.h.

References get(), line::InputError::InputError(), and line::reg::int_vector_from_json().

Referenced by count().

◆ scalar()

template<class T>
T line::reg::Args::scalar ( const char * key,
const T & fallback )
inline

Definition at line 544 of file api_json.h.

References line::reg::number_from_json(), and opt().

◆ text()

std::string line::reg::Args::text ( const char * key,
const std::string & fallback )
inline

A string-valued option, e.g.

a method or convention name.

Definition at line 516 of file api_json.h.

References line::InputError::InputError(), and opt().

◆ uinteger() [1/2]

unsigned line::reg::Args::uinteger ( const char * key)
inline

The same as count(), for the arguments the port declares unsigned.

Definition at line 492 of file api_json.h.

References count().

◆ uinteger() [2/2]

unsigned line::reg::Args::uinteger ( const char * key,
unsigned fallback )
inline

Definition at line 494 of file api_json.h.

References count().

◆ unsupported()

void line::reg::Args::unsupported ( const char * key,
const std::string & why )
inline

Refuse an argument the JSON boundary cannot carry, naming it, rather than proceeding as if it had not been given.

Definition at line 553 of file api_json.h.

References line::UnsupportedError::UnsupportedError().

◆ vector()

template<class T>
std::vector< T > line::reg::Args::vector ( const char * key)
inline

Required vector argument; absent is an error, not an empty vector.

Definition at line 436 of file api_json.h.

References get(), and line::reg::vector_from_json().

◆ vector_or_empty()

template<class T>
std::vector< T > line::reg::Args::vector_or_empty ( const char * key)
inline

Definition at line 429 of file api_json.h.

References opt(), and line::reg::vector_from_json().


The documentation for this class was generated from the following file: