.. _program_listing_file_uconfig_Interface.h: Program Listing for File Interface.h ==================================== |exhale_lsh| :ref:`Return to documentation for file ` (``uconfig/Interface.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include "Objects.h" #include namespace uconfig { template class Interface { public: typedef Format format_type; typedef typename Format::source_type source_type; typedef typename Format::dest_type dest_type; virtual ~Interface() = default; virtual bool Parse(const format_type& parser, const source_type* source, bool throw_on_fail) = 0; virtual void Emit(const format_type& emitter, dest_type* dest, bool throw_on_fail) = 0; virtual const std::string& Path() const noexcept = 0; virtual bool Initialized() const noexcept = 0; virtual bool Optional() const noexcept = 0; }; template class ConfigIface: public Interface { public: using typename Interface::format_type; using typename Interface::source_type; using typename Interface::dest_type; template ConfigIface(const std::string& parse_path, Config* config); ConfigIface(const ConfigIface&) = default; ConfigIface& operator=(const ConfigIface&) = default; ConfigIface(ConfigIface&&) noexcept = default; ConfigIface& operator=(ConfigIface&&) noexcept = default; virtual ~ConfigIface() = default; virtual bool Parse(const format_type& parser, const source_type* source, bool throw_on_fail = true) override; virtual void Emit(const format_type& emitter, dest_type* dest, bool throw_on_fail = true) override; virtual const std::string& Path() const noexcept override; virtual bool Initialized() const noexcept override; virtual bool Optional() const noexcept override; private: std::string path_; bool cfg_optional_; std::vector>>* cfg_interfaces_; std::function cfg_validate_; }; template class ValueIface: public Interface { public: using typename Interface::format_type; using typename Interface::source_type; using typename Interface::dest_type; ValueIface(const std::string& variable_path, T* value); ValueIface(const ValueIface&) = default; ValueIface& operator=(const ValueIface&) = default; ValueIface(ValueIface&&) noexcept = default; ValueIface& operator=(ValueIface&&) noexcept = default; virtual ~ValueIface() = default; virtual bool Parse(const format_type& parser, const source_type* source, bool throw_on_fail = true) override; virtual void Emit(const format_type& emitter, dest_type* dest, bool throw_on_fail = true) override; virtual const std::string& Path() const noexcept override; virtual bool Initialized() const noexcept override; virtual bool Optional() const noexcept override; private: std::string path_; bool initialized_; T* value_ptr_; }; template class VariableIface: public Interface { public: using typename Interface::format_type; using typename Interface::source_type; using typename Interface::dest_type; VariableIface(const std::string& variable_path, Variable* variable); VariableIface(const VariableIface&) = default; VariableIface& operator=(const VariableIface&) = default; VariableIface(VariableIface&&) noexcept = default; VariableIface& operator=(VariableIface&&) noexcept = default; virtual ~VariableIface() = default; virtual bool Parse(const format_type& parser, const source_type* source, bool throw_on_fail = true) override; virtual void Emit(const format_type& emitter, dest_type* dest, bool throw_on_fail = true) override; virtual const std::string& Path() const noexcept override; virtual bool Initialized() const noexcept override; virtual bool Optional() const noexcept override; private: std::string path_; Variable* variable_ptr_; }; template class VectorIface: public Interface { public: using typename Interface::format_type; using typename Interface::source_type; using typename Interface::dest_type; VectorIface(const std::string& vector_path, Vector* vector); VectorIface(const VectorIface&) = default; VectorIface& operator=(const VectorIface&) = default; VectorIface(VectorIface&&) noexcept = default; VectorIface& operator=(VectorIface&&) noexcept = default; virtual ~VectorIface() = default; virtual bool Parse(const format_type& parser, const source_type* source, bool throw_on_fail = true) override; virtual void Emit(const format_type& emitter, dest_type* dest, bool throw_on_fail = true) override; virtual const std::string& Path() const noexcept override; virtual bool Initialized() const noexcept override; virtual bool Optional() const noexcept override; private: std::string path_; Vector* vector_ptr_; }; } // namespace uconfig #include "impl/Interface.ipp"