16 #include <string_view>
17 #include "../internal/helpers.h"
29 explicit Parameters(
const bool override_parameters =
true)
44 template <
class t_Derived,
class t_Parameters,
class t_ReturnType =
void>
59 template <
class t_Ariles>
62 return (ariles_class.arilesGetParameters(*
static_cast<const t_Derived *
>(
this)));
68 #define ARILES2_BASE_METHODS(Namespace) \
69 using Namespace::Base::arilesVirtualVisit; \
70 using Namespace::Base::arilesGetParameters;
72 #define ARILES2_METHODS(Namespace, VisitorQualifier, MethodQualifier) \
73 void arilesVirtualVisit( \
74 VisitorQualifier ariles2::Namespace::Visitor &visitor, \
75 const ariles2::Namespace::Visitor::Parameters ¶m) MethodQualifier override \
77 CPPUT_TRACE_FUNCTION; \
78 this->arilesVisit(visitor, param); \
80 using ariles2::Namespace::Base::arilesGetParameters;
85 template <
class t_Visitor>
96 return (visitor.getDefaultParameters());
101 template <
class t_Visitor>
112 return (visitor.getDefaultParameters());
119 template <
class t_Subtree>
121 std::is_same<std::string, std::decay_t<t_Subtree>>,
122 std::is_same<char *, std::decay_t<t_Subtree>>,
123 std::is_same<const char *, std::decay_t<t_Subtree>>,
124 std::is_same<std::string_view, std::decay_t<t_Subtree>>,
125 std::is_same<std::vector<std::string>, std::decay_t<t_Subtree>>>;
127 template <
class t_Subtree>
130 template <
class t_Subtree>
134 template <
class t_Visitor>
135 using is_visitor_t = std::enable_if_t<std::is_base_of_v<ariles2::visitor::Visitor, t_Visitor>>;
137 template <
class t_Visitor>
138 using is_not_visitor_t = std::enable_if_t<not std::is_base_of_v<ariles2::visitor::Visitor, t_Visitor>>;
140 template <
class t_Ariles>
141 using is_ariles_t = std::enable_if_t<std::is_base_of_v<ariles2::Ariles, t_Ariles>>;
143 template <
class t_Ariles>
144 using is_not_ariles_t = std::enable_if_t<not std::is_base_of_v<ariles2::Ariles, t_Ariles>>;
148 #ifndef ARILES2_DISABLE
149 # ifndef ARILES2_ENABLED
150 # define ARILES2_ENABLED
154 #ifdef ARILES2_ENABLED
163 typename = traits::is_subtree_t<t_Subtree>,
164 typename = traits::is_visitor_t<t_Visitor>>
165 typename t_Visitor::ReturnType
apply(
167 t_Ariles &ariles_class,
172 return (visitor.visit(ariles_class, std::forward<t_Subtree>(subtree), param));
176 template <
class t_Visitor,
class t_Ariles,
typename = traits::is_visitor_t<t_Visitor>>
177 typename t_Visitor::ReturnType
apply(
179 t_Ariles &ariles_class,
183 return (visitor.visit(ariles_class, ariles_class.arilesDefaultID(), param));
191 typename = traits::is_subtree_t<t_Subtree>,
192 typename = traits::is_visitor_t<t_Visitor>>
193 typename t_Visitor::ReturnType
apply(t_Visitor &visitor, t_Ariles &ariles_class, t_Subtree &&subtree)
196 return (visitor.visit(ariles_class, std::forward<t_Subtree>(subtree), visitor.getParameters(ariles_class)));
200 template <
class t_Visitor,
class t_Ariles,
typename = traits::is_visitor_t<t_Visitor>>
201 typename t_Visitor::ReturnType
apply(t_Visitor &visitor, t_Ariles &ariles_class)
204 return (
ariles2::apply(visitor, ariles_class, ariles_class.arilesDefaultID()));
211 typename = traits::is_visitor_t<t_Visitor>,
212 typename = traits::is_ariles_t<t_Ariles>>
213 typename t_Visitor::ReturnType
apply(t_Ariles &ariles_class)
228 typename = traits::is_not_visitor_t<t_Arg>,
229 typename = traits::is_not_ariles_t<t_Arg>>
230 typename t_Visitor::ReturnType
apply(t_Arg &&arg, t_Args &&...args)
233 t_Visitor visitor(std::forward<t_Arg>(arg));
244 typename = traits::is_visitor_t<t_Visitor>,
245 typename = traits::is_ariles_t<t_Left>,
246 typename = traits::is_not_subtree_t<t_Right>>
247 typename t_Visitor::ReturnType
apply(t_Left &left, t_Right &right)
251 return (visitor.visit(left, right, left.arilesDefaultID(), visitor.getParameters(left)));
259 typename = traits::is_not_subtree_t<t_Right>,
260 typename = traits::is_visitor_t<t_Visitor>>
261 typename t_Visitor::ReturnType
apply(
265 const std::string &name,
269 return (visitor.visit(left, right, name, param));
277 typename = traits::is_visitor_t<t_Visitor>,
278 typename = traits::is_not_subtree_t<t_Right>,
279 typename = std::enable_if_t<not std::is_base_of_v<typename t_Visitor::Parameters, t_Right>>>
280 typename t_Visitor::ReturnType
apply(t_Visitor &visitor, t_Left &left, t_Right &right)
283 return (visitor.visit(left, right, left.arilesDefaultID(), visitor.getParameters(left)));
291 typename = traits::is_not_subtree_t<t_Right>,
292 typename = traits::is_visitor_t<t_Visitor>>
293 typename t_Visitor::ReturnType
apply(
300 return (
ariles2::apply(visitor, left, right, left.arilesDefaultID(), param));
309 template <
class t_Visitor,
class... t_Args>
310 void apply(t_Args &&...)
314 template <
class... t_Args>
315 void apply(t_Args &&...)
virtual const t_Visitor::Parameters & arilesGetParameters(const t_Visitor &visitor) const
virtual t_Visitor::ReturnType arilesVirtualVisit(t_Visitor &, const typename t_Visitor::Parameters &)=0
virtual const t_Visitor::Parameters & arilesGetParameters(const t_Visitor &visitor) const
virtual t_Visitor::ReturnType arilesVirtualVisit(t_Visitor &, const typename t_Visitor::Parameters &) const =0
virtual const t_Parameters & getDefaultParameters() const
const t_Parameters & getParameters(const t_Ariles &ariles_class) const
bool override_parameters_
Parameters(const bool override_parameters=true)
visitor::Parameters Parameters
std::enable_if_t< std::is_base_of_v< ariles2::visitor::Visitor, t_Visitor > > is_visitor_t
std::enable_if_t< is_subtree< t_Subtree >::value > is_subtree_t
std::enable_if_t< not std::is_base_of_v< ariles2::Ariles, t_Ariles > > is_not_ariles_t
std::enable_if_t< std::is_base_of_v< ariles2::Ariles, t_Ariles > > is_ariles_t
std::disjunction< std::is_same< std::string, std::decay_t< t_Subtree > >, std::is_same< char *, std::decay_t< t_Subtree > >, std::is_same< const char *, std::decay_t< t_Subtree > >, std::is_same< std::string_view, std::decay_t< t_Subtree > >, std::is_same< std::vector< std::string >, std::decay_t< t_Subtree > >> is_subtree
std::enable_if_t< not std::is_base_of_v< ariles2::visitor::Visitor, t_Visitor > > is_not_visitor_t
std::enable_if_t< not is_subtree< t_Subtree >::value > is_not_subtree_t
t_Visitor::ReturnType apply(t_Visitor &visitor, t_Ariles &ariles_class, t_Subtree &&subtree, const typename t_Visitor::Parameters ¶m)
#define CPPUT_TRACE_FUNCTION