Skip to content

iris::Params Class Reference

Doxygen 1.15.0 generates this reference during each site build from the public headers. The C++ guide shows the API in use.

Values for the param statements of a reader spec, as name and value strings in the order they were first set (Specification §9.1). More...

#include <iris/params.hpp>

Public Member Functions

 Params ()
 No values.
 Params (std::pmr::memory_resource &memory)
 No values, which will be allocated from memory.
 Params (std::initializer_list< std::pair< std::string_view, std::string_view > > pairs)
 The values pairs, set in order.
 Params (std::initializer_list< std::pair< std::string_view, std::string_view > > pairs, std::pmr::memory_resource &memory)
 The values pairs, set in order and allocated from memory.
void set (std::string_view name, std::string_view value)
 Set name to value. A name that is already set keeps its place.
template<class H, class T>
requires detail::ParamHandle<H> && detail::ParamAccepts<typename H::Value, T>
void set (const H &handle, const T &value)
 Set the parameter of handle to value, formatted as the conversion in Specification §9.2 expects.
std::size_t size () const
 Return the number of names set.
std::string_view name (std::size_t i) const
 Return name i, in the order of first setting; throws AccessError if there are not that many names.
std::optional< std::string_view > get (std::string_view name) const
 Return the value of name, or nothing if it is not set.

Detailed Description

Values for the param statements of a reader spec, as name and value strings in the order they were first set (Specification §9.1).

A value is set by name as a string, or through a typed handle as a value of the handle's type, such as a handle that param("scale", 3) returns in <iris/build.hpp>.

The values are allocated from the memory resource given at construction: the default resource unless another is given, which must outlive the values. Copies are cheap: they share the values until one of them changes.

Constructor & Destructor Documentation

Params() [1/4]

iris::Params::Params ( )

No values.

Params() [2/4]

iris::Params::Params ( std::pmr::memory_resource & memory)
explicit

No values, which will be allocated from memory.

Params() [3/4]

iris::Params::Params ( std::initializer_list< std::pair< std::string_view, std::string_view > > pairs)

The values pairs, set in order.

Params() [4/4]

iris::Params::Params ( std::initializer_list< std::pair< std::string_view, std::string_view > > pairs,
std::pmr::memory_resource & memory )

The values pairs, set in order and allocated from memory.

Member Function Documentation

get()

std::optional< std::string_view > iris::Params::get ( std::string_view name) const
nodiscard

Return the value of name, or nothing if it is not set.

name()

std::string_view iris::Params::name ( std::size_t i) const
nodiscard

Return name i, in the order of first setting; throws AccessError if there are not that many names.

set() [1/2]

template<class H, class T>
requires detail::ParamHandle<H> && detail::ParamAccepts<typename H::Value, T>
void iris::Params::set ( const H & handle,
const T & value )
inline

Set the parameter of handle to value, formatted as the conversion in Specification §9.2 expects.

Only a value of the handle's type compiles: an integer for an int handle, an integer or a float for a float or num handle, a string for a string handle, and any of them for a handle of unknown type. A float is written in the shortest form that converts back to the same number, with .0 on a whole number so that it stays a float; a negative zero keeps its sign. A float that is not finite, or nonzero and below the smallest normal float, fails the conversion when the spec reads. A name that is already set keeps its place.

set() [2/2]

void iris::Params::set ( std::string_view name,
std::string_view value )

Set name to value. A name that is already set keeps its place.

size()

std::size_t iris::Params::size ( ) const
nodiscard

Return the number of names set.