5#ifndef IDOL_IMPL_ANNOTATION_H
6#define IDOL_IMPL_ANNOTATION_H
21class idol::impl::Annotation {
24 const unsigned int id;
25 const std::string name;
26 std::any default_value;
27 Id(Env& t_env,
unsigned int t_id, std::string&& t_name) : env(t_env), id(t_id), name(std::move(t_name)) {}
29 std::shared_ptr<Id> m_id;
31 template<
class T,
class ...ArgsT>
void set_default_value(ArgsT&& ...t_args);
32 template<
class T> [[nodiscard]]
const T& cast_default_value()
const {
return std::any_cast<const T&>(m_id->default_value); }
34 Annotation(
::idol::Env& t_env, std::string&& t_name);
36 virtual ~Annotation() =
default;
44 [[nodiscard]]
unsigned int id()
const {
return m_id->id; }
50 [[nodiscard]]
const std::string& name()
const {
return m_id->name; }
56 [[nodiscard]]
bool has_default()
const {
return m_id->default_value.has_value(); }
67 [[nodiscard]] Env& env()
const {
return m_id->env; }
70template<
class T,
class... ArgsT>
71void idol::impl::Annotation::set_default_value(ArgsT &&... t_args) {
72 m_id->default_value.emplace<T>(std::forward<ArgsT>(t_args)...);