Template Class VariableIface

Inheritance Relationships

Base Type

Class Documentation

template<typename T, typename Format>
class uconfig::VariableIface : public uconfig::Interface<Format>

Interface for uconfig::Variable objects.

tparam T

Variable wrapped type.

tparam Format

Format this interface interacts with.

Public Functions

VariableIface(const std::string &variable_path, Variable<T> *variable)

Constructor.

Note

Does not own variable, should not outlive it.

Parameters
  • [in] variable_path – Path to the variable in terms of Format.

  • [in] variable – Pointer to the uconfig::Variable<> to wrap.

VariableIface(const VariableIface<T, Format>&) = default

Copy constructor.

VariableIface<T, Format> &operator=(const VariableIface<T, Format>&) = default

Copy assignment.

VariableIface(VariableIface<T, Format>&&) noexcept = default

Move constructor.

VariableIface<T, Format> &operator=(VariableIface<T, Format>&&) noexcept = default

Move assignment.

virtual ~VariableIface() = default

Destructor.

virtual bool Parse(const format_type &parser, const source_type *source, bool throw_on_fail = true) override

Parse referenced uconfig::Variable<> from source using parser.

Parameters
  • [in] parser – Parser instance to use.

  • [in] source – Source to parse from.

  • [in] throw_on_fail – Will throw an uconfig::ParseError is failed to parse. Default true.

Throws

uconfig::ParseError – Thrown if throw_on_fail.

Returns

true if variable has been parsed, false otherwise.

virtual void Emit(const format_type &emitter, dest_type *dest, bool throw_on_fail = true) override

Emit referenced uconfig::Variable<> to destination using emitter.

Parameters
  • [in] emitter – Emitter instance to use.

  • [in] dest – Destination to emit into.

  • [in] throw_on_fail – Will throw an uconfig::EmitError is failed to emit. Default true.

Throws

uconfig::EmitError – Thrown if throw_on_fail.

virtual const std::string &Path() const noexcept override

Get path of the wrapped uconfig::Variable<>.

virtual bool Initialized() const noexcept override

Check if wrapped uconfig::Variable<> has all mandatory values set.

virtual bool Optional() const noexcept override

Check if wrapped uconfig::Variable<> declared as optional.