Program Listing for File base_parser.hpp
↰ Return to documentation for file (rcppsw/config/base_parser.hpp
)
#pragma once
/*******************************************************************************
* Includes
******************************************************************************/
#include "rcppsw/rcppsw.hpp"
/*******************************************************************************
* Namespaces/Decls
******************************************************************************/
namespace rcppsw::config {
struct base_config;
/*******************************************************************************
* Class Definitions
******************************************************************************/
class base_parser {
public:
base_parser(void) = default;
virtual ~base_parser(void) = default;
virtual bool validate(void) const { return true; }
template <typename T>
RCPPSW_COLD const T* config_get(void) const {
static_assert(std::is_base_of<base_config, T>::value,
"Config type to get must be derived from base_config!");
return static_cast<const T*>(config_get_impl());
}
RCPPSW_COLD bool is_parsed(void) const {
return (nullptr != config_get_impl()) ? true : false;
}
protected:
virtual const base_config* config_get_impl(void) const = 0;
};
} /* namespace rcppsw::config */