Class EnvFormat

Inheritance Relationships

Base Type

Class Documentation

class uconfig::EnvFormat : public uconfig::Format

Environment format.

Parsed values from env, emit into std::map.

Public Types

using source_type = void

Env does’t have a source type.

using dest_type = std::map<std::string, std::string>

std::map<std::string, std::string> to emit to.

Public Functions

template<typename T>
std::optional<T> Parse(const source_type*, const std::string &path) const

Parse the value with name path from environment.

Template Parameters

T – Type to parse.

Parameters

[in] path – Name of the value.

Returns

Value wrapped in std::optional or std::nullopt.

template<typename T>
void Emit(dest_type *dest, const std::string &path, const T &value) const

Emit the (path, value) pair into dest.

Template Parameters

T – Type to emit.

Parameters
  • [in] dest – Map to emit to.

  • [in] path – Key to emplace in the map.

  • [in] value – Value to emit.

inline virtual std::string VectorElementPath(const std::string &vector_path, std::size_t index) const noexcept override

Construct array element name using ‘_’ as delimiter.

Parameters
  • [in] vector_path – Name array itself.

  • [in] index – Position in the array to make path to.

Returns

‘_’ delimited name to the element at index, e.g. “ARRAY_0” for vector_path = “ARRAY” and index = 0.

Public Static Attributes

static const std::string name = "[ENV]"

Name of the format. Used to form nice error-strings.