From ba8203b3ad423cbe90dbff78bf66177de155f695 Mon Sep 17 00:00:00 2001 From: Stonex <43725202+sheny1xuan@users.noreply.github.com> Date: Wed, 23 Feb 2022 01:52:05 +0800 Subject: [PATCH] feat: add ExprtkEvaluator test for basic model and root model. (#184) * feat: add ExprtkEvaluator test for basic model and root model. fix: fix basic_with_root_model.conf and add "p" variable when Enforce with no policy. fix: add bigobj option for windows. fix: fix short string optimization bug in MSVC. Signed-off-by: stonexx <1479765922@qq.com> * chore: Update exprtk version Signed-off-by: stonex <1479765922@qq.com> --- CMakeLists.txt | 4 + casbin/enforcer.cpp | 11 + casbin/exprtk/exprtk.hpp | 2755 +++++++++++++++------------ casbin/model/evaluator.cpp | 81 +- casbin/model/evaluator.h | 2 + examples/basic_with_root_model.conf | 2 +- include/casbin/casbin_helpers.h | 2 + include/casbin/exprtk/exprtk.hpp | 2755 +++++++++++++++------------ tests/model_enforcer_test.cpp | 570 +++--- 9 files changed, 3465 insertions(+), 2717 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e63b1e1..ecc3f8bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,10 @@ if(APPLE AND NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X deployment version") endif() +if(WIN32) + add_compile_options("/bigobj") +endif() + ############################################################################### # Project definition. diff --git a/casbin/enforcer.cpp b/casbin/enforcer.cpp index 1ea00bd3..8af2e90f 100644 --- a/casbin/enforcer.cpp +++ b/casbin/enforcer.cpp @@ -98,6 +98,7 @@ bool Enforcer::m_enforce(const std::string& matcher, std::shared_ptr m_log.LogPrint("Policy Rule: ", p_vals); if(p_tokens.size() != p_vals.size()) return false; + m_func_map.evalator->Clean(m_model->m["p"]); m_func_map.evalator->InitialObject("p"); for(int j = 0 ; j < p_tokens.size() ; j++) { size_t index = p_tokens[j].find("_"); @@ -166,6 +167,16 @@ bool Enforcer::m_enforce(const std::string& matcher, std::shared_ptr break; } } else { + // Push initial value for p in symbol table + // If p don't in symbol table, the evaluate result will be invalid. + m_func_map.evalator->Clean(m_model->m["p"]); + m_func_map.evalator->InitialObject("p"); + for(int j = 0 ; j < p_tokens.size() ; j++) { + size_t index = p_tokens[j].find("_"); + std::string token = p_tokens[j].substr(index + 1); + m_func_map.evalator->PushObjectString("p", token, ""); + } + bool isvalid = m_func_map.Evaluate(exp_string); if (!isvalid) { return false; diff --git a/casbin/exprtk/exprtk.hpp b/casbin/exprtk/exprtk.hpp index 4ce08486..b362bd2c 100644 --- a/casbin/exprtk/exprtk.hpp +++ b/casbin/exprtk/exprtk.hpp @@ -2,14 +2,14 @@ ****************************************************************** * C++ Mathematical Expression Toolkit Library * * * - * Author: Arash Partow (1999-2021) * - * URL: http://www.partow.net/programming/exprtk/index.html * + * Author: Arash Partow (1999-2022) * + * URL: https://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * * Free use of the C++ Mathematical Expression Toolkit Library is * * permitted under the guidelines and in accordance with the most * * current version of the MIT License. * - * http://www.opensource.org/licenses/MIT * + * https://www.opensource.org/licenses/MIT * * * * Example expressions: * * (00) (y + x / y) * (x - y / x) * @@ -85,9 +85,11 @@ namespace exprtk #if __cplusplus >= 201103L #define exprtk_override override #define exprtk_final final + #define exprtk_delete = delete #else #define exprtk_override #define exprtk_final + #define exprtk_delete #endif namespace details @@ -282,25 +284,21 @@ namespace exprtk std::string result; - if (i < 0) - { - for ( ; i; i /= 10) - { - result += '0' + static_cast(-(i % 10)); - } + const int sign = (i < 0) ? -1 : 1; - result += '-'; + for ( ; i; i /= 10) + { + result += '0' + static_cast(sign * (i % 10)); } - else + + if (sign < 0) { - for ( ; i; i /= 10) - { - result += '0' + static_cast(i % 10); - } + result += '-'; } std::reverse(result.begin(), result.end()); + return result; } @@ -309,7 +307,7 @@ namespace exprtk return to_str(static_cast(i)); } - inline bool is_hex_digit(const std::string::value_type digit) + inline bool is_hex_digit(const uchar_t digit) { return (('0' <= digit) && (digit <= '9')) || (('A' <= digit) && (digit <= 'F')) || @@ -326,7 +324,7 @@ namespace exprtk template inline bool parse_hex(Iterator& itr, Iterator end, - std::string::value_type& result) + char_t& result) { if ( (end == (itr )) || @@ -599,83 +597,84 @@ namespace exprtk } }; - template + template ::value_type> inline bool match_impl(const Iterator pattern_begin, const Iterator pattern_end , const Iterator data_begin , const Iterator data_end , - const typename std::iterator_traits::value_type& zero_or_more, - const typename std::iterator_traits::value_type& zero_or_one ) + const ValueType zero_or_more, + const ValueType exactly_one ) { const Iterator null_itr(0); - Iterator d_itr = data_begin; - Iterator p_itr = pattern_begin; - Iterator tb_p_itr = null_itr; - Iterator tb_d_itr = null_itr; + Iterator p_itr = pattern_begin; + Iterator d_itr = data_begin; + Iterator np_itr = null_itr; + Iterator nd_itr = null_itr; + bool in_bounds = true; - while (d_itr != data_end) + for ( ; ; ) { - if (zero_or_more == *p_itr) - { - while ((pattern_end != p_itr) && ((zero_or_more == *p_itr) || (zero_or_one == *p_itr))) - { - ++p_itr; - } - - if (pattern_end == p_itr) - return true; + const bool pvalid = p_itr != pattern_end; + const bool dvalid = d_itr != data_end; + if (pvalid) + { const typename std::iterator_traits::value_type c = *(p_itr); - while ((data_end != d_itr) && !Compare::cmp(c,*d_itr)) + if (dvalid && (Compare::cmp(c,*(d_itr)) || (exactly_one == c))) { ++d_itr; + ++p_itr; + continue; + } + else if (zero_or_more == c) + { + in_bounds = dvalid; + nd_itr = d_itr + 1; + np_itr = p_itr; + ++p_itr; + continue; } - - tb_p_itr = p_itr; - tb_d_itr = d_itr; - - continue; } - else if (!Compare::cmp(*p_itr, *d_itr) && (zero_or_one != *p_itr)) - { - if (null_itr == tb_d_itr) - return false; - - d_itr = tb_d_itr++; - p_itr = tb_p_itr; + else if (!dvalid) + break; + //nd_itr in [1,data_end] + if ((null_itr != nd_itr) && in_bounds) + { + p_itr = np_itr; + d_itr = nd_itr; continue; } - ++p_itr; - ++d_itr; - } - - while ((pattern_end != p_itr) && ((zero_or_more == *p_itr) || (zero_or_one == *p_itr))) - { - ++p_itr; + return false; } - return (pattern_end == p_itr); + return true; } inline bool wc_match(const std::string& wild_card, const std::string& str) { - return match_impl( - wild_card.data(), wild_card.data() + wild_card.size(), - str.data(), str.data() + str.size(), + return match_impl( + wild_card.data(), + wild_card.data() + wild_card.size(), + str.data(), + str.data() + str.size(), '*', '?'); } inline bool wc_imatch(const std::string& wild_card, const std::string& str) { - return match_impl( - wild_card.data(), wild_card.data() + wild_card.size(), - str.data(), str.data() + str.size(), + return match_impl( + wild_card.data(), + wild_card.data() + wild_card.size(), + str.data(), + str.data() + str.size(), '*', '?'); } @@ -696,8 +695,8 @@ namespace exprtk itr_t p_itr = pattern.begin(); itr_t s_itr = str .begin(); - itr_t p_end = pattern.end(); - itr_t s_end = str .end(); + const itr_t p_end = pattern.end(); + const itr_t s_end = str .end(); while ((s_end != s_itr) && (p_end != p_itr)) { @@ -1100,7 +1099,7 @@ namespace exprtk template inline T sgn_impl(const T v, real_type_tag) { - if (v > T(0)) return T(+1); + if (v > T(0)) return T(+1); else if (v < T(0)) return T(-1); else return T( 0); } @@ -1108,7 +1107,7 @@ namespace exprtk template inline T sgn_impl(const T v, int_type_tag) { - if (v > T(0)) return T(+1); + if (v > T(0)) return T(+1); else if (v < T(0)) return T(-1); else return T( 0); } @@ -1198,8 +1197,8 @@ namespace exprtk } #if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || !defined(_MSC_VER) - #define exprtk_define_erf(TT,impl) \ - inline TT erf_impl(TT v) { return impl(v); } \ + #define exprtk_define_erf(TT, impl) \ + inline TT erf_impl(const TT v) { return impl(v); } \ exprtk_define_erf( float,::erff) exprtk_define_erf( double,::erf ) @@ -1208,7 +1207,7 @@ namespace exprtk #endif template - inline T erf_impl(T v, real_type_tag) + inline T erf_impl(const T v, real_type_tag) { #if defined(_MSC_VER) && (_MSC_VER < 1900) // Credits: Abramowitz & Stegun Equations 7.1.25-28 @@ -1222,12 +1221,12 @@ namespace exprtk const T t = T(1) / (T(1) + T(0.5) * abs_impl(v,real_type_tag())); - T result = T(1) - t * std::exp((-v * v) - - c[0] + t * (c[1] + t * - (c[2] + t * (c[3] + t * - (c[4] + t * (c[5] + t * - (c[6] + t * (c[7] + t * - (c[8] + t * (c[9])))))))))); + const T result = T(1) - t * std::exp((-v * v) - + c[0] + t * (c[1] + t * + (c[2] + t * (c[3] + t * + (c[4] + t * (c[5] + t * + (c[6] + t * (c[7] + t * + (c[8] + t * (c[9])))))))))); return (v >= T(0)) ? result : -result; #else @@ -1236,14 +1235,14 @@ namespace exprtk } template - inline T erf_impl(T v, int_type_tag) + inline T erf_impl(const T v, int_type_tag) { return erf_impl(static_cast(v),real_type_tag()); } #if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || !defined(_MSC_VER) - #define exprtk_define_erfc(TT,impl) \ - inline TT erfc_impl(TT v) { return impl(v); } \ + #define exprtk_define_erfc(TT, impl) \ + inline TT erfc_impl(const TT v) { return impl(v); } \ exprtk_define_erfc(float ,::erfcf) exprtk_define_erfc(double ,::erfc ) @@ -1252,7 +1251,7 @@ namespace exprtk #endif template - inline T erfc_impl(T v, real_type_tag) + inline T erfc_impl(const T v, real_type_tag) { #if defined(_MSC_VER) && (_MSC_VER < 1900) return T(1) - erf_impl(v,real_type_tag()); @@ -1262,28 +1261,28 @@ namespace exprtk } template - inline T erfc_impl(T v, int_type_tag) + inline T erfc_impl(const T v, int_type_tag) { return erfc_impl(static_cast(v),real_type_tag()); } template - inline T ncdf_impl(T v, real_type_tag) + inline T ncdf_impl(const T v, real_type_tag) { - T cnd = T(0.5) * (T(1) + erf_impl( - abs_impl(v,real_type_tag()) / - T(numeric::constant::sqrt2),real_type_tag())); + const T cnd = T(0.5) * (T(1) + + erf_impl(abs_impl(v,real_type_tag()) / + T(numeric::constant::sqrt2),real_type_tag())); return (v < T(0)) ? (T(1) - cnd) : cnd; } template - inline T ncdf_impl(T v, int_type_tag) + inline T ncdf_impl(const T v, int_type_tag) { return ncdf_impl(static_cast(v),real_type_tag()); } template - inline T sinc_impl(T v, real_type_tag) + inline T sinc_impl(const T v, real_type_tag) { if (std::abs(v) >= std::numeric_limits::epsilon()) return(std::sin(v) / v); @@ -1292,7 +1291,7 @@ namespace exprtk } template - inline T sinc_impl(T v, int_type_tag) + inline T sinc_impl(const T v, int_type_tag) { return sinc_impl(static_cast(v),real_type_tag()); } @@ -1323,14 +1322,14 @@ namespace exprtk template inline T csc_impl(const T v, real_type_tag) { return T(1) / std::sin(v); } template inline T r2d_impl(const T v, real_type_tag) { return (v * T(numeric::constant::_180_pi)); } template inline T d2r_impl(const T v, real_type_tag) { return (v * T(numeric::constant::pi_180)); } - template inline T d2g_impl(const T v, real_type_tag) { return (v * T(20.0/9.0)); } - template inline T g2d_impl(const T v, real_type_tag) { return (v * T(9.0/20.0)); } + template inline T d2g_impl(const T v, real_type_tag) { return (v * T(10.0/9.0)); } + template inline T g2d_impl(const T v, real_type_tag) { return (v * T(9.0/10.0)); } template inline T notl_impl(const T v, real_type_tag) { return (std::not_equal_to()(T(0),v) ? T(0) : T(1)); } template inline T frac_impl(const T v, real_type_tag) { return (v - static_cast(v)); } template inline T trunc_impl(const T v, real_type_tag) { return T(static_cast(v)); } - template inline T const_pi_impl (real_type_tag) { return T(numeric::constant::pi); } - template inline T const_e_impl (real_type_tag) { return T(numeric::constant::e); } + template inline T const_pi_impl(real_type_tag) { return T(numeric::constant::pi); } + template inline T const_e_impl(real_type_tag) { return T(numeric::constant::e); } template inline T const_qnan_impl(real_type_tag) { return std::numeric_limits::quiet_NaN(); } template inline T abs_impl(const T v, int_type_tag) { return ((v >= T(0)) ? v : -v); } @@ -1805,7 +1804,7 @@ namespace exprtk } template - static inline bool parse_inf(Iterator& itr, const Iterator end, T& t, bool negative) + static inline bool parse_inf(Iterator& itr, const Iterator end, T& t, const bool negative) { static const char_t inf_uc[] = "INFINITY"; static const char_t inf_lc[] = "infinity"; @@ -2263,8 +2262,8 @@ namespace exprtk generator() : base_itr_(0) - , s_itr_ (0) - , s_end_ (0) + , s_itr_ (0) + , s_end_ (0) { clear(); } @@ -2380,7 +2379,7 @@ namespace exprtk } } - inline std::string substr(const std::size_t& begin, const std::size_t& end) + inline std::string substr(const std::size_t& begin, const std::size_t& end) const { const details::char_cptr begin_itr = ((base_itr_ + begin) < s_end_) ? (base_itr_ + begin) : s_end_; const details::char_cptr end_itr = ((base_itr_ + end ) < s_end_) ? (base_itr_ + end ) : s_end_; @@ -2400,13 +2399,13 @@ namespace exprtk private: - inline bool is_end(details::char_cptr itr) + inline bool is_end(details::char_cptr itr) const { return (s_end_ == itr); } #ifndef exprtk_disable_comments - inline bool is_comment_start(details::char_cptr itr) + inline bool is_comment_start(details::char_cptr itr) const { const char_t c0 = *(itr + 0); const char_t c1 = *(itr + 1); @@ -2421,7 +2420,7 @@ namespace exprtk return false; } #else - inline bool is_comment_start(details::char_cptr) + inline bool is_comment_start(details::char_cptr) const { return false; } @@ -2447,10 +2446,10 @@ namespace exprtk static inline bool comment_start(const char_t c0, const char_t c1, int& mode, int& incr) { mode = 0; - if ('#' == c0) { mode = 1; incr = 1; } + if ('#' == c0) { mode = 1; incr = 1; } else if ('/' == c0) { - if ('/' == c1) { mode = 1; incr = 2; } + if ('/' == c1) { mode = 1; incr = 2; } else if ('*' == c1) { mode = 2; incr = 2; } } return (0 != mode); @@ -2593,7 +2592,7 @@ namespace exprtk token_t::token_type ttype = token_t::e_none; - if ((c0 == '<') && (c1 == '=')) ttype = token_t::e_lte; + if ((c0 == '<') && (c1 == '=')) ttype = token_t::e_lte; else if ((c0 == '>') && (c1 == '=')) ttype = token_t::e_gte; else if ((c0 == '<') && (c1 == '>')) ttype = token_t::e_ne; else if ((c0 == '!') && (c1 == '=')) ttype = token_t::e_ne; @@ -2931,7 +2930,7 @@ namespace exprtk friend class token_modifier; friend class token_inserter; friend class token_joiner; - }; + }; // class generator class helper_interface { @@ -2948,8 +2947,7 @@ namespace exprtk { public: - virtual ~token_scanner() - {} + virtual ~token_scanner() {} explicit token_scanner(const std::size_t& stride) : stride_(stride) @@ -3049,7 +3047,7 @@ namespace exprtk private: const std::size_t stride_; - }; + }; // class token_scanner class token_modifier : public helper_interface { @@ -3350,7 +3348,7 @@ namespace exprtk return -1; } } - if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_symbol )) match = true; + if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_symbol )) match = true; else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lbracket )) match = true; else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lcrlbracket)) match = true; else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lsqrbracket)) match = true; @@ -3598,7 +3596,7 @@ namespace exprtk { details::char_t c = t.value[0]; - if (t.type == lexer::token::e_lbracket ) stack_.push(std::make_pair(')',t.position)); + if (t.type == lexer::token::e_lbracket ) stack_.push(std::make_pair(')',t.position)); else if (t.type == lexer::token::e_lcrlbracket) stack_.push(std::make_pair('}',t.position)); else if (t.type == lexer::token::e_lsqrbracket) stack_.push(std::make_pair(']',t.position)); else if (exprtk::details::is_right_bracket(c)) @@ -3632,6 +3630,7 @@ namespace exprtk lexer::token error_token_; }; + template class numeric_checker : public lexer::token_scanner { public: @@ -3658,7 +3657,7 @@ namespace exprtk { if (token::e_number == t.type) { - double v; + T v; if (!exprtk::details::string_to_real(t.value,v)) { @@ -4859,8 +4858,8 @@ namespace exprtk private: - control_block(const control_block&); - control_block& operator=(const control_block&); + control_block(const control_block&) exprtk_delete; + control_block& operator=(const control_block&) exprtk_delete; inline void create_data() { @@ -4927,11 +4926,6 @@ namespace exprtk return control_block_->data; } - inline std::size_t size() - { - return control_block_->size; - } - inline std::size_t size() const { return control_block_->size; @@ -4970,7 +4964,7 @@ namespace exprtk private: - static inline std::size_t min_size(control_block* cb0, control_block* cb1) + static inline std::size_t min_size(const control_block* cb0, const control_block* cb1) { const std::size_t size0 = cb0->size; const std::size_t size1 = cb1->size; @@ -5199,8 +5193,7 @@ namespace exprtk typedef typename nci_t::noderef_list_t noderef_list_t; typedef node_depth_base > ndb_t; - virtual ~expression_node() - {} + virtual ~expression_node() {} inline virtual T value() const { @@ -5216,7 +5209,7 @@ namespace exprtk { return e_none; } - }; + }; // class expression_node template inline bool is_generally_string_node(const expression_node* node); @@ -5354,7 +5347,11 @@ namespace exprtk template inline bool is_constant_node(const expression_node* node) { - return node && (details::expression_node::e_constant == node->type()); + return node && + ( + details::expression_node::e_constant == node->type() || + details::expression_node::e_stringconst == node->type() + ); } template @@ -5867,7 +5864,8 @@ namespace exprtk private: - array_vector_impl operator=(const array_vector_impl&); + array_vector_impl(const array_vector_impl&) exprtk_delete; + array_vector_impl& operator=(const array_vector_impl&) exprtk_delete; const Type* vec_; const std::size_t size_; @@ -5899,7 +5897,8 @@ namespace exprtk private: - sequence_vector_impl operator=(const sequence_vector_impl&); + sequence_vector_impl(const sequence_vector_impl&) exprtk_delete; + sequence_vector_impl& operator=(const sequence_vector_impl&) exprtk_delete; sequence_t& sequence_; }; @@ -5938,7 +5937,8 @@ namespace exprtk private: - vector_view_impl operator=(const vector_view_impl&); + vector_view_impl(const vector_view_impl&) exprtk_delete; + vector_view_impl& operator=(const vector_view_impl&) exprtk_delete; vector_view_t& vec_view_; }; @@ -6000,12 +6000,12 @@ namespace exprtk { public: - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_null; } @@ -6070,7 +6070,7 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); @@ -6083,27 +6083,22 @@ namespace exprtk return (equality_) ? T(0) : T(1); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_nulleq; } - inline operator_type operation() const - { - return details::e_eq; - } - - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -6123,25 +6118,25 @@ namespace exprtk : value_(v) {} - inline T value() const + inline T value() const exprtk_override { return value_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_constant; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return reinterpret_cast*>(0); } private: - literal_node(literal_node&) {} - literal_node& operator=(literal_node&) { return (*this); } + literal_node(const literal_node&) exprtk_delete; + literal_node& operator=(const literal_node&) exprtk_delete; const T value_; }; @@ -6159,8 +6154,7 @@ namespace exprtk typedef range_pack range_t; - virtual ~range_interface() - {} + virtual ~range_interface() {} virtual range_t& range_ref() = 0; @@ -6175,8 +6169,7 @@ namespace exprtk typedef range_data_type range_data_type_t; - virtual ~string_base_node() - {} + virtual ~string_base_node() {} virtual std::string str () const = 0; @@ -6204,50 +6197,50 @@ namespace exprtk rp_.cache.second = rp_.n1_c.second; } - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringconst; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return reinterpret_cast*>(0); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return value_.data(); } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return rp_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return rp_; } private: - string_literal_node(const string_literal_node&); - string_literal_node& operator=(const string_literal_node&); + string_literal_node(const string_literal_node&) exprtk_delete; + string_literal_node& operator=(const string_literal_node&) exprtk_delete; const std::string value_; range_t rp_; @@ -6268,7 +6261,7 @@ namespace exprtk construct_branch_pair(branch_,branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); @@ -6277,17 +6270,17 @@ namespace exprtk return numeric::process(operation_,arg); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_unary; } - inline operator_type operation() const + inline operator_type operation() { return operation_; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } @@ -6297,12 +6290,12 @@ namespace exprtk branch_.second = false; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -6329,7 +6322,7 @@ namespace exprtk init_branches<2>(branch_, branch0, branch1); } - inline T value() const + inline T value() const exprtk_override { assert(branch_[0].first); assert(branch_[1].first); @@ -6340,7 +6333,7 @@ namespace exprtk return numeric::process(operation_,arg0,arg1); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_binary; } @@ -6350,7 +6343,7 @@ namespace exprtk return operation_; } - inline expression_node* branch(const std::size_t& index = 0) const + inline expression_node* branch(const std::size_t& index = 0) const exprtk_override { if (0 == index) return branch_[0].first; @@ -6360,12 +6353,12 @@ namespace exprtk return reinterpret_cast(0); } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::template compute_node_depth<2>(branch_); } @@ -6389,7 +6382,7 @@ namespace exprtk init_branches<2>(branch_, branch0, branch1); } - inline T value() const + inline T value() const exprtk_override { assert(branch_[0].first); assert(branch_[1].first); @@ -6400,7 +6393,7 @@ namespace exprtk return Operation::process(arg0,arg1); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_binary_ext; } @@ -6410,7 +6403,7 @@ namespace exprtk return Operation::operation(); } - inline expression_node* branch(const std::size_t& index = 0) const + inline expression_node* branch(const std::size_t& index = 0) const exprtk_override { if (0 == index) return branch_[0].first; @@ -6420,12 +6413,12 @@ namespace exprtk return reinterpret_cast(0); } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::template compute_node_depth<2>(branch_); } @@ -6452,7 +6445,7 @@ namespace exprtk init_branches<3>(branch_, branch0, branch1, branch2); } - inline T value() const + inline T value() const exprtk_override { assert(branch_[0].first); assert(branch_[1].first); @@ -6478,17 +6471,17 @@ namespace exprtk } } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_trinary; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::template compute_node_depth<3>(branch_); } @@ -6517,22 +6510,22 @@ namespace exprtk init_branches<4>(branch_, branch0, branch1, branch2, branch3); } - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_quaternary; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::template compute_node_depth<4>(branch_); } @@ -6560,7 +6553,7 @@ namespace exprtk construct_branch_pair(alternative_, alternative); } - inline T value() const + inline T value() const exprtk_override { assert(condition_ .first); assert(consequent_ .first); @@ -6572,19 +6565,19 @@ namespace exprtk return alternative_.first->value(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_conditional; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(condition_ , node_delete_list); expression_node::ndb_t::collect(consequent_ , node_delete_list); expression_node::ndb_t::collect(alternative_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth (condition_, consequent_, alternative_); @@ -6613,7 +6606,7 @@ namespace exprtk construct_branch_pair(consequent_, consequent); } - inline T value() const + inline T value() const exprtk_override { assert(condition_ .first); assert(consequent_.first); @@ -6624,18 +6617,18 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_conditional; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(condition_ , node_delete_list); expression_node::ndb_t::collect(consequent_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t:: compute_node_depth(condition_, consequent_); @@ -6660,8 +6653,7 @@ namespace exprtk T value; }; - class continue_exception - {}; + class continue_exception {}; template class break_node exprtk_final : public expression_node @@ -6676,7 +6668,7 @@ namespace exprtk construct_branch_pair(return_, ret); } - inline T value() const + inline T value() const exprtk_override { const T result = return_.first ? return_.first->value() : @@ -6689,17 +6681,17 @@ namespace exprtk #endif } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_break; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(return_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(return_); } @@ -6714,7 +6706,7 @@ namespace exprtk { public: - inline T value() const + inline T value() const exprtk_override { throw continue_exception(); #ifndef _MSC_VER @@ -6722,22 +6714,24 @@ namespace exprtk #endif } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_break; } }; #endif - #ifdef exprtk_enable_runtime_checks struct loop_runtime_checker { - loop_runtime_checker(loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0), + loop_runtime_checker(loop_runtime_check_ptr loop_runtime_check, loop_runtime_check::loop_types lp_typ = loop_runtime_check::e_invalid) : iteration_count_(0) - , loop_runtime_check_(loop_rt_chk) - , loop_type(lp_typ) - {} + , loop_runtime_check_(loop_runtime_check) + , max_loop_iterations_(loop_runtime_check_->max_loop_iterations) + , loop_type_(lp_typ) + { + assert(loop_runtime_check_); + } inline void reset(const _uint64_t initial_value = 0) const { @@ -6748,14 +6742,14 @@ namespace exprtk { if ( (0 == loop_runtime_check_) || - (++iteration_count_ <= loop_runtime_check_->max_loop_iterations) + (++iteration_count_ <= max_loop_iterations_) ) { return true; } loop_runtime_check::violation_context ctxt; - ctxt.loop = loop_type; + ctxt.loop = loop_type_; ctxt.violation = loop_runtime_check::e_iteration_count; loop_runtime_check_->handle_runtime_violation(ctxt); @@ -6765,28 +6759,12 @@ namespace exprtk mutable _uint64_t iteration_count_; mutable loop_runtime_check_ptr loop_runtime_check_; - loop_runtime_check::loop_types loop_type; + const details::_uint64_t& max_loop_iterations_; + loop_runtime_check::loop_types loop_type_; }; - #else - struct loop_runtime_checker - { - loop_runtime_checker(loop_runtime_check_ptr, loop_runtime_check::loop_types) - {} - - inline void reset(const _uint64_t = 0) const - {} - - inline bool check() const - { - return true; - } - }; - #endif template - class while_loop_node exprtk_final - : public expression_node, - public loop_runtime_checker + class while_loop_node : public expression_node { public: @@ -6794,24 +6772,20 @@ namespace exprtk typedef std::pair branch_t; while_loop_node(expression_ptr condition, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk,loop_runtime_check::e_while_loop) + expression_ptr loop_body) { construct_branch_pair(condition_, condition); construct_branch_pair(loop_body_, loop_body); } - inline T value() const + inline T value() const exprtk_override { assert(condition_.first); assert(loop_body_.first); T result = T(0); - loop_runtime_checker::reset(); - - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(condition_)) { result = loop_body_.first->value(); } @@ -6819,32 +6793,65 @@ namespace exprtk return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_while; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(condition_ , node_delete_list); expression_node::ndb_t::collect(loop_body_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(condition_, loop_body_); } - private: + protected: branch_t condition_; branch_t loop_body_; }; template - class repeat_until_loop_node exprtk_final - : public expression_node, - public loop_runtime_checker + class while_loop_rtc_node exprtk_final + : public while_loop_node + , public loop_runtime_checker + { + public: + + typedef while_loop_node parent_t; + typedef expression_node* expression_ptr; + + while_loop_rtc_node(expression_ptr condition, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(condition, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_while_loop) + {} + + inline T value() const exprtk_override + { + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); + + T result = T(0); + + loop_runtime_checker::reset(); + + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + result = parent_t::loop_body_.first->value(); + } + + return result; + } + }; + + template + class repeat_until_loop_node : public expression_node { public: @@ -6852,58 +6859,88 @@ namespace exprtk typedef std::pair branch_t; repeat_until_loop_node(expression_ptr condition, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_repeat_until_loop) + expression_ptr loop_body) { construct_branch_pair(condition_, condition); construct_branch_pair(loop_body_, loop_body); } - inline T value() const + inline T value() const exprtk_override { assert(condition_.first); assert(loop_body_.first); T result = T(0); - loop_runtime_checker::reset(1); - do { result = loop_body_.first->value(); } - while (is_false(condition_.first) && loop_runtime_checker::check()); + while (is_false(condition_.first)); return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_repeat; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(condition_ , node_delete_list); expression_node::ndb_t::collect(loop_body_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(condition_, loop_body_); } - private: + protected: branch_t condition_; branch_t loop_body_; }; template - class for_loop_node exprtk_final - : public expression_node, - public loop_runtime_checker + class repeat_until_loop_rtc_node exprtk_final + : public repeat_until_loop_node + , public loop_runtime_checker + { + public: + + typedef repeat_until_loop_node parent_t; + typedef expression_node* expression_ptr; + + repeat_until_loop_rtc_node(expression_ptr condition, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(condition, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_repeat_until_loop) + {} + + inline T value() const exprtk_override + { + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); + + T result = T(0); + + loop_runtime_checker::reset(1); + + do + { + result = parent_t::loop_body_.first->value(); + } + while (is_false(parent_t::condition_.first) && loop_runtime_checker::check()); + + return result; + } + }; + + template + class for_loop_node : public expression_node { public: @@ -6913,9 +6950,7 @@ namespace exprtk for_loop_node(expression_ptr initialiser, expression_ptr condition, expression_ptr incrementor, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_for_loop) + expression_ptr loop_body) { construct_branch_pair(initialiser_, initialiser); construct_branch_pair(condition_ , condition ); @@ -6923,21 +6958,19 @@ namespace exprtk construct_branch_pair(loop_body_ , loop_body ); } - inline T value() const + inline T value() const exprtk_override { assert(condition_.first); assert(loop_body_.first); T result = T(0); - loop_runtime_checker::reset(); - if (initialiser_.first) initialiser_.first->value(); if (incrementor_.first) { - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(condition_)) { result = loop_body_.first->value(); incrementor_.first->value(); @@ -6945,7 +6978,7 @@ namespace exprtk } else { - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(condition_)) { result = loop_body_.first->value(); } @@ -6954,12 +6987,12 @@ namespace exprtk return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_for; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(initialiser_ , node_delete_list); expression_node::ndb_t::collect(condition_ , node_delete_list); @@ -6967,13 +7000,13 @@ namespace exprtk expression_node::ndb_t::collect(loop_body_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth (initialiser_, condition_, incrementor_, loop_body_); } - private: + protected: branch_t initialiser_; branch_t condition_ ; @@ -6981,40 +7014,83 @@ namespace exprtk branch_t loop_body_ ; }; - #ifndef exprtk_disable_break_continue template - class while_loop_bc_node exprtk_final - : public expression_node, - public loop_runtime_checker + class for_loop_rtc_node exprtk_final + : public for_loop_node + , public loop_runtime_checker { public: + typedef for_loop_node parent_t; typedef expression_node* expression_ptr; - typedef std::pair branch_t; - while_loop_bc_node(expression_ptr condition, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_while_loop) - { - construct_branch_pair(condition_, condition); - construct_branch_pair(loop_body_, loop_body); - } + for_loop_rtc_node(expression_ptr initialiser, + expression_ptr condition, + expression_ptr incrementor, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(initialiser, condition, incrementor, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_for_loop) + {} - inline T value() const + inline T value() const exprtk_override { - assert(condition_.first); - assert(loop_body_.first); + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); T result = T(0); loop_runtime_checker::reset(); - while (is_true(condition_) && loop_runtime_checker::check()) + if (parent_t::initialiser_.first) + parent_t::initialiser_.first->value(); + + if (parent_t::incrementor_.first) + { + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + result = parent_t::loop_body_.first->value(); + parent_t::incrementor_.first->value(); + } + } + else + { + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + result = parent_t::loop_body_.first->value(); + } + } + + return result; + } + }; + + #ifndef exprtk_disable_break_continue + template + class while_loop_bc_node : public while_loop_node + { + public: + + typedef while_loop_node parent_t; + typedef expression_node* expression_ptr; + + while_loop_bc_node(expression_ptr condition, + expression_ptr loop_body) + : parent_t(condition, loop_body) + {} + + inline T value() const exprtk_override + { + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); + + T result = T(0); + + while (is_true(parent_t::condition_)) { try { - result = loop_body_.first->value(); + result = parent_t::loop_body_.first->value(); } catch(const break_exception& e) { @@ -7026,62 +7102,77 @@ namespace exprtk return result; } + }; - inline typename expression_node::node_type type() const - { - return expression_node::e_while; - } + template + class while_loop_bc_rtc_node exprtk_final + : public while_loop_bc_node + , public loop_runtime_checker + { + public: - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) - { - expression_node::ndb_t::collect(condition_ , node_delete_list); - expression_node::ndb_t::collect(loop_body_ , node_delete_list); - } + typedef while_loop_bc_node parent_t; + typedef expression_node* expression_ptr; + + while_loop_bc_rtc_node(expression_ptr condition, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(condition, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_while_loop) + {} - std::size_t node_depth() const + inline T value() const exprtk_override { - return expression_node::ndb_t::compute_node_depth(condition_, loop_body_); - } + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); - private: + T result = T(0); - branch_t condition_; - branch_t loop_body_; + loop_runtime_checker::reset(); + + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + try + { + result = parent_t::loop_body_.first->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + } + + return result; + } }; template - class repeat_until_loop_bc_node exprtk_final - : public expression_node, - public loop_runtime_checker + class repeat_until_loop_bc_node : public repeat_until_loop_node { public: - typedef expression_node* expression_ptr; - typedef std::pair branch_t; + typedef repeat_until_loop_node parent_t; + typedef expression_node* expression_ptr; repeat_until_loop_bc_node(expression_ptr condition, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_repeat_until_loop) - { - construct_branch_pair(condition_, condition); - construct_branch_pair(loop_body_, loop_body); - } + expression_ptr loop_body) + : parent_t(condition, loop_body) + {} - inline T value() const + inline T value() const exprtk_override { - assert(condition_.first); - assert(loop_body_.first); + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); T result = T(0); - loop_runtime_checker::reset(); - do { try { - result = loop_body_.first->value(); + result = parent_t::loop_body_.first->value(); } catch(const break_exception& e) { @@ -7090,75 +7181,89 @@ namespace exprtk catch(const continue_exception&) {} } - while (is_false(condition_.first) && loop_runtime_checker::check()); + while (is_false(parent_t::condition_.first)); return result; } + }; - inline typename expression_node::node_type type() const - { - return expression_node::e_repeat; - } + template + class repeat_until_loop_bc_rtc_node exprtk_final + : public repeat_until_loop_bc_node, + public loop_runtime_checker + { + public: - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) - { - expression_node::ndb_t::collect(condition_ , node_delete_list); - expression_node::ndb_t::collect(loop_body_ , node_delete_list); - } + typedef repeat_until_loop_bc_node parent_t; + typedef expression_node* expression_ptr; - std::size_t node_depth() const + repeat_until_loop_bc_rtc_node(expression_ptr condition, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(condition, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_repeat_until_loop) + {} + + inline T value() const exprtk_override { - return expression_node::ndb_t::compute_node_depth(condition_, loop_body_); - } + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); - private: + T result = T(0); - branch_t condition_; - branch_t loop_body_; + loop_runtime_checker::reset(); + + do + { + try + { + result = parent_t::loop_body_.first->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + } + while (is_false(parent_t::condition_.first) && loop_runtime_checker::check()); + + return result; + } }; template - class for_loop_bc_node exprtk_final - : public expression_node, - public loop_runtime_checker + class for_loop_bc_node : public for_loop_node { public: + typedef for_loop_node parent_t; typedef expression_node* expression_ptr; - typedef std::pair branch_t; for_loop_bc_node(expression_ptr initialiser, expression_ptr condition, expression_ptr incrementor, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_for_loop) - { - construct_branch_pair(initialiser_, initialiser); - construct_branch_pair(condition_ , condition ); - construct_branch_pair(incrementor_, incrementor); - construct_branch_pair(loop_body_ , loop_body ); - } + expression_ptr loop_body) + : parent_t(initialiser, condition, incrementor, loop_body) + {} - inline T value() const + inline T value() const exprtk_override { - assert(condition_.first); - assert(loop_body_.first); + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); T result = T(0); - loop_runtime_checker::reset(); - - if (initialiser_.first) - initialiser_.first->value(); + if (parent_t::initialiser_.first) + parent_t::initialiser_.first->value(); - if (incrementor_.first) + if (parent_t::incrementor_.first) { - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(parent_t::condition_)) { try { - result = loop_body_.first->value(); + result = parent_t::loop_body_.first->value(); } catch(const break_exception& e) { @@ -7167,16 +7272,16 @@ namespace exprtk catch(const continue_exception&) {} - incrementor_.first->value(); + parent_t::incrementor_.first->value(); } } else { - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(parent_t::condition_)) { try { - result = loop_body_.first->value(); + result = parent_t::loop_body_.first->value(); } catch(const break_exception& e) { @@ -7189,32 +7294,76 @@ namespace exprtk return result; } + }; - inline typename expression_node::node_type type() const - { - return expression_node::e_for; - } + template + class for_loop_bc_rtc_node exprtk_final + : public for_loop_bc_node + , public loop_runtime_checker + { + public: - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) - { - expression_node::ndb_t::collect(initialiser_ , node_delete_list); - expression_node::ndb_t::collect(condition_ , node_delete_list); - expression_node::ndb_t::collect(incrementor_ , node_delete_list); - expression_node::ndb_t::collect(loop_body_ , node_delete_list); - } + typedef for_loop_bc_node parent_t; + typedef expression_node* expression_ptr; - std::size_t node_depth() const + for_loop_bc_rtc_node(expression_ptr initialiser, + expression_ptr condition, + expression_ptr incrementor, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(initialiser, condition, incrementor, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_for_loop) + {} + + inline T value() const exprtk_override { - return expression_node::ndb_t::compute_node_depth - (initialiser_, condition_, incrementor_, loop_body_); - } + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); - private: + T result = T(0); - branch_t initialiser_; - branch_t condition_ ; - branch_t incrementor_; - branch_t loop_body_ ; + loop_runtime_checker::reset(); + + if (parent_t::initialiser_.first) + parent_t::initialiser_.first->value(); + + if (parent_t::incrementor_.first) + { + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + try + { + result = parent_t::loop_body_.first->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + + parent_t::incrementor_.first->value(); + } + } + else + { + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + try + { + result = parent_t::loop_body_.first->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + } + } + + return result; + } }; #endif @@ -7249,7 +7398,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (!arg_list_.empty()) { @@ -7272,17 +7421,17 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const exprtk_final + inline typename expression_node::node_type type() const exprtk_override exprtk_final { return expression_node::e_switch; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(arg_list_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::compute_node_depth(arg_list_); } @@ -7305,7 +7454,7 @@ namespace exprtk : switch_node(arg_list) {} - inline T value() const + inline T value() const exprtk_override { return Switch_N::process(switch_node::arg_list_); } @@ -7342,7 +7491,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { T result = T(0); @@ -7367,17 +7516,17 @@ namespace exprtk return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_mswitch; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(arg_list_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::compute_node_depth(arg_list_); } @@ -7392,8 +7541,7 @@ namespace exprtk { public: - virtual ~ivariable() - {} + virtual ~ivariable() {} virtual T& ref() = 0; virtual const T& ref() const = 0; @@ -7421,22 +7569,22 @@ namespace exprtk return this < (&v); } - inline T value() const + inline T value() const exprtk_override { return (*value_); } - inline T& ref() + inline T& ref() exprtk_override { return (*value_); } - inline const T& ref() const + inline const T& ref() const exprtk_override { return (*value_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_variable; } @@ -7545,7 +7693,7 @@ namespace exprtk cache.first = r0; cache.second = r1; - #ifndef exprtk_enable_runtime_checks + #ifndef exprtk_enable_range_runtime_checks return (r0 <= r1); #else return range_runtime_check(r0, r1, size); @@ -7568,7 +7716,7 @@ namespace exprtk std::pair n1_c; mutable cached_range_t cache; - #ifdef exprtk_enable_runtime_checks + #ifdef exprtk_enable_range_runtime_checks bool range_runtime_check(const std::size_t r0, const std::size_t r1, const std::size_t size) const @@ -7624,8 +7772,7 @@ namespace exprtk typedef vector_node* vector_node_ptr; typedef vec_data_store vds_t; - virtual ~vector_interface() - {} + virtual ~vector_interface() {} virtual std::size_t size () const = 0; @@ -7647,10 +7794,10 @@ namespace exprtk { public: - typedef expression_node* expression_ptr; + typedef expression_node* expression_ptr; typedef vector_holder vector_holder_t; typedef vector_node* vector_node_ptr; - typedef vec_data_store vds_t; + typedef vec_data_store vds_t; explicit vector_node(vector_holder_t* vh) : vector_holder_(vh) @@ -7664,37 +7811,37 @@ namespace exprtk , vds_(vds) {} - inline T value() const + inline T value() const exprtk_override { return vds().data()[0]; } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return const_cast(this); } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return this; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vector; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -7729,22 +7876,22 @@ namespace exprtk construct_branch_pair(index_, index); } - inline T value() const + inline T value() const exprtk_override { return *(vector_base_ + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline T& ref() + inline T& ref() exprtk_override { return *(vector_base_ + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline const T& ref() const + inline const T& ref() const exprtk_override { return *(vector_base_ + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecelem; } @@ -7754,12 +7901,12 @@ namespace exprtk return (*vec_holder_); } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(index_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(index_); } @@ -7792,22 +7939,22 @@ namespace exprtk construct_branch_pair(index_, index); } - inline T value() const + inline T value() const exprtk_override { return *(vds_.data() + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline T& ref() + inline T& ref() exprtk_override { return *(vds_.data() + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline const T& ref() const + inline const T& ref() const exprtk_override { return *(vds_.data() + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_rbvecelem; } @@ -7817,12 +7964,12 @@ namespace exprtk return (*vector_holder_); } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(index_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(index_); } @@ -7854,22 +8001,22 @@ namespace exprtk vector_holder_->set_ref(&vds_.ref()); } - inline T value() const + inline T value() const exprtk_override { return *(vds_.data() + index_); } - inline T& ref() + inline T& ref() exprtk_override { return *(vds_.data() + index_); } - inline const T& ref() const + inline const T& ref() const exprtk_override { return *(vds_.data() + index_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_rbveccelem; } @@ -7903,7 +8050,7 @@ namespace exprtk , single_value_initialse_(single_value_initialse) {} - inline T value() const + inline T value() const exprtk_override { if (single_value_initialse_) { @@ -7914,16 +8061,16 @@ namespace exprtk } else { - std::size_t il_size = initialiser_list_.size(); + const std::size_t initialiser_list_size = initialiser_list_.size(); - for (std::size_t i = 0; i < il_size; ++i) + for (std::size_t i = 0; i < initialiser_list_size; ++i) { *(vector_base_ + i) = initialiser_list_[i]->value(); } - if (il_size < size_) + if (initialiser_list_size < size_) { - for (std::size_t i = il_size; i < size_; ++i) + for (std::size_t i = initialiser_list_size; i < size_; ++i) { *(vector_base_ + i) = T(0); } @@ -7933,24 +8080,25 @@ namespace exprtk return *(vector_base_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecdefass; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(initialiser_list_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(initialiser_list_); } private: - vector_assignment_node& operator=(const vector_assignment_node&); + vector_assignment_node(const vector_assignment_node&) exprtk_delete; + vector_assignment_node& operator=(const vector_assignment_node&) exprtk_delete; mutable T* vector_base_; std::vector initialiser_list_; @@ -7971,13 +8119,13 @@ namespace exprtk , var1_(var1) {} - inline T value() const + inline T value() const exprtk_override { std::swap(var0_->ref(),var1_->ref()); return var1_->ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_swap; } @@ -8002,13 +8150,13 @@ namespace exprtk , var1_(dynamic_cast(var1)) {} - inline T value() const + inline T value() const exprtk_override { std::swap(var0_->ref(),var1_->ref()); return var1_->ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_swap; } @@ -8070,7 +8218,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8094,32 +8242,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return vec0_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return vec0_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvecswap; } - std::size_t size() const + std::size_t size() const exprtk_override { return vec_size_; } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -8142,7 +8290,7 @@ namespace exprtk { public: - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; static std::string null_value; @@ -8164,7 +8312,7 @@ namespace exprtk return this < (&v); } - inline T value() const + inline T value() const exprtk_override { rp_.n1_c.second = (*value_).size() - 1; rp_.cache.second = rp_.n1_c.second; @@ -8172,17 +8320,17 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return ref(); } - char_cptr base() const + char_cptr base() const exprtk_override { return &(*value_)[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return ref().size(); } @@ -8197,21 +8345,30 @@ namespace exprtk return (*value_); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return rp_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return rp_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringvar; } + void rebase(std::string& s) + { + value_ = &s; + rp_.n0_c = std::make_pair(true,0); + rp_.n1_c = std::make_pair(true,value_->size() - 1); + rp_.cache.first = rp_.n0_c.second; + rp_.cache.second = rp_.n1_c.second; + } + private: std::string* value_; @@ -8229,7 +8386,7 @@ namespace exprtk { public: - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; static std::string null_value; @@ -8248,22 +8405,22 @@ namespace exprtk return this < (&v); } - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - inline std::string str() const + inline std::string str() const exprtk_override { return (*value_); } - char_cptr base() const + char_cptr base() const exprtk_override { return &(*value_)[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return ref().size(); } @@ -8283,17 +8440,17 @@ namespace exprtk return (*value_); } - inline range_t& range_ref() + inline range_t& range_ref() exprtk_override { return rp_; } - inline const range_t& range_ref() const + inline const range_t& range_ref() const exprtk_override { return rp_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringvarrng; } @@ -8315,7 +8472,7 @@ namespace exprtk { public: - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; explicit const_string_range_node(const std::string& v, const range_t& rp) : value_(v) @@ -8327,22 +8484,22 @@ namespace exprtk rp_.free(); } - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return value_.data(); } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } @@ -8352,24 +8509,25 @@ namespace exprtk return rp_; } - range_t& range_ref() + range_t& range_ref() exprtk_override { return rp_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return rp_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_cstringvarrng; } private: - const_string_range_node& operator=(const const_string_range_node&); + const_string_range_node(const const_string_range_node&) exprtk_delete; + const_string_range_node& operator=(const const_string_range_node&) exprtk_delete; const std::string value_; range_t rp_; @@ -8386,13 +8544,12 @@ namespace exprtk typedef expression_node * expression_ptr; typedef stringvar_node * strvar_node_ptr; typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; typedef std::pair branch_t; - generic_string_range_node(expression_ptr str_branch, const range_t& brange) : initialised_(false) , str_base_ptr_ (0) @@ -8429,7 +8586,7 @@ namespace exprtk base_range_.free(); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8464,42 +8621,42 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return &value_[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return range_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return range_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strgenrange; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -8523,22 +8680,22 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; + typedef typename range_interface::range_t range_t; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef range_t* range_ptr; + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; string_concat_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) : binary_node(opr, branch0, branch1) - , initialised_(false) - , str0_base_ptr_ (0) - , str1_base_ptr_ (0) - , str0_range_ptr_(0) - , str1_range_ptr_(0) + , initialised_(false) + , str0_base_ptr_ (0) + , str1_base_ptr_ (0) + , str0_range_ptr_(0) + , str1_range_ptr_(0) { range_.n0_c = std::make_pair(true,0); range_.n1_c = std::make_pair(true,0); @@ -8580,7 +8737,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8618,32 +8775,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return &value_[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return range_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return range_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strconcat; } @@ -8667,13 +8824,13 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef stringvar_node * strvar_node_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef stringvar_node * strvar_node_ptr; + typedef string_base_node* str_base_ptr; swap_string_node(expression_ptr branch0, expression_ptr branch1) : binary_node(details::e_swap, branch0, branch1), @@ -8696,7 +8853,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8712,32 +8869,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return str0_node_ptr_->str(); } - char_cptr base() const + char_cptr base() const exprtk_override { return str0_node_ptr_->base(); } - std::size_t size() const + std::size_t size() const exprtk_override { return str0_node_ptr_->size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return str0_node_ptr_->range_ref(); } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return str0_node_ptr_->range_ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strswap; } @@ -8754,12 +8911,12 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; swap_genstrings_node(expression_ptr branch0, expression_ptr branch1) @@ -8808,7 +8965,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8891,15 +9048,15 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strswap; } private: - swap_genstrings_node(swap_genstrings_node&); - swap_genstrings_node& operator=(swap_genstrings_node&); + swap_genstrings_node(const swap_genstrings_node&) exprtk_delete; + swap_genstrings_node& operator=(const swap_genstrings_node&) exprtk_delete; str_base_ptr str0_base_ptr_; str_base_ptr str1_base_ptr_; @@ -8923,12 +9080,12 @@ namespace exprtk : value_(&v) {} - inline T value() const + inline T value() const exprtk_override { return T((*value_).size()); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringvarsize; } @@ -8964,7 +9121,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { T result = std::numeric_limits::quiet_NaN(); @@ -8977,17 +9134,17 @@ namespace exprtk return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringsize; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -9018,13 +9175,13 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef stringvar_node * strvar_node_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef stringvar_node * strvar_node_ptr; + typedef string_base_node* str_base_ptr; assignment_string_node(const operator_type& opr, expression_ptr branch0, @@ -9066,7 +9223,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -9093,32 +9250,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return str0_node_ptr_->str(); } - char_cptr base() const + char_cptr base() const exprtk_override { return str0_node_ptr_->base(); } - std::size_t size() const + std::size_t size() const exprtk_override { return str0_node_ptr_->size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return str0_node_ptr_->range_ref(); } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return str0_node_ptr_->range_ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strass; } @@ -9140,14 +9297,14 @@ namespace exprtk { public: + typedef typename range_interface::range_t range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; typedef expression_node * expression_ptr; typedef stringvar_node * strvar_node_ptr; typedef string_range_node* str_rng_node_ptr; typedef string_base_node * str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; assignment_string_range_node(const operator_type& opr, expression_ptr branch0, @@ -9198,7 +9355,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -9233,32 +9390,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return str0_base_ptr_->str(); } - char_cptr base() const + char_cptr base() const exprtk_override { return str0_base_ptr_->base(); } - std::size_t size() const + std::size_t size() const exprtk_override { return str0_base_ptr_->size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return str0_rng_node_ptr_->range_ref(); } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return str0_rng_node_ptr_->range_ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strass; } @@ -9281,17 +9438,17 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; conditional_string_node(expression_ptr condition, expression_ptr consequent, expression_ptr alternative) - : trinary_node(details::e_default,consequent,alternative,condition) + : trinary_node(details::e_default, consequent, alternative, condition) , initialised_(false) , str0_base_ptr_ (0) , str1_base_ptr_ (0) @@ -9341,7 +9498,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -9393,32 +9550,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return &value_[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return range_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return range_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strcondition; } @@ -9446,12 +9603,12 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; cons_conditional_str_node(expression_ptr condition, expression_ptr consequent) @@ -9486,7 +9643,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -9544,7 +9701,7 @@ namespace exprtk return range_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strccondition; } @@ -9569,12 +9726,12 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; typedef std::pair branch_t; template ::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return str_base_ptr_->str(); } - char_cptr base() const + char_cptr base() const exprtk_override { return str_base_ptr_->base(); } - std::size_t size() const + std::size_t size() const exprtk_override { return str_base_ptr_->size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return str_range_ptr_->range_ref(); } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return str_range_ptr_->range_ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringvararg; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(final_node_ , node_delete_list); expression_node::ndb_t::collect(arg_list_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return std::max( expression_node::ndb_t::compute_node_depth(final_node_), @@ -9714,7 +9871,7 @@ namespace exprtk typedef typename functor_t::ufunc_t unary_functor_t; }; - #define define_sfop3(NN,OP0,OP1) \ + #define define_sfop3(NN, OP0, OP1) \ template \ struct sf##NN##_op : public sf_base \ { \ @@ -9778,7 +9935,7 @@ namespace exprtk define_sfop3(46,x * numeric::cos(y) - z ,"") define_sfop3(47,details::is_true(x) ? y : z,"") - #define define_sfop4(NN,OP0,OP1) \ + #define define_sfop4(NN, OP0, OP1) \ template \ struct sf##NN##_op : public sf_base \ { \ @@ -9927,7 +10084,7 @@ namespace exprtk : trinary_node(opr, branch0, branch1, branch2) {} - inline T value() const + inline T value() const exprtk_override { assert(trinary_node::branch_[0].first); assert(trinary_node::branch_[1].first); @@ -9956,7 +10113,7 @@ namespace exprtk : quaternary_node(opr, branch0, branch1, branch2, branch3) {} - inline T value() const + inline T value() const exprtk_override { assert(quaternary_node::branch_[0].first); assert(quaternary_node::branch_[1].first); @@ -9985,20 +10142,20 @@ namespace exprtk , v2_(v2) {} - inline T value() const + inline T value() const exprtk_override { return SpecialFunction::process(v0_, v1_, v2_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_trinary; } private: - sf3_var_node(sf3_var_node&); - sf3_var_node& operator=(sf3_var_node&); + sf3_var_node(const sf3_var_node&) exprtk_delete; + sf3_var_node& operator=(const sf3_var_node&) exprtk_delete; const T& v0_; const T& v1_; @@ -10019,20 +10176,20 @@ namespace exprtk , v3_(v3) {} - inline T value() const + inline T value() const exprtk_override { return SpecialFunction::process(v0_, v1_, v2_, v3_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_trinary; } private: - sf4_var_node(sf4_var_node&); - sf4_var_node& operator=(sf4_var_node&); + sf4_var_node(const sf4_var_node&) exprtk_delete; + sf4_var_node& operator=(const sf4_var_node&) exprtk_delete; const T& v0_; const T& v1_; @@ -10068,22 +10225,22 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { return VarArgFunction::process(arg_list_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vararg; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(arg_list_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(arg_list_); } @@ -10121,7 +10278,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (!arg_list_.empty()) return VarArgFunction::process(arg_list_); @@ -10129,7 +10286,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vararg; } @@ -10160,7 +10317,7 @@ namespace exprtk ivec_ptr_ = 0; } - inline T value() const + inline T value() const exprtk_override { if (ivec_ptr_) { @@ -10174,17 +10331,17 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecfunc; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(v_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(v_); } @@ -10214,7 +10371,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (var_node_ptr_) { @@ -10254,7 +10411,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (vec_node_ptr_) { @@ -10294,7 +10451,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (rbvec_node_ptr_) { @@ -10334,7 +10491,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (rbvec_node_ptr_) { @@ -10379,7 +10536,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (vec_node_ptr_) { @@ -10439,32 +10596,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return vec_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return vec_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvalass; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -10529,7 +10686,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -10594,32 +10751,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() exprtk_override { return vec0_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() const exprtk_override { return vec0_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvecass; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -10652,7 +10809,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (var_node_ptr_) { @@ -10691,7 +10848,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (vec_node_ptr_) { @@ -10730,7 +10887,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (rbvec_node_ptr_) { @@ -10769,7 +10926,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (rbvec_node_ptr_) { @@ -10813,7 +10970,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (vec_node_ptr_) { @@ -10864,7 +11021,6 @@ namespace exprtk } exprtk_disable_fallthrough_end - #undef exprtk_loop #undef case_stmt @@ -10874,37 +11030,37 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return vec_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return vec_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecopvalass; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } - bool side_effect() const + bool side_effect() const exprtk_override { return true; } @@ -10963,7 +11119,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -11029,37 +11185,37 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return vec0_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return vec0_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecopvecass; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } - bool side_effect() const + bool side_effect() const exprtk_override { return true; } @@ -11154,7 +11310,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -11222,32 +11378,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvecarith; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds_.size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -11317,7 +11473,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { if (vec0_node_ptr_) { @@ -11383,32 +11539,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvalarith; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -11476,7 +11632,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { if (vec1_node_ptr_) { @@ -11542,32 +11698,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvalarith; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -11633,7 +11789,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { assert(unary_node::branch_.first); @@ -11697,32 +11853,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecunaryop; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -11804,7 +11960,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -11838,44 +11994,44 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecondition; } - std::size_t size() const + std::size_t size() const exprtk_override { return vec_size_; } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(condition_ , node_delete_list); expression_node::ndb_t::collect(consequent_ , node_delete_list); expression_node::ndb_t::collect(alternative_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth (condition_, consequent_, alternative_); @@ -11908,7 +12064,7 @@ namespace exprtk : binary_node(opr, branch0, branch1) {} - inline T value() const + inline T value() const exprtk_override { assert(binary_node::branch_[0].first); assert(binary_node::branch_[1].first); @@ -11935,7 +12091,7 @@ namespace exprtk : binary_node(opr, branch0, branch1) {} - inline T value() const + inline T value() const exprtk_override { assert(binary_node::branch_[0].first); assert(binary_node::branch_[1].first); @@ -11995,7 +12151,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { // Needed for incompetent and broken msvc compiler versions #ifdef _MSC_VER @@ -12015,17 +12171,17 @@ namespace exprtk #endif } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_function; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::template compute_node_depth(branch_); } @@ -12264,7 +12420,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { if (function_) return (*function_)(); @@ -12272,7 +12428,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_function; } @@ -12302,7 +12458,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { if (function_) { @@ -12313,12 +12469,12 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vafunction; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { for (std::size_t i = 0; i < arg_list_.size(); ++i) { @@ -12329,7 +12485,7 @@ namespace exprtk } } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(arg_list_); } @@ -12362,7 +12518,7 @@ namespace exprtk typedef vector_node_t* vector_node_ptr_t; typedef range_interface range_interface_t; typedef range_data_type range_data_type_t; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef std::pair branch_t; typedef std::pair void_t; @@ -12377,15 +12533,14 @@ namespace exprtk , arg_list_(arg_list) {} - virtual ~generic_function_node() - {} + virtual ~generic_function_node() {} - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -12481,7 +12636,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { if (function_) { @@ -12496,7 +12651,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_genfunction; } @@ -12560,7 +12715,7 @@ namespace exprtk public: typedef generic_function_node gen_function_t; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; string_function_node(StringFunction* func, const std::vector& arg_list) @@ -12577,7 +12732,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { if (gen_function_t::function_) { @@ -12601,32 +12756,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strfunction; } - std::string str() const + std::string str() const exprtk_override { return ret_string_; } - char_cptr base() const + char_cptr base() const exprtk_override { return &ret_string_[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return ret_string_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return range_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return range_; } @@ -12644,7 +12799,7 @@ namespace exprtk public: typedef generic_function_node gen_function_t; - typedef range_pack range_t; + typedef typename gen_function_t::range_t range_t; multimode_genfunction_node(GenericFunction* func, const std::size_t& param_seq_index, @@ -12653,7 +12808,7 @@ namespace exprtk , param_seq_index_(param_seq_index) {} - inline T value() const + inline T value() const exprtk_override { if (gen_function_t::function_) { @@ -12672,7 +12827,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const exprtk_final + inline typename expression_node::node_type type() const exprtk_override exprtk_final { return expression_node::e_genfunction; } @@ -12689,7 +12844,7 @@ namespace exprtk public: typedef string_function_node str_function_t; - typedef range_pack range_t; + typedef typename str_function_t::range_t range_t; multimode_strfunction_node(StringFunction* func, const std::size_t& param_seq_index, @@ -12698,7 +12853,7 @@ namespace exprtk , param_seq_index_(param_seq_index) {} - inline T value() const + inline T value() const exprtk_override { if (str_function_t::function_) { @@ -12723,7 +12878,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strfunction; } @@ -12742,8 +12897,7 @@ namespace exprtk { public: - virtual ~null_igenfunc() - {} + virtual ~null_igenfunc() {} typedef type_store generic_type; typedef typename generic_type::parameter_list parameter_list_t; @@ -12760,10 +12914,10 @@ namespace exprtk { public: - typedef null_igenfunc igeneric_function_t; + typedef results_context results_context_t; + typedef null_igenfunc igeneric_function_t; typedef igeneric_function_t* igeneric_function_ptr; typedef generic_function_node gen_function_t; - typedef results_context results_context_t; return_node(const std::vector& arg_list, results_context_t& rc) @@ -12771,7 +12925,7 @@ namespace exprtk , results_context_(&rc) {} - inline T value() const + inline T value() const exprtk_override { if ( (0 != results_context_) && @@ -12789,7 +12943,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_return; } @@ -12815,7 +12969,7 @@ namespace exprtk construct_branch_pair(body_, body); } - inline T value() const + inline T value() const exprtk_override { assert(body_.first); @@ -12833,7 +12987,7 @@ namespace exprtk } } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_retenv; } @@ -12843,12 +12997,12 @@ namespace exprtk return &return_invoked_; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(body_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(body_); } @@ -14091,8 +14245,7 @@ namespace exprtk { public: - virtual ~vov_base_node() - {} + virtual ~vov_base_node() {} inline virtual operator_type operation() const { @@ -14109,8 +14262,7 @@ namespace exprtk { public: - virtual ~cov_base_node() - {} + virtual ~cov_base_node() {} inline virtual operator_type operation() const { @@ -14127,8 +14279,7 @@ namespace exprtk { public: - virtual ~voc_base_node() - {} + virtual ~voc_base_node() {} inline virtual operator_type operation() const { @@ -14145,8 +14296,7 @@ namespace exprtk { public: - virtual ~vob_base_node() - {} + virtual ~vob_base_node() {} virtual const T& v() const = 0; }; @@ -14156,8 +14306,7 @@ namespace exprtk { public: - virtual ~bov_base_node() - {} + virtual ~bov_base_node() {} virtual const T& v() const = 0; }; @@ -14167,8 +14316,7 @@ namespace exprtk { public: - virtual ~cob_base_node() - {} + virtual ~cob_base_node() {} inline virtual operator_type operation() const { @@ -14187,8 +14335,7 @@ namespace exprtk { public: - virtual ~boc_base_node() - {} + virtual ~boc_base_node() {} inline virtual operator_type operation() const { @@ -14207,8 +14354,7 @@ namespace exprtk { public: - virtual ~uv_base_node() - {} + virtual ~uv_base_node() {} inline virtual operator_type operation() const { @@ -14223,8 +14369,7 @@ namespace exprtk { public: - virtual ~sos_base_node() - {} + virtual ~sos_base_node() {} inline virtual operator_type operation() const { @@ -14237,8 +14382,7 @@ namespace exprtk { public: - virtual ~sosos_base_node() - {} + virtual ~sosos_base_node() {} inline virtual operator_type operation() const { @@ -14251,8 +14395,7 @@ namespace exprtk { public: - virtual ~T0oT1oT2_base_node() - {} + virtual ~T0oT1oT2_base_node() {} virtual std::string type_id() const = 0; }; @@ -14262,8 +14405,7 @@ namespace exprtk { public: - virtual ~T0oT1oT2oT3_base_node() - {} + virtual ~T0oT1oT2oT3_base_node() {} virtual std::string type_id() const = 0; }; @@ -14280,30 +14422,30 @@ namespace exprtk : v_(var) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(v_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } private: - unary_variable_node(unary_variable_node&); - unary_variable_node& operator=(unary_variable_node&); + unary_variable_node(const unary_variable_node&) exprtk_delete; + unary_variable_node& operator=(const unary_variable_node&) exprtk_delete; const T& v_; }; @@ -14328,21 +14470,16 @@ namespace exprtk , f_ (bf ) {} - inline T value() const + inline T value() const exprtk_override { return f_(u0_(v0_),u1_(v1_)); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_uvouv; } - inline operator_type operation() const - { - return details::e_default; - } - inline const T& v0() { return v0_; @@ -14370,8 +14507,8 @@ namespace exprtk private: - uvouv_node(uvouv_node&); - uvouv_node& operator=(uvouv_node&); + uvouv_node(const uvouv_node&) exprtk_delete; + uvouv_node& operator=(const uvouv_node&) exprtk_delete; const T& v0_; const T& v1_; @@ -14385,31 +14522,31 @@ namespace exprtk { public: - typedef expression_node* expression_ptr; + typedef Operation operation_t; + typedef expression_node* expression_ptr; typedef std::pair branch_t; - typedef Operation operation_t; explicit unary_branch_node(expression_ptr branch) { construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { return Operation::process(branch_.first->value()); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() { return Operation::operation(); } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } @@ -14419,20 +14556,20 @@ namespace exprtk branch_.second = false; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - unary_branch_node(unary_branch_node&); - unary_branch_node& operator=(unary_branch_node&); + unary_branch_node(const unary_branch_node&) exprtk_delete; + unary_branch_node& operator=(const unary_branch_node&) exprtk_delete; branch_t branch_; }; @@ -14615,7 +14752,7 @@ namespace exprtk template const typename expression_node::node_type nodetype_T0oT1::result = expression_node::e_none; - #define synthesis_node_type_define(T0_,T1_,v_) \ + #define synthesis_node_type_define(T0_, T1_, v_) \ template \ struct nodetype_T0oT1 { static const typename expression_node::node_type result; }; \ template \ @@ -14637,7 +14774,7 @@ namespace exprtk template const typename expression_node::node_type nodetype_T0oT1oT2::result = expression_node::e_none; - #define synthesis_node_type_define(T0_,T1_,T2_,v_) \ + #define synthesis_node_type_define(T0_, T1_, T2_, v_) \ template \ struct nodetype_T0oT1oT2 { static const typename expression_node::node_type result; }; \ template \ @@ -14659,7 +14796,7 @@ namespace exprtk template const typename expression_node::node_type nodetype_T0oT1oT2oT3::result = expression_node::e_none; - #define synthesis_node_type_define(T0_,T1_,T2_,T3_,v_) \ + #define synthesis_node_type_define(T0_, T1_, T2_, T3_, v_) \ template \ struct nodetype_T0oT1oT2oT3 { static const typename expression_node::node_type result; }; \ template \ @@ -14699,18 +14836,18 @@ namespace exprtk , f_ (p2) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1::result; return result; } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return e_default; } - inline T value() const + inline T value() const exprtk_override { return f_(t0_,t1_); } @@ -14742,8 +14879,8 @@ namespace exprtk private: - T0oT1(T0oT1&) {} - T0oT1& operator=(T0oT1&) { return (*this); } + T0oT1(const T0oT1&) exprtk_delete; + T0oT1& operator=(const T0oT1&) { return (*this); } T0 t0_; T1 t1_; @@ -14769,18 +14906,18 @@ namespace exprtk , f1_(p4) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; return result; } - inline operator_type operation() const + inline operator_type operation() { return e_default; } - inline T value() const + inline T value() const exprtk_override { return ProcessMode::process(t0_, t1_, t2_, f0_, f1_); } @@ -14810,7 +14947,7 @@ namespace exprtk return f1_; } - std::string type_id() const + std::string type_id() const exprtk_override { return id(); } @@ -14830,8 +14967,8 @@ namespace exprtk private: - T0oT1oT2(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -14865,7 +15002,7 @@ namespace exprtk , f2_(p6) {} - inline T value() const + inline T value() const exprtk_override { return ProcessMode::process(t0_, t1_, t2_, t3_, f0_, f1_, f2_); } @@ -14905,7 +15042,7 @@ namespace exprtk return f2_; } - inline std::string type_id() const + inline std::string type_id() const exprtk_override { return id(); } @@ -14927,8 +15064,8 @@ namespace exprtk private: - T0oT1oT2oT3(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2oT3(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -14956,18 +15093,18 @@ namespace exprtk , f_ (p3) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; return result; } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return e_default; } - inline T value() const + inline T value() const exprtk_override { return f_(t0_, t1_, t2_); } @@ -15012,8 +15149,8 @@ namespace exprtk private: - T0oT1oT2_sf3(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2_sf3(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -15026,8 +15163,7 @@ namespace exprtk { public: - virtual ~sf3ext_type_node() - {} + virtual ~sf3ext_type_node() {} virtual T0 t0() const = 0; @@ -15044,7 +15180,7 @@ namespace exprtk typedef typename details::functor_t functor_t; typedef typename functor_t::tfunc_t tfunc_t; typedef T value_type; - typedef T0oT1oT2_sf3ext node_type; + typedef T0oT1oT2_sf3ext node_type; T0oT1oT2_sf3ext(T0 p0, T1 p1, T2 p2) : t0_(p0) @@ -15052,38 +15188,38 @@ namespace exprtk , t2_(p2) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; return result; } - inline operator_type operation() const + inline operator_type operation() { return e_default; } - inline T value() const + inline T value() const exprtk_override { return SF3Operation::process(t0_, t1_, t2_); } - T0 t0() const + T0 t0() const exprtk_override { return t0_; } - T1 t1() const + T1 t1() const exprtk_override { return t1_; } - T2 t2() const + T2 t2() const exprtk_override { return t2_; } - std::string type_id() const + std::string type_id() const exprtk_override { return id(); } @@ -15103,8 +15239,8 @@ namespace exprtk private: - T0oT1oT2_sf3ext(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2_sf3ext(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -15133,7 +15269,7 @@ namespace exprtk typedef typename details::functor_t functor_t; typedef typename functor_t::qfunc_t qfunc_t; typedef T value_type; - typedef T0oT1oT2oT3_sf4 node_type; + typedef T0oT1oT2oT3_sf4 node_type; T0oT1oT2oT3_sf4(T0 p0, T1 p1, T2 p2, T3 p3, const qfunc_t p4) : t0_(p0) @@ -15143,18 +15279,18 @@ namespace exprtk , f_ (p4) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2oT3::result; return result; } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return e_default; } - inline T value() const + inline T value() const exprtk_override { return f_(t0_, t1_, t2_, t3_); } @@ -15204,8 +15340,8 @@ namespace exprtk private: - T0oT1oT2oT3_sf4(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2oT3_sf4(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -15222,7 +15358,7 @@ namespace exprtk typedef typename details::functor_t functor_t; typedef typename functor_t::tfunc_t tfunc_t; typedef T value_type; - typedef T0oT1oT2oT3_sf4ext node_type; + typedef T0oT1oT2oT3_sf4ext node_type; T0oT1oT2oT3_sf4ext(T0 p0, T1 p1, T2 p2, T3 p3) : t0_(p0) @@ -15231,18 +15367,13 @@ namespace exprtk , t3_(p3) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2oT3::result; return result; } - inline operator_type operation() const - { - return e_default; - } - - inline T value() const + inline T value() const exprtk_override { return SF4Operation::process(t0_, t1_, t2_, t3_); } @@ -15267,7 +15398,7 @@ namespace exprtk return t3_; } - std::string type_id() const + std::string type_id() const exprtk_override { return id(); } @@ -15287,8 +15418,8 @@ namespace exprtk private: - T0oT1oT2oT3_sf4ext(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2oT3_sf4ext(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -15354,27 +15485,27 @@ namespace exprtk , v1_(var1) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(v0_,v1_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T& v0() const + inline const T& v0() const exprtk_override { return v0_; } - inline const T& v1() const + inline const T& v1() const exprtk_override { return v1_; } @@ -15386,8 +15517,8 @@ namespace exprtk private: - vov_node(vov_node&); - vov_node& operator=(vov_node&); + vov_node(const vov_node&) exprtk_delete; + vov_node& operator=(const vov_node&) exprtk_delete; }; template @@ -15404,27 +15535,27 @@ namespace exprtk , v_(var) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(c_,v_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T c() const + inline const T c() const exprtk_override { return c_; } - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } @@ -15436,8 +15567,8 @@ namespace exprtk private: - cov_node(const cov_node&); - cov_node& operator=(const cov_node&); + cov_node(const cov_node&) exprtk_delete; + cov_node& operator=(const cov_node&) exprtk_delete; }; template @@ -15454,22 +15585,22 @@ namespace exprtk , c_(const_var) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(v_,c_); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T c() const + inline const T c() const exprtk_override { return c_; } - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } @@ -15481,8 +15612,8 @@ namespace exprtk private: - voc_node(const voc_node&); - voc_node& operator=(const voc_node&); + voc_node(const voc_node&) exprtk_delete; + voc_node& operator=(const voc_node&) exprtk_delete; }; template @@ -15501,41 +15632,36 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return Operation::process(v_,branch_.first->value()); } - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - vob_node(const vob_node&); - vob_node& operator=(const vob_node&); + vob_node(const vob_node&) exprtk_delete; + vob_node& operator=(const vob_node&) exprtk_delete; const T& v_; branch_t branch_; @@ -15557,41 +15683,36 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return Operation::process(branch_.first->value(),v_); } - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - bov_node(const bov_node&); - bov_node& operator=(const bov_node&); + bov_node(const bov_node&) exprtk_delete; + bov_node& operator=(const bov_node&) exprtk_delete; const T& v_; branch_t branch_; @@ -15613,52 +15734,52 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return Operation::process(c_,branch_.first->value()); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T c() const + inline const T c() const exprtk_override { return c_; } - inline void set_c(const T new_c) + inline void set_c(const T new_c) exprtk_override { (*const_cast(&c_)) = new_c; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - inline expression_node* move_branch(const std::size_t&) + inline expression_node* move_branch(const std::size_t&) exprtk_override { branch_.second = false; return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - cob_node(const cob_node&); - cob_node& operator=(const cob_node&); + cob_node(const cob_node&) exprtk_delete; + cob_node& operator=(const cob_node&) exprtk_delete; const T c_; branch_t branch_; @@ -15680,52 +15801,52 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return Operation::process(branch_.first->value(),c_); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T c() const + inline const T c() const exprtk_override { return c_; } - inline void set_c(const T new_c) + inline void set_c(const T new_c) exprtk_override { (*const_cast(&c_)) = new_c; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - inline expression_node* move_branch(const std::size_t&) + inline expression_node* move_branch(const std::size_t&) exprtk_override { branch_.second = false; return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - boc_node(const boc_node&); - boc_node& operator=(const boc_node&); + boc_node(const boc_node&) exprtk_delete; + boc_node& operator=(const boc_node&) exprtk_delete; const T c_; branch_t branch_; @@ -15746,17 +15867,17 @@ namespace exprtk , s1_(p1) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(s0_,s1_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -15778,8 +15899,8 @@ namespace exprtk private: - sos_node(sos_node&); - sos_node& operator=(sos_node&); + sos_node(const sos_node&) exprtk_delete; + sos_node& operator=(const sos_node&) exprtk_delete; }; template @@ -15789,6 +15910,7 @@ namespace exprtk typedef expression_node* expression_ptr; typedef Operation operation_t; + typedef str_xrox_node node_type; // string-range op string node explicit str_xrox_node(SType0 p0, SType1 p1, RangePack rp0) @@ -15802,7 +15924,7 @@ namespace exprtk rp0_.free(); } - inline T value() const + inline T value() const exprtk_override { std::size_t r0 = 0; std::size_t r1 = 0; @@ -15813,12 +15935,12 @@ namespace exprtk return T(0); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -15841,8 +15963,8 @@ namespace exprtk private: - str_xrox_node(str_xrox_node&); - str_xrox_node& operator=(str_xrox_node&); + str_xrox_node(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) exprtk_delete; }; template @@ -15852,6 +15974,7 @@ namespace exprtk typedef expression_node* expression_ptr; typedef Operation operation_t; + typedef str_xoxr_node node_type; // string op string range node explicit str_xoxr_node(SType0 p0, SType1 p1, RangePack rp1) @@ -15865,7 +15988,7 @@ namespace exprtk rp1_.free(); } - inline T value() const + inline T value() const exprtk_override { std::size_t r0 = 0; std::size_t r1 = 0; @@ -15876,12 +15999,12 @@ namespace exprtk return T(0); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -15904,8 +16027,8 @@ namespace exprtk private: - str_xoxr_node(str_xoxr_node&); - str_xoxr_node& operator=(str_xoxr_node&); + str_xoxr_node(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) exprtk_delete; }; template @@ -15915,6 +16038,7 @@ namespace exprtk typedef expression_node* expression_ptr; typedef Operation operation_t; + typedef str_xroxr_node node_type; // string-range op string-range node explicit str_xroxr_node(SType0 p0, SType1 p1, RangePack rp0, RangePack rp1) @@ -15930,7 +16054,7 @@ namespace exprtk rp1_.free(); } - inline T value() const + inline T value() const exprtk_override { std::size_t r0_0 = 0; std::size_t r0_1 = 0; @@ -15951,12 +16075,12 @@ namespace exprtk return T(0); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -15980,8 +16104,8 @@ namespace exprtk private: - str_xroxr_node(str_xroxr_node&); - str_xroxr_node& operator=(str_xroxr_node&); + str_xroxr_node(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) exprtk_delete; }; template @@ -16036,7 +16160,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if ( str0_base_ptr_ && @@ -16072,20 +16196,15 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const - { - return Operation::operation(); - } - private: - str_sogens_node(str_sogens_node&); - str_sogens_node& operator=(str_sogens_node&); + str_sogens_node(const str_sogens_node&) exprtk_delete; + str_sogens_node& operator=(const str_sogens_node&) exprtk_delete; str_base_ptr str0_base_ptr_; str_base_ptr str1_base_ptr_; @@ -16100,6 +16219,7 @@ namespace exprtk typedef expression_node* expression_ptr; typedef Operation operation_t; + typedef sosos_node node_type; // variable op variable node explicit sosos_node(SType0 p0, SType1 p1, SType2 p2) @@ -16108,17 +16228,17 @@ namespace exprtk , s2_(p2) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(s0_, s1_, s2_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -16146,8 +16266,8 @@ namespace exprtk private: - sosos_node(sosos_node&); - sosos_node& operator=(sosos_node&); + sosos_node(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) exprtk_delete; }; #endif @@ -16163,20 +16283,20 @@ namespace exprtk : v_(v) {} - inline T value() const + inline T value() const exprtk_override { return PowOp::result(v_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_ipow; } private: - ipow_node(const ipow_node&); - ipow_node& operator=(const ipow_node&); + ipow_node(const ipow_node&) exprtk_delete; + ipow_node& operator=(const ipow_node&) exprtk_delete; const T& v_; }; @@ -16195,31 +16315,31 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return PowOp::result(branch_.first->value()); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_ipow; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - bipow_node(const bipow_node&); - bipow_node& operator=(const bipow_node&); + bipow_node(const bipow_node&) exprtk_delete; + bipow_node& operator=(const bipow_node&) exprtk_delete; branch_t branch_; }; @@ -16236,20 +16356,20 @@ namespace exprtk : v_(v) {} - inline T value() const + inline T value() const exprtk_override { return (T(1) / PowOp::result(v_)); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_ipowinv; } private: - ipowinv_node(const ipowinv_node&); - ipowinv_node& operator=(const ipowinv_node&); + ipowinv_node(const ipowinv_node&) exprtk_delete; + ipowinv_node& operator=(const ipowinv_node&) exprtk_delete; const T& v_; }; @@ -16268,31 +16388,31 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return (T(1) / PowOp::result(branch_.first->value())); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_ipowinv; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - bipowninv_node(const bipowninv_node&); - bipowninv_node& operator=(const bipowninv_node&); + bipowninv_node(const bipowninv_node&) exprtk_delete; + bipowninv_node& operator=(const bipowninv_node&) exprtk_delete; branch_t branch_; }; @@ -16824,7 +16944,7 @@ namespace exprtk inline void load_operations_map(std::multimap& m) { - #define register_op(Symbol,Type,Args) \ + #define register_op(Symbol, Type, Args) \ m.insert(std::make_pair(std::string(Symbol),details::base_operation_t(Type,Args))); \ register_op("abs" , e_abs , 1) @@ -16976,8 +17096,7 @@ namespace exprtk : param_count(pc) {} - virtual ~ifunction() - {} + virtual ~ifunction() {} #define empty_method_body(N) \ { \ @@ -17068,8 +17187,7 @@ namespace exprtk { public: - virtual ~ivararg_function() - {} + virtual ~ivararg_function() {} inline virtual T operator() (const std::vector&) { @@ -17099,8 +17217,7 @@ namespace exprtk , rtrn_type(rtr_type) {} - virtual ~igeneric_function() - {} + virtual ~igeneric_function() {} #define igeneric_function_empty_body(N) \ { \ @@ -17128,6 +17245,43 @@ namespace exprtk return_type rtrn_type; }; + #ifndef exprtk_disable_string_capabilities + template + class stringvar_base + { + public: + + typedef typename details::stringvar_node stringvar_node_t; + + stringvar_base(const std::string& name, stringvar_node_t* svn) + : name_(name) + , string_varnode_(svn) + {} + + bool valid() const + { + return !name_.empty() && (0 != string_varnode_); + } + + std::string name() const + { + assert(string_varnode_); + return name_; + } + + void rebase(std::string& s) + { + assert(string_varnode_); + string_varnode_->rebase(s); + } + + private: + + std::string name_; + stringvar_node_t* string_varnode_; + }; + #endif + template class parser; template class expression_helper; @@ -17974,6 +18128,24 @@ namespace exprtk else return local_data().stringvar_store.get(string_name); } + + inline stringvar_base get_stringvar_base(const std::string& string_name) const + { + static stringvar_base null_stringvar_base("",reinterpret_cast(0)); + if (!valid()) + return null_stringvar_base; + else if (!valid_symbol(string_name)) + return null_stringvar_base; + + stringvar_ptr stringvar = local_data().stringvar_store.get(string_name); + + if (0 == stringvar) + { + return null_stringvar_base; + } + + return stringvar_base(string_name,stringvar); + } #endif inline function_ptr get_function(const std::string& function_name) const @@ -18732,7 +18904,7 @@ namespace exprtk control_block* control_block_; friend class parser; - }; + }; // class symbol_table template class function_compositor; @@ -18743,8 +18915,8 @@ namespace exprtk private: typedef details::expression_node* expression_ptr; - typedef details::vector_holder* vector_holder_ptr; - typedef std::vector > symtab_list_t; + typedef details::vector_holder* vector_holder_ptr; + typedef std::vector > symtab_list_t; struct control_block { @@ -19106,7 +19278,7 @@ namespace exprtk friend class parser; friend class expression_helper; friend class function_compositor; - }; + }; // class expression template class expression_helper @@ -19315,10 +19487,16 @@ namespace exprtk typedef details::while_loop_node while_loop_node_t; typedef details::repeat_until_loop_node repeat_until_loop_node_t; typedef details::for_loop_node for_loop_node_t; + typedef details::while_loop_rtc_node while_loop_rtc_node_t; + typedef details::repeat_until_loop_rtc_node repeat_until_loop_rtc_node_t; + typedef details::for_loop_rtc_node for_loop_rtc_node_t; #ifndef exprtk_disable_break_continue typedef details::while_loop_bc_node while_loop_bc_node_t; typedef details::repeat_until_loop_bc_node repeat_until_loop_bc_node_t; typedef details::for_loop_bc_node for_loop_bc_node_t; + typedef details::while_loop_bc_rtc_node while_loop_bc_rtc_node_t; + typedef details::repeat_until_loop_bc_rtc_node repeat_until_loop_bc_rtc_node_t; + typedef details::for_loop_bc_rtc_node for_loop_bc_rtc_node_t; #endif typedef details::switch_node switch_node_t; typedef details::variable_node variable_node_t; @@ -19356,10 +19534,10 @@ namespace exprtk typedef details::vector_holder* vector_holder_ptr; typedef typename details::functor_t functor_t; - typedef typename functor_t::qfunc_t quaternary_functor_t; - typedef typename functor_t::tfunc_t trinary_functor_t; - typedef typename functor_t::bfunc_t binary_functor_t; - typedef typename functor_t::ufunc_t unary_functor_t; + typedef typename functor_t::qfunc_t quaternary_functor_t; + typedef typename functor_t::tfunc_t trinary_functor_t; + typedef typename functor_t::bfunc_t binary_functor_t; + typedef typename functor_t::ufunc_t unary_functor_t; typedef details::operator_type operator_t; @@ -19678,7 +19856,8 @@ namespace exprtk private: - scope_element_manager& operator=(const scope_element_manager&); + scope_element_manager(const scope_element_manager&) exprtk_delete; + scope_element_manager& operator=(const scope_element_manager&) exprtk_delete; parser_t& parser_; std::vector element_; @@ -19718,7 +19897,8 @@ namespace exprtk private: - scope_handler& operator=(const scope_handler&); + scope_handler(const scope_handler&) exprtk_delete; + scope_handler& operator=(const scope_handler&) exprtk_delete; parser_t& parser_; }; @@ -19756,7 +19936,8 @@ namespace exprtk private: - stack_limit_handler& operator=(const stack_limit_handler&); + stack_limit_handler(const stack_limit_handler&) exprtk_delete; + stack_limit_handler& operator=(const stack_limit_handler&) exprtk_delete; parser_t& parser_; bool limit_exceeded_; @@ -19766,14 +19947,14 @@ namespace exprtk { symbol_table_list_t symtab_list_; - typedef typename symbol_table_t::local_data_t local_data_t; - typedef typename symbol_table_t::variable_ptr variable_ptr; - typedef typename symbol_table_t::function_ptr function_ptr; + typedef typename symbol_table_t::local_data_t local_data_t; + typedef typename symbol_table_t::variable_ptr variable_ptr; + typedef typename symbol_table_t::function_ptr function_ptr; #ifndef exprtk_disable_string_capabilities typedef typename symbol_table_t::stringvar_ptr stringvar_ptr; #endif - typedef typename symbol_table_t::vector_holder_ptr vector_holder_ptr; - typedef typename symbol_table_t::vararg_function_ptr vararg_function_ptr; + typedef typename symbol_table_t::vector_holder_ptr vector_holder_ptr; + typedef typename symbol_table_t::vararg_function_ptr vararg_function_ptr; typedef typename symbol_table_t::generic_function_ptr generic_function_ptr; inline bool empty() const @@ -20262,8 +20443,7 @@ namespace exprtk : mode(m) {} - virtual ~unknown_symbol_resolver() - {} + virtual ~unknown_symbol_resolver() {} virtual bool process(const std::string& /*unknown_symbol*/, usr_symbol_type& st, @@ -21134,8 +21314,7 @@ namespace exprtk expression_generator_.set_strength_reduction_state(settings_.strength_reduction_enabled()); } - ~parser() - {} + ~parser() {} inline void init_precompilation() { @@ -21300,11 +21479,8 @@ namespace exprtk inline expression_t compile(const std::string& expression_string, symbol_table_t& symtab) { expression_t expression; - expression.register_symbol_table(symtab); - compile(expression_string,expression); - return expression; } @@ -21373,7 +21549,7 @@ namespace exprtk if (helper_assembly_.error_token_scanner) { lexer::helper::bracket_checker* bracket_checker_ptr = 0; - lexer::helper::numeric_checker* numeric_checker_ptr = 0; + lexer::helper::numeric_checker* numeric_checker_ptr = 0; lexer::helper::sequence_validator* sequence_validator_ptr = 0; lexer::helper::sequence_validator_3tokens* sequence_validator3_ptr = 0; @@ -21385,7 +21561,7 @@ namespace exprtk "ERR005 - Mismatched brackets: '" + bracket_checker_ptr->error_token().value + "'", exprtk_error_location)); } - else if (0 != (numeric_checker_ptr = dynamic_cast(helper_assembly_.error_token_scanner))) + else if (0 != (numeric_checker_ptr = dynamic_cast*>(helper_assembly_.error_token_scanner))) { for (std::size_t i = 0; i < numeric_checker_ptr->error_count(); ++i) { @@ -21625,7 +21801,7 @@ namespace exprtk scoped_vec_delete sdd((*this),arg_list); lexer::token begin_token; - lexer::token end_token; + lexer::token end_token; for ( ; ; ) { @@ -22088,7 +22264,8 @@ namespace exprtk private: - scoped_expression_delete& operator=(const scoped_expression_delete&); + scoped_expression_delete(const scoped_expression_delete&) exprtk_delete; + scoped_expression_delete& operator=(const scoped_expression_delete&) exprtk_delete; }; template @@ -22125,7 +22302,8 @@ namespace exprtk private: - scoped_delete& operator=(const scoped_delete&); + scoped_delete(const scoped_delete&) exprtk_delete; + scoped_delete& operator=(const scoped_delete&) exprtk_delete; }; template @@ -22158,7 +22336,8 @@ namespace exprtk private: - scoped_deq_delete& operator=(const scoped_deq_delete&); + scoped_deq_delete(const scoped_deq_delete&) exprtk_delete; + scoped_deq_delete& operator=(const scoped_deq_delete&) exprtk_delete; }; template @@ -22191,7 +22370,8 @@ namespace exprtk private: - scoped_vec_delete& operator=(const scoped_vec_delete&); + scoped_vec_delete(const scoped_vec_delete&) exprtk_delete; + scoped_vec_delete& operator=(const scoped_vec_delete&) exprtk_delete; }; struct scoped_bool_negator @@ -22867,20 +23047,22 @@ namespace exprtk } else if (token_is(token_t::e_rbracket)) { - // 00. if (x) y; - // 01. if (x) y; else z; - // 02. if (x) y; else {z0; ... zn;} - // 03. if (x) y; else if (z) w; - // 04. if (x) y; else if (z) w; else u; - // 05. if (x) y; else if (z) w; else {u0; ... un;} - // 06. if (x) y; else if (z) {w0; ... wn;} - // 07. if (x) {y0; ... yn;} - // 08. if (x) {y0; ... yn;} else z; - // 09. if (x) {y0; ... yn;} else {z0; ... zn;}; - // 10. if (x) {y0; ... yn;} else if (z) w; - // 11. if (x) {y0; ... yn;} else if (z) w; else u; - // 12. if (x) {y0; ... nex;} else if (z) w; else {u0 ... un;} - // 13. if (x) {y0; ... yn;} else if (z) {w0; ... wn;} + /* + 00. if (x) y; + 01. if (x) y; else z; + 02. if (x) y; else {z0; ... zn;} + 03. if (x) y; else if (z) w; + 04. if (x) y; else if (z) w; else u; + 05. if (x) y; else if (z) w; else {u0; ... un;} + 06. if (x) y; else if (z) {w0; ... wn;} + 07. if (x) {y0; ... yn;} + 08. if (x) {y0; ... yn;} else z; + 09. if (x) {y0; ... yn;} else {z0; ... zn;}; + 10. if (x) {y0; ... yn;} else if (z) w; + 11. if (x) {y0; ... yn;} else if (z) w; else u; + 12. if (x) {y0; ... nex;} else if (z) w; else {u0 ... un;} + 13. if (x) {y0; ... yn;} else if (z) {w0; ... wn;} + */ return parse_conditional_statement_02(condition); } @@ -24898,8 +25080,8 @@ namespace exprtk } } - type_checker(const type_checker&); - type_checker& operator=(const type_checker&); + type_checker(const type_checker&) exprtk_delete; + type_checker& operator=(const type_checker&) exprtk_delete; bool invalid_state_; parser_t& parser_; @@ -26504,7 +26686,7 @@ namespace exprtk { bool implied_mul = false; - if (is_generally_string_node(branch)) + if (details::is_generally_string_node(branch)) return true; const lexer::parser_helper::token_advance_mode hold = prsrhlpr_t::e_hold; @@ -26880,83 +27062,85 @@ namespace exprtk static const std::string symbol_return = "return" ; static const std::string symbol_not = "not" ; - if (valid_vararg_operation(current_token().value)) + const std::string symbol = current_token().value; + + if (valid_vararg_operation(symbol)) { return parse_vararg_function(); } - else if (details::imatch(current_token().value, symbol_not)) + else if (details::imatch(symbol, symbol_not)) { return parse_not_statement(); } - else if (valid_base_operation(current_token().value)) + else if (valid_base_operation(symbol)) { return parse_base_operation(); } else if ( - details::imatch(current_token().value, symbol_if) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_if) && + settings_.control_struct_enabled(symbol) ) { return parse_conditional_statement(); } else if ( - details::imatch(current_token().value, symbol_while) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_while) && + settings_.control_struct_enabled(symbol) ) { return parse_while_loop(); } else if ( - details::imatch(current_token().value, symbol_repeat) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_repeat) && + settings_.control_struct_enabled(symbol) ) { return parse_repeat_until_loop(); } else if ( - details::imatch(current_token().value, symbol_for) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_for) && + settings_.control_struct_enabled(symbol) ) { return parse_for_loop(); } else if ( - details::imatch(current_token().value, symbol_switch) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_switch) && + settings_.control_struct_enabled(symbol) ) { return parse_switch_statement(); } - else if (details::is_valid_sf_symbol(current_token().value)) + else if (details::is_valid_sf_symbol(symbol)) { return parse_special_function(); } - else if (details::imatch(current_token().value, symbol_null)) + else if (details::imatch(symbol, symbol_null)) { return parse_null_statement(); } #ifndef exprtk_disable_break_continue - else if (details::imatch(current_token().value, symbol_break)) + else if (details::imatch(symbol, symbol_break)) { return parse_break_statement(); } - else if (details::imatch(current_token().value, symbol_continue)) + else if (details::imatch(symbol, symbol_continue)) { return parse_continue_statement(); } #endif - else if (details::imatch(current_token().value, symbol_var)) + else if (details::imatch(symbol, symbol_var)) { return parse_define_var_statement(); } - else if (details::imatch(current_token().value, symbol_swap)) + else if (details::imatch(symbol, symbol_swap)) { return parse_swap_statement(); } #ifndef exprtk_disable_return_statement else if ( - details::imatch(current_token().value, symbol_return) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_return) && + settings_.control_struct_enabled(symbol) ) { return parse_return_statement(); @@ -26971,7 +27155,7 @@ namespace exprtk set_error( make_error(parser_error::e_symtab, current_token(), - "ERR202 - Variable or function detected, yet symbol-table is invalid, Symbol: " + current_token().value, + "ERR202 - Variable or function detected, yet symbol-table is invalid, Symbol: " + symbol, exprtk_error_location)); return error_node(); @@ -27046,13 +27230,13 @@ namespace exprtk "ERR205 - Expected ')' instead of: '" + current_token().value + "'", exprtk_error_location)); - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } else if (!post_bracket_process(token_t::e_lbracket,branch)) { - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } @@ -27071,13 +27255,13 @@ namespace exprtk "ERR206 - Expected ']' instead of: '" + current_token().value + "'", exprtk_error_location)); - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } else if (!post_bracket_process(token_t::e_lsqrbracket,branch)) { - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } @@ -27096,13 +27280,13 @@ namespace exprtk "ERR207 - Expected '}' instead of: '" + current_token().value + "'", exprtk_error_location)); - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } else if (!post_bracket_process(token_t::e_lcrlbracket,branch)) { - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } @@ -27124,7 +27308,7 @@ namespace exprtk if (0 == result) { - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } @@ -28055,9 +28239,9 @@ namespace exprtk { if ((0 == condition) || (0 == consequent)) { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, consequent ); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent ); + details::free_node(*node_allocator_, alternative); return error_node(); } @@ -28067,16 +28251,16 @@ namespace exprtk // True branch if (details::is_true(condition)) { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, alternative); return consequent; } // False branch else { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, consequent); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent); if (alternative) return alternative; @@ -28101,9 +28285,9 @@ namespace exprtk { if ((0 == condition) || (0 == consequent)) { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, consequent ); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent ); + details::free_node(*node_allocator_, alternative); return error_node(); } @@ -28113,16 +28297,16 @@ namespace exprtk // True branch if (details::is_true(condition)) { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, alternative); return consequent; } // False branch else { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, consequent); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent); if (alternative) return alternative; @@ -28152,9 +28336,9 @@ namespace exprtk { if ((0 == condition) || (0 == consequent)) { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, consequent ); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent ); + details::free_node(*node_allocator_, alternative); return error_node(); } @@ -28164,16 +28348,16 @@ namespace exprtk // True branch if (details::is_true(condition)) { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, alternative); return consequent; } // False branch else { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, consequent); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent); if (alternative) return alternative; @@ -28206,9 +28390,9 @@ namespace exprtk inline expression_node_ptr while_loop(expression_node_ptr& condition, expression_node_ptr& branch, - const bool brkcont = false) const + const bool break_continue_present = false) const { - if (!brkcont && details::is_constant_node(condition)) + if (!break_continue_present && details::is_constant_node(condition)) { expression_node_ptr result = error_node(); if (details::is_true(condition)) @@ -28217,32 +28401,39 @@ namespace exprtk else result = node_allocator_->allocate >(); - free_node(*node_allocator_, condition); - free_node(*node_allocator_, branch ); + details::free_node(*node_allocator_, condition); + details::free_node(*node_allocator_, branch ); return result; } else if (details::is_null_node(condition)) { - free_node(*node_allocator_,condition); + details::free_node(*node_allocator_,condition); return branch; } - else if (!brkcont) - return node_allocator_->allocate - ( - condition, - branch, - get_loop_runtime_check(loop_runtime_check::e_while_loop) - ); + + loop_runtime_check_ptr rtc = get_loop_runtime_check(loop_runtime_check::e_while_loop); + + if (!break_continue_present) + { + if (rtc) + return node_allocator_->allocate + (condition, branch, rtc); + else + return node_allocator_->allocate + (condition, branch); + } #ifndef exprtk_disable_break_continue else - return node_allocator_->allocate - ( - condition, - branch, - get_loop_runtime_check(loop_runtime_check::e_while_loop) - ); + { + if (rtc) + return node_allocator_->allocate + (condition, branch, rtc); + else + return node_allocator_->allocate + (condition, branch); + } #else return error_node(); #endif @@ -28250,9 +28441,9 @@ namespace exprtk inline expression_node_ptr repeat_until_loop(expression_node_ptr& condition, expression_node_ptr& branch, - const bool brkcont = false) const + const bool break_continue_present = false) const { - if (!brkcont && details::is_constant_node(condition)) + if (!break_continue_present && details::is_constant_node(condition)) { if ( details::is_true(condition) && @@ -28264,32 +28455,39 @@ namespace exprtk return branch; } - free_node(*node_allocator_, condition); - free_node(*node_allocator_, branch ); + details::free_node(*node_allocator_, condition); + details::free_node(*node_allocator_, branch ); return error_node(); } else if (details::is_null_node(condition)) { - free_node(*node_allocator_,condition); + details::free_node(*node_allocator_,condition); return branch; } - else if (!brkcont) - return node_allocator_->allocate - ( - condition, - branch, - get_loop_runtime_check(loop_runtime_check::e_repeat_until_loop) - ); + + loop_runtime_check_ptr rtc = get_loop_runtime_check(loop_runtime_check::e_repeat_until_loop); + + if (!break_continue_present) + { + if (rtc) + return node_allocator_->allocate + (condition, branch, rtc); + else + return node_allocator_->allocate + (condition, branch); + } #ifndef exprtk_disable_break_continue else - return node_allocator_->allocate - ( - condition, - branch, - get_loop_runtime_check(loop_runtime_check::e_repeat_until_loop) - ); + { + if (rtc) + return node_allocator_->allocate + (condition, branch, rtc); + else + return node_allocator_->allocate + (condition, branch); + } #else return error_node(); #endif @@ -28299,9 +28497,9 @@ namespace exprtk expression_node_ptr& condition, expression_node_ptr& incrementor, expression_node_ptr& loop_body, - bool brkcont = false) const + bool break_continue_present = false) const { - if (!brkcont && details::is_constant_node(condition)) + if (!break_continue_present && details::is_constant_node(condition)) { expression_node_ptr result = error_node(); @@ -28311,43 +28509,67 @@ namespace exprtk else result = node_allocator_->allocate >(); - free_node(*node_allocator_, initialiser); - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, incrementor); - free_node(*node_allocator_, loop_body ); + details::free_node(*node_allocator_, initialiser); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, incrementor); + details::free_node(*node_allocator_, loop_body ); return result; } else if (details::is_null_node(condition) || (0 == condition)) { - free_node(*node_allocator_, initialiser); - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, incrementor); + details::free_node(*node_allocator_, initialiser); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, incrementor); return loop_body; } - else if (!brkcont) - return node_allocator_->allocate - ( - initialiser, - condition, - incrementor, - loop_body, - get_loop_runtime_check(loop_runtime_check::e_for_loop) - ); + loop_runtime_check_ptr rtc = get_loop_runtime_check(loop_runtime_check::e_for_loop); + + if (!break_continue_present) + { + if (rtc) + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body, + rtc + ); + else + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body + ); + } #ifndef exprtk_disable_break_continue else - return node_allocator_->allocate - ( - initialiser, - condition, - incrementor, - loop_body, - get_loop_runtime_check(loop_runtime_check::e_for_loop) - ); + { + if (rtc) + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body, + rtc + ); + else + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body + ); + } #else - return error_node(); + return error_node(); #endif } @@ -28416,7 +28638,7 @@ namespace exprtk if (current_expr && (current_expr != result)) { - free_node(*node_allocator_,current_expr); + details::free_node(*node_allocator_,current_expr); } } @@ -28630,7 +28852,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(v); \ @@ -28645,7 +28867,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > > \ (operation, branch[0]); \ @@ -28661,7 +28883,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(branch[0]); \ @@ -28885,7 +29107,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : temp_node = node_allocator_-> \ allocate > > \ (arg_list); \ @@ -28927,7 +29149,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(arg_list); \ @@ -28952,7 +29174,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(arg_list[0]); \ @@ -28999,7 +29221,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(arg_list); \ @@ -29228,8 +29450,8 @@ namespace exprtk } else { - details::free_node (*node_allocator_,result ); - details::free_all_nodes(*node_allocator_,arg_list); + details::free_node (*node_allocator_, result ); + details::free_all_nodes(*node_allocator_, arg_list); return error_node(); } @@ -29449,7 +29671,7 @@ namespace exprtk if (details::is_ivector_node(branch[1])) return synthesize_expression(operation, branch); - else + else return synthesize_expression(operation, branch); } else @@ -29469,7 +29691,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29489,7 +29711,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29509,7 +29731,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29529,7 +29751,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29551,7 +29773,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29569,7 +29791,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29630,7 +29852,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29644,7 +29866,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29658,7 +29880,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29691,7 +29913,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29706,7 +29928,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29721,7 +29943,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29831,8 +30053,8 @@ namespace exprtk if (result) { - free_node(*node_allocator_, branch[0]); - free_node(*node_allocator_, branch[1]); + details::free_node(*node_allocator_, branch[0]); + details::free_node(*node_allocator_, branch[1]); return result; } @@ -30105,7 +30327,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate > > \ (branch[0], branch[1]); \ @@ -30137,7 +30359,7 @@ namespace exprtk if (synthesis_result) { - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); return result; } } @@ -30158,7 +30380,7 @@ namespace exprtk { const Type& v1 = static_cast(branch[1])->v(); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); switch (operation) { @@ -30180,7 +30402,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_rc > > \ (v, branch[1]); \ @@ -30212,7 +30434,7 @@ namespace exprtk if (synthesis_result) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return result; } @@ -30236,7 +30458,7 @@ namespace exprtk { const Type& v0 = static_cast(branch[0])->v(); - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); switch (operation) { @@ -30266,7 +30488,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_cr > > \ (branch[0], v); \ @@ -30287,17 +30509,17 @@ namespace exprtk { const Type c = static_cast*>(branch[0])->value(); - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } @@ -30378,7 +30600,7 @@ namespace exprtk default : return error_node(); } - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); return new_cobnode; } @@ -30395,7 +30617,7 @@ namespace exprtk if (synthesis_result) { - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); return result; } @@ -30404,7 +30626,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_tt > > \ (c, branch[1]); \ @@ -30429,13 +30651,13 @@ namespace exprtk if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return expr_gen(std::numeric_limits::quiet_NaN()); } @@ -30523,7 +30745,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_cr > > \ (branch[0], c); \ @@ -30553,33 +30775,33 @@ namespace exprtk if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(std::numeric_limits::quiet_NaN())); } else if (std::equal_to()(T(0),c) && (details::e_add == operation)) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return branch[0]; } else if (std::equal_to()(T(1),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return branch[0]; } else if (std::equal_to()(T(1),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return branch[0]; } @@ -30622,13 +30844,13 @@ namespace exprtk template allocate_tt > > (cobnode->c() / c, cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); } } if (result) { - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } @@ -30641,27 +30863,27 @@ namespace exprtk if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_add == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return branch[1]; } else if (std::equal_to()(T(1),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return branch[1]; } @@ -30679,7 +30901,7 @@ namespace exprtk template allocate_tt > > (c - cobnode->c(), cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_sub == cobnode->operation()) @@ -30695,7 +30917,7 @@ namespace exprtk template allocate_tt > > (c - cobnode->c(), cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_mul == cobnode->operation()) @@ -30711,7 +30933,7 @@ namespace exprtk template allocate_tt > > (c / cobnode->c(), cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_div == cobnode->operation()) @@ -30727,13 +30949,13 @@ namespace exprtk template allocate_tt > > (c / cobnode->c(), cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } if (result) { - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); } } @@ -30786,7 +31008,7 @@ namespace exprtk template allocate_tt > > (bocnode->move_branch(0), c - bocnode->c()); - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); } else if (details::e_sub == operation) { @@ -30808,7 +31030,7 @@ namespace exprtk if (result) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); } } @@ -30832,7 +31054,7 @@ namespace exprtk template allocate_tt > > (c - bocnode->c(), bocnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_sub == bocnode->operation()) @@ -30843,7 +31065,7 @@ namespace exprtk template allocate_tt > > (bocnode->move_branch(0), c - bocnode->c()); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } else if (details::e_sub == operation) { @@ -30851,7 +31073,7 @@ namespace exprtk template allocate_tt > > (c + bocnode->c(), bocnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_mul == bocnode->operation()) @@ -30867,7 +31089,7 @@ namespace exprtk template allocate_tt > > (c / bocnode->c(), bocnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_div == bocnode->operation()) @@ -30883,13 +31105,13 @@ namespace exprtk template allocate_tt > > (c * bocnode->c(), bocnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } if (result) { - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); } } @@ -30932,7 +31154,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_rr > > \ (v1, v2); \ @@ -30967,7 +31189,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_cr > > \ (c, v); \ @@ -31011,7 +31233,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_rc > > \ (v, c); \ @@ -31080,7 +31302,6 @@ namespace exprtk case details::e_sf##op : return details::T0oT1oT2oT3_sf4ext >:: \ allocate(*(expr_gen.node_allocator_), t0, t1, t2, t3); \ - #define case_stmt1(op) \ case details::e_sf4ext##op : return details::T0oT1oT2oT3_sf4ext >:: \ allocate(*(expr_gen.node_allocator_), t0, t1, t2, t3); \ @@ -32027,7 +32248,9 @@ namespace exprtk struct synthesize_cocov_expression0 { typedef typename cocov_t::type0 node_type; - static inline expression_node_ptr process(expression_generator&, const details::operator_type&, expression_node_ptr (&)[2]) + static inline expression_node_ptr process(expression_generator&, + const details::operator_type&, + expression_node_ptr (&)[2]) { // (c0 o0 c1) o1 (v) - Not possible. return error_node(); @@ -32284,7 +32507,9 @@ namespace exprtk { typedef typename vococ_t::type0 node_type; - static inline expression_node_ptr process(expression_generator&, const details::operator_type&, expression_node_ptr (&)[2]) + static inline expression_node_ptr process(expression_generator&, + const details::operator_type&, + expression_node_ptr (&)[2]) { // (v) o0 (c0 o1 c1) - Not possible. exprtk_debug(("(v) o0 (c0 o1 c1) - Not possible.\n")); @@ -33360,7 +33585,7 @@ namespace exprtk const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,specfunc, c0, v0, v1, result); + template compile(expr_gen, specfunc, c0, v0, v1, result); exprtk_debug(("(c * v0) +/- (v1 * c) --> (covov) c * (v0 +/- v1)\n")); @@ -34623,7 +34848,9 @@ namespace exprtk struct synthesize_vococov_expression2 { typedef typename vococov_t::type2 node_type; - static inline expression_node_ptr process(expression_generator&, const details::operator_type&, expression_node_ptr (&)[2]) + static inline expression_node_ptr process(expression_generator&, + const details::operator_type&, + expression_node_ptr (&)[2]) { // v0 o0 ((c0 o1 c1) o2 v1) - Not possible exprtk_debug(("v0 o0 ((c0 o1 c1) o2 v1) - Not possible\n")); @@ -34631,7 +34858,9 @@ namespace exprtk } static inline std::string id(expression_generator&, - const details::operator_type, const details::operator_type, const details::operator_type) + const details::operator_type, + const details::operator_type, + const details::operator_type) { return "INVALID"; } @@ -35665,7 +35894,9 @@ namespace exprtk struct synthesize_vococov_expression4 { typedef typename vococov_t::type4 node_type; - static inline expression_node_ptr process(expression_generator&, const details::operator_type&, expression_node_ptr (&)[2]) + static inline expression_node_ptr process(expression_generator&, + const details::operator_type&, + expression_node_ptr (&)[2]) { // ((v0 o0 (c0 o1 c1)) o2 v1) - Not possible exprtk_debug(("((v0 o0 (c0 o1 c1)) o2 v1) - Not possible\n")); @@ -35673,7 +35904,9 @@ namespace exprtk } static inline std::string id(expression_generator&, - const details::operator_type, const details::operator_type, const details::operator_type) + const details::operator_type, + const details::operator_type, + const details::operator_type) { return "INVALID"; } @@ -35774,7 +36007,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_ttt >,T0,T1> \ (s0, s1, rp0); \ @@ -35792,7 +36025,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_ttt >,T0,T1> \ (s0, s1, rp1); \ @@ -35810,7 +36043,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_tttt >,T0,T1> \ (s0, s1, rp0, rp1); \ @@ -35826,7 +36059,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_tt >,T0,T1>(s0, s1); \ @@ -35852,7 +36085,7 @@ namespace exprtk static_cast*>(branch[0])->range_ref().clear(); - free_node(*node_allocator_,branch[0]); + details::free_node(*node_allocator_,branch[0]); return synthesize_str_xrox_expression_impl(opr, s0, s1, rp0); } @@ -35865,7 +36098,7 @@ namespace exprtk static_cast*>(branch[1])->range_ref().clear(); - free_node(*node_allocator_,branch[1]); + details::free_node(*node_allocator_,branch[1]); return synthesize_str_xoxr_expression_impl(opr, s0, s1, rp1); } @@ -35878,7 +36111,7 @@ namespace exprtk static_cast*>(branch[1])->range_ref().clear(); - free_node(*node_allocator_,branch[1]); + details::free_node(*node_allocator_,branch[1]); return synthesize_str_xoxr_expression_impl(opr, s0, s1, rp1); } @@ -35935,9 +36168,9 @@ namespace exprtk inline expression_node_ptr synthesize_srocs_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { - std::string& s0 = static_cast*> (branch[0])->ref (); + std::string& s0 = static_cast* >(branch[0])->ref (); std::string s1 = static_cast*>(branch[1])->str (); - range_t rp0 = static_cast*> (branch[0])->range(); + range_t rp0 = static_cast* >(branch[0])->range(); static_cast*>(branch[0])->range_ref().clear(); @@ -35949,9 +36182,9 @@ namespace exprtk inline expression_node_ptr synthesize_srocsr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { - std::string& s0 = static_cast*> (branch[0])->ref (); + std::string& s0 = static_cast* >(branch[0])->ref (); std::string s1 = static_cast*>(branch[1])->str (); - range_t rp0 = static_cast*> (branch[0])->range(); + range_t rp0 = static_cast* >(branch[0])->range(); range_t rp1 = static_cast*>(branch[1])->range(); static_cast*> (branch[0])->range_ref().clear(); @@ -35996,14 +36229,14 @@ namespace exprtk inline expression_node_ptr synthesize_csocsr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { - const std::string s0 = static_cast*> (branch[0])->str (); + const std::string s0 = static_cast* >(branch[0])->str (); std::string s1 = static_cast*>(branch[1])->str (); range_t rp1 = static_cast*>(branch[1])->range(); static_cast*>(branch[1])->range_ref().clear(); - free_node(*node_allocator_,branch[0]); - free_node(*node_allocator_,branch[1]); + details::free_node(*node_allocator_,branch[0]); + details::free_node(*node_allocator_,branch[1]); return synthesize_str_xoxr_expression_impl(opr, s0, s1, rp1); } @@ -36011,12 +36244,12 @@ namespace exprtk inline expression_node_ptr synthesize_csros_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { std::string s0 = static_cast*>(branch[0])->str (); - std::string& s1 = static_cast*> (branch[1])->ref (); + std::string& s1 = static_cast* >(branch[1])->ref (); range_t rp0 = static_cast*>(branch[0])->range(); static_cast*>(branch[0])->range_ref().clear(); - free_node(*node_allocator_,branch[0]); + details::free_node(*node_allocator_,branch[0]); return synthesize_str_xrox_expression_impl(opr, s0, s1, rp0); } @@ -36024,15 +36257,15 @@ namespace exprtk inline expression_node_ptr synthesize_csrosr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { const std::string s0 = static_cast*>(branch[0])->str (); - std::string& s1 = static_cast*> (branch[1])->ref (); + std::string& s1 = static_cast* >(branch[1])->ref (); const range_t rp0 = static_cast*>(branch[0])->range(); - const range_t rp1 = static_cast*> (branch[1])->range(); + const range_t rp1 = static_cast* >(branch[1])->range(); static_cast*>(branch[0])->range_ref().clear(); static_cast*> (branch[1])->range_ref().clear(); - free_node(*node_allocator_,branch[0]); - free_node(*node_allocator_,branch[1]); + details::free_node(*node_allocator_,branch[0]); + details::free_node(*node_allocator_,branch[1]); return synthesize_str_xroxr_expression_impl(opr, s0, s1, rp0, rp1); } @@ -36040,7 +36273,7 @@ namespace exprtk inline expression_node_ptr synthesize_csrocs_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { const std::string s0 = static_cast*>(branch[0])->str (); - const std::string s1 = static_cast*> (branch[1])->str (); + const std::string s1 = static_cast* >(branch[1])->str (); const range_t rp0 = static_cast*>(branch[0])->range(); static_cast*>(branch[0])->range_ref().clear(); @@ -36069,7 +36302,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_ttt > > \ (opr, branch[0], branch[1]); \ @@ -36131,28 +36364,28 @@ namespace exprtk } else if (b0_is_s) { - if (b1_is_s ) return synthesize_sos_expression (opr,branch); + if (b1_is_s ) return synthesize_sos_expression (opr,branch); else if (b1_is_cs ) return synthesize_socs_expression (opr,branch); else if (b1_is_sr ) return synthesize_sosr_expression (opr,branch); else if (b1_is_csr) return synthesize_socsr_expression (opr,branch); } else if (b0_is_cs) { - if (b1_is_s ) return synthesize_csos_expression (opr,branch); + if (b1_is_s ) return synthesize_csos_expression (opr,branch); else if (b1_is_cs ) return synthesize_csocs_expression (opr,branch); else if (b1_is_sr ) return synthesize_csosr_expression (opr,branch); else if (b1_is_csr) return synthesize_csocsr_expression(opr,branch); } else if (b0_is_sr) { - if (b1_is_s ) return synthesize_sros_expression (opr,branch); + if (b1_is_s ) return synthesize_sros_expression (opr,branch); else if (b1_is_sr ) return synthesize_srosr_expression (opr,branch); else if (b1_is_cs ) return synthesize_srocs_expression (opr,branch); else if (b1_is_csr) return synthesize_srocsr_expression(opr,branch); } else if (b0_is_csr) { - if (b1_is_s ) return synthesize_csros_expression (opr,branch); + if (b1_is_s ) return synthesize_csros_expression (opr,branch); else if (b1_is_sr ) return synthesize_csrosr_expression (opr,branch); else if (b1_is_cs ) return synthesize_csrocs_expression (opr,branch); else if (b1_is_csr) return synthesize_csrocsr_expression(opr,branch); @@ -36232,9 +36465,9 @@ namespace exprtk details::is_string_node(branch[2]) ) { - std::string& s0 = static_cast< details::stringvar_node*>(branch[0])->ref(); + std::string& s0 = static_cast* >(branch[0])->ref(); std::string s1 = static_cast*>(branch[1])->str(); - std::string& s2 = static_cast< details::stringvar_node*>(branch[2])->ref(); + std::string& s2 = static_cast* >(branch[2])->ref(); typedef typename details::sosos_node > inrange_t; @@ -36248,8 +36481,8 @@ namespace exprtk details::is_const_string_node(branch[2]) ) { - std::string& s0 = static_cast< details::stringvar_node*>(branch[0])->ref(); - std::string& s1 = static_cast< details::stringvar_node*>(branch[1])->ref(); + std::string& s0 = static_cast* >(branch[0])->ref(); + std::string& s1 = static_cast* >(branch[1])->ref(); std::string s2 = static_cast*>(branch[2])->str(); typedef typename details::sosos_node > inrange_t; @@ -36467,7 +36700,7 @@ namespace exprtk sf3_map_t* sf3_map_; sf4_map_t* sf4_map_; parser_t* parser_; - }; + }; // class expression_generator inline void set_error(const parser_error::type& error_type) { @@ -36557,7 +36790,7 @@ namespace exprtk inline void load_unary_operations_map(unary_op_map_t& m) { - #define register_unary_op(Op,UnaryFunctor) \ + #define register_unary_op(Op, UnaryFunctor) \ m.insert(std::make_pair(Op,UnaryFunctor::process)); \ register_unary_op(details::e_abs , details::abs_op ) @@ -36606,7 +36839,7 @@ namespace exprtk { typedef typename binary_op_map_t::value_type value_type; - #define register_binary_op(Op,BinaryFunctor) \ + #define register_binary_op(Op, BinaryFunctor) \ m.insert(value_type(Op,BinaryFunctor::process)); \ register_binary_op(details::e_add , details::add_op ) @@ -36634,7 +36867,7 @@ namespace exprtk { typedef typename inv_binary_op_map_t::value_type value_type; - #define register_binary_op(Op,BinaryFunctor) \ + #define register_binary_op(Op, BinaryFunctor) \ m.insert(value_type(BinaryFunctor::process,Op)); \ register_binary_op(details::e_add , details::add_op ) @@ -36747,8 +36980,8 @@ namespace exprtk private: - parser(const parser&); - parser& operator=(const parser&); + parser(const parser&) exprtk_delete; + parser& operator=(const parser&) exprtk_delete; settings_store settings_; expression_generator expression_generator_; @@ -36778,7 +37011,7 @@ namespace exprtk lexer::helper::operator_joiner operator_joiner_3_; lexer::helper::symbol_replacer symbol_replacer_; lexer::helper::bracket_checker bracket_checker_; - lexer::helper::numeric_checker numeric_checker_; + lexer::helper::numeric_checker numeric_checker_; lexer::helper::sequence_validator sequence_validator_; lexer::helper::sequence_validator_3tokens sequence_validator_3tkns_; @@ -36786,7 +37019,7 @@ namespace exprtk template friend void details::disable_type_checking(ParserType& p); - }; + }; // class parser namespace details { @@ -36794,8 +37027,8 @@ namespace exprtk struct collector_helper { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; typedef typename parser_t::dependent_entity_collector::symbol_t symbol_t; typedef typename parser_t::unknown_symbol_resolver usr_t; @@ -37459,8 +37692,7 @@ namespace exprtk disable_has_side_effects(*this); } - virtual ~polynomial() - {} + virtual ~polynomial() {} #define poly_rtrn(NN) \ return (NN != N) ? std::numeric_limits::quiet_NaN() : @@ -37480,47 +37712,60 @@ namespace exprtk poly_rtrn(3) (poly_impl::evaluate(x, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c4, const T& c3, const T& c2, const T& c1, + const T& c0) { poly_rtrn(4) (poly_impl::evaluate(x, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c5, const T& c4, const T& c3, const T& c2, + const T& c1, const T& c0) { poly_rtrn(5) (poly_impl::evaluate(x, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c6, const T& c5, const T& c4, const T& c3, + const T& c2, const T& c1, const T& c0) { poly_rtrn(6) (poly_impl::evaluate(x, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c7, const T& c6, const T& c5, const T& c4, + const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(7) (poly_impl::evaluate(x, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c8, const T& c7, const T& c6, const T& c5, + const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(8) (poly_impl::evaluate(x, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c9, const T& c8, const T& c7, const T& c6, + const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, + const T& c0) { poly_rtrn(9) (poly_impl::evaluate(x, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c10, const T& c9, const T& c8, const T& c7, + const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, + const T& c1, const T& c0) { poly_rtrn(10) (poly_impl::evaluate(x, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c11, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c11, const T& c10, const T& c9, const T& c8, + const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, + const T& c2, const T& c1, const T& c0) { poly_rtrn(11) (poly_impl::evaluate(x, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c12, const T& c11, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c12, const T& c11, const T& c10, const T& c9, + const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, + const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(12) (poly_impl::evaluate(x, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } @@ -37665,45 +37910,51 @@ namespace exprtk v.resize(pc); } - virtual ~base_func() - {} + virtual ~base_func() {} + + #define exprtk_assign(Index) \ + (*v[Index]) = v##Index; \ inline void update(const T& v0) { - (*v[0]) = v0; + exprtk_assign(0) } inline void update(const T& v0, const T& v1) { - (*v[0]) = v0; (*v[1]) = v1; + exprtk_assign(0) exprtk_assign(1) } inline void update(const T& v0, const T& v1, const T& v2) { - (*v[0]) = v0; (*v[1]) = v1; - (*v[2]) = v2; + exprtk_assign(0) exprtk_assign(1) + exprtk_assign(2) } inline void update(const T& v0, const T& v1, const T& v2, const T& v3) { - (*v[0]) = v0; (*v[1]) = v1; - (*v[2]) = v2; (*v[3]) = v3; + exprtk_assign(0) exprtk_assign(1) + exprtk_assign(2) exprtk_assign(3) } inline void update(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4) { - (*v[0]) = v0; (*v[1]) = v1; - (*v[2]) = v2; (*v[3]) = v3; - (*v[4]) = v4; + exprtk_assign(0) exprtk_assign(1) + exprtk_assign(2) exprtk_assign(3) + exprtk_assign(4) } inline void update(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) { - (*v[0]) = v0; (*v[1]) = v1; - (*v[2]) = v2; (*v[3]) = v3; - (*v[4]) = v4; (*v[5]) = v5; + exprtk_assign(0) exprtk_assign(1) + exprtk_assign(2) exprtk_assign(3) + exprtk_assign(4) exprtk_assign(5) } + #ifdef exprtk_assign + #undef exprtk_assign + #endif + inline function_t& setup(expression_t& expr) { expression = expr; @@ -37894,8 +38145,8 @@ namespace exprtk private: - scoped_bft(scoped_bft&); - scoped_bft& operator=(scoped_bft&); + scoped_bft(const scoped_bft&) exprtk_delete; + scoped_bft& operator=(const scoped_bft&) exprtk_delete; }; struct func_1param : public base_func @@ -38297,7 +38548,7 @@ namespace exprtk std::map expr_map_; std::vector fp_map_; std::vector auxiliary_symtab_list_; - }; + }; // class function_compositor template inline bool pgo_primer() @@ -38742,7 +38993,7 @@ namespace exprtk bool register_package(exprtk::symbol_table& symtab) { - #define exprtk_register_function(FunctionName,FunctionType) \ + #define exprtk_register_function(FunctionName, FunctionType) \ if (!symtab.add_function(FunctionName,FunctionType)) \ { \ exprtk_debug(( \ @@ -38965,11 +39216,13 @@ namespace exprtk template file_descriptor* make_handle(T v) { - file_descriptor* fd = reinterpret_cast(0); + details::file_descriptor* fd = reinterpret_cast(0); + + const std::size_t fd_size = sizeof(details::file_descriptor*); std::memcpy(reinterpret_cast(&fd), reinterpret_cast(&v), - sizeof(fd)); + fd_size); return fd; } @@ -39028,9 +39281,11 @@ namespace exprtk { T t = T(0); + const std::size_t fd_size = sizeof(details::file_descriptor*); + std::memcpy(reinterpret_cast(&t ), reinterpret_cast(&fd), - sizeof(fd)); + fd_size); return t; } else @@ -39231,7 +39486,7 @@ namespace exprtk bool register_package(exprtk::symbol_table& symtab) { - #define exprtk_register_function(FunctionName,FunctionType) \ + #define exprtk_register_function(FunctionName, FunctionType) \ if (!symtab.add_function(FunctionName,FunctionType)) \ { \ exprtk_debug(( \ @@ -40392,7 +40647,7 @@ namespace exprtk bool register_package(exprtk::symbol_table& symtab) { - #define exprtk_register_function(FunctionName,FunctionType) \ + #define exprtk_register_function(FunctionName, FunctionType) \ if (!symtab.add_function(FunctionName,FunctionType)) \ { \ exprtk_debug(( \ @@ -40440,11 +40695,11 @@ namespace exprtk namespace information { static const char* library = "Mathematical Expression Toolkit"; - static const char* version = "2.718281828459045235360287471352" - "66249775724709369995957496696762" - "77240766303535475945713821785251" - "66427427466391932003059921817413"; - static const char* date = "20210101"; + static const char* version = "2.7182818284590452353602874713526" + "624977572470936999595749669676277" + "240766303535475945713821785251664" + "274274663919320030599218174135966"; + static const char* date = "20220101"; static inline std::string data() { @@ -40480,6 +40735,10 @@ namespace exprtk #undef exprtk_final #endif + #ifdef exprtk_delete + #undef exprtk_delete + #endif + } // namespace exprtk #endif diff --git a/casbin/model/evaluator.cpp b/casbin/model/evaluator.cpp index b2b7ae97..bf7d5e8e 100644 --- a/casbin/model/evaluator.cpp +++ b/casbin/model/evaluator.cpp @@ -13,11 +13,90 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include "evaluator.h" #include "../util/util.h" namespace casbin { + bool ExprtkEvaluator::Eval(const std::string& expression_string) { + expression.register_symbol_table(symbol_table); + // replace (&& -> and), (|| -> or) + auto replaced_string = std::regex_replace(expression_string, std::regex("&&"), "and"); + replaced_string = std::regex_replace(replaced_string, std::regex("\\|{2}"), "or"); + // replace string "" -> '' + replaced_string = std::regex_replace(replaced_string, std::regex("\""), "\'"); + + return parser.compile(replaced_string, expression); + } + + void ExprtkEvaluator::InitialObject(std::string identifier) { + // symbol_table.add_stringvar(""); + } + + void ExprtkEvaluator::PushObjectString(std::string target, std::string proprity, const std::string& var) { + auto identifier = target + "." + proprity; + this->symbol_table.add_stringvar(identifier, const_cast(var)); + } + + void ExprtkEvaluator::PushObjectJson(std::string target, std::string proprity, const nlohmann::json& var) { + auto identifier = target + "." + proprity; + // this->symbol_table.add_stringvar(identifier, const_cast(var)); + } + + void ExprtkEvaluator::LoadFunctions() { + + } + + void ExprtkEvaluator::LoadGFunction(std::shared_ptr rm, const std::string& name, int narg) { + + } + + void ExprtkEvaluator::ProcessFunctions(const std::string& expression) { + + } + + Type ExprtkEvaluator::CheckType() { + if (expression.value() == float(0) || expression.value() == float(1)) { + return Type::Bool; + } else { + return Type::Float; + } + } + + bool ExprtkEvaluator::GetBoolen() { + return expression.value(); + } + + float ExprtkEvaluator::GetFloat() { + return expression.value(); + } + + void ExprtkEvaluator::Clean(AssertionMap& section) { + for (auto& [assertion_name, assertion]: section.assertion_map) { + std::vector raw_tokens = assertion->tokens; + + for(int j = 0 ; j < raw_tokens.size() ; j++) { + size_t index = raw_tokens[j].find("_"); + std::string token = raw_tokens[j].substr(index + 1); + auto identifier = assertion_name + "." + token; + if (symbol_table.get_stringvar(identifier) != nullptr) { + symbol_table.remove_stringvar(identifier); + } + } + } + } + + void ExprtkEvaluator::PrintSymbol() { + std::vector var_list; + symbol_table.get_stringvar_list(var_list); + + printf("Current symboltable: \n"); + for (auto& var: var_list) { + printf(" %s: %s\n" , var.c_str(), symbol_table.get_stringvar(var)->ref().c_str()); + } + } + bool DuktapeEvaluator::Eval(const std::string& expression) { return casbin::Eval(scope, expression); } @@ -54,7 +133,7 @@ namespace casbin { PushFunction(scope, f, func_name, nargs); } - void DuktapeEvaluator::ProcessFunctions(const std::string& expression){ + void DuktapeEvaluator::ProcessFunctions(const std::string& expression) { for(const std::string& func: func_list) { size_t index = expression.find(func+"("); diff --git a/casbin/model/evaluator.h b/casbin/model/evaluator.h index 85973873..d8b2c671 100644 --- a/casbin/model/evaluator.h +++ b/casbin/model/evaluator.h @@ -86,6 +86,8 @@ namespace casbin { float GetFloat(); void Clean(AssertionMap& section); + + void PrintSymbol(); }; class DuktapeEvaluator : public IEvaluator { diff --git a/examples/basic_with_root_model.conf b/examples/basic_with_root_model.conf index d3ec95b5..8f13907e 100644 --- a/examples/basic_with_root_model.conf +++ b/examples/basic_with_root_model.conf @@ -8,4 +8,4 @@ p = sub, obj, act e = some(where (p.eft == allow)) [matchers] -m = r.sub == "root" || r.sub == p.sub && r.obj == p.obj && r.act == p.act \ No newline at end of file +m = r.sub == p.sub && r.obj == p.obj && r.act == p.act || r.sub == "root" \ No newline at end of file diff --git a/include/casbin/casbin_helpers.h b/include/casbin/casbin_helpers.h index 89ab520b..86435b83 100644 --- a/include/casbin/casbin_helpers.h +++ b/include/casbin/casbin_helpers.h @@ -838,6 +838,8 @@ namespace casbin { float GetFloat(); void Clean(AssertionMap& section); + + void PrintSymbol(); }; class DuktapeEvaluator : public IEvaluator { diff --git a/include/casbin/exprtk/exprtk.hpp b/include/casbin/exprtk/exprtk.hpp index 4ce08486..b362bd2c 100644 --- a/include/casbin/exprtk/exprtk.hpp +++ b/include/casbin/exprtk/exprtk.hpp @@ -2,14 +2,14 @@ ****************************************************************** * C++ Mathematical Expression Toolkit Library * * * - * Author: Arash Partow (1999-2021) * - * URL: http://www.partow.net/programming/exprtk/index.html * + * Author: Arash Partow (1999-2022) * + * URL: https://www.partow.net/programming/exprtk/index.html * * * * Copyright notice: * * Free use of the C++ Mathematical Expression Toolkit Library is * * permitted under the guidelines and in accordance with the most * * current version of the MIT License. * - * http://www.opensource.org/licenses/MIT * + * https://www.opensource.org/licenses/MIT * * * * Example expressions: * * (00) (y + x / y) * (x - y / x) * @@ -85,9 +85,11 @@ namespace exprtk #if __cplusplus >= 201103L #define exprtk_override override #define exprtk_final final + #define exprtk_delete = delete #else #define exprtk_override #define exprtk_final + #define exprtk_delete #endif namespace details @@ -282,25 +284,21 @@ namespace exprtk std::string result; - if (i < 0) - { - for ( ; i; i /= 10) - { - result += '0' + static_cast(-(i % 10)); - } + const int sign = (i < 0) ? -1 : 1; - result += '-'; + for ( ; i; i /= 10) + { + result += '0' + static_cast(sign * (i % 10)); } - else + + if (sign < 0) { - for ( ; i; i /= 10) - { - result += '0' + static_cast(i % 10); - } + result += '-'; } std::reverse(result.begin(), result.end()); + return result; } @@ -309,7 +307,7 @@ namespace exprtk return to_str(static_cast(i)); } - inline bool is_hex_digit(const std::string::value_type digit) + inline bool is_hex_digit(const uchar_t digit) { return (('0' <= digit) && (digit <= '9')) || (('A' <= digit) && (digit <= 'F')) || @@ -326,7 +324,7 @@ namespace exprtk template inline bool parse_hex(Iterator& itr, Iterator end, - std::string::value_type& result) + char_t& result) { if ( (end == (itr )) || @@ -599,83 +597,84 @@ namespace exprtk } }; - template + template ::value_type> inline bool match_impl(const Iterator pattern_begin, const Iterator pattern_end , const Iterator data_begin , const Iterator data_end , - const typename std::iterator_traits::value_type& zero_or_more, - const typename std::iterator_traits::value_type& zero_or_one ) + const ValueType zero_or_more, + const ValueType exactly_one ) { const Iterator null_itr(0); - Iterator d_itr = data_begin; - Iterator p_itr = pattern_begin; - Iterator tb_p_itr = null_itr; - Iterator tb_d_itr = null_itr; + Iterator p_itr = pattern_begin; + Iterator d_itr = data_begin; + Iterator np_itr = null_itr; + Iterator nd_itr = null_itr; + bool in_bounds = true; - while (d_itr != data_end) + for ( ; ; ) { - if (zero_or_more == *p_itr) - { - while ((pattern_end != p_itr) && ((zero_or_more == *p_itr) || (zero_or_one == *p_itr))) - { - ++p_itr; - } - - if (pattern_end == p_itr) - return true; + const bool pvalid = p_itr != pattern_end; + const bool dvalid = d_itr != data_end; + if (pvalid) + { const typename std::iterator_traits::value_type c = *(p_itr); - while ((data_end != d_itr) && !Compare::cmp(c,*d_itr)) + if (dvalid && (Compare::cmp(c,*(d_itr)) || (exactly_one == c))) { ++d_itr; + ++p_itr; + continue; + } + else if (zero_or_more == c) + { + in_bounds = dvalid; + nd_itr = d_itr + 1; + np_itr = p_itr; + ++p_itr; + continue; } - - tb_p_itr = p_itr; - tb_d_itr = d_itr; - - continue; } - else if (!Compare::cmp(*p_itr, *d_itr) && (zero_or_one != *p_itr)) - { - if (null_itr == tb_d_itr) - return false; - - d_itr = tb_d_itr++; - p_itr = tb_p_itr; + else if (!dvalid) + break; + //nd_itr in [1,data_end] + if ((null_itr != nd_itr) && in_bounds) + { + p_itr = np_itr; + d_itr = nd_itr; continue; } - ++p_itr; - ++d_itr; - } - - while ((pattern_end != p_itr) && ((zero_or_more == *p_itr) || (zero_or_one == *p_itr))) - { - ++p_itr; + return false; } - return (pattern_end == p_itr); + return true; } inline bool wc_match(const std::string& wild_card, const std::string& str) { - return match_impl( - wild_card.data(), wild_card.data() + wild_card.size(), - str.data(), str.data() + str.size(), + return match_impl( + wild_card.data(), + wild_card.data() + wild_card.size(), + str.data(), + str.data() + str.size(), '*', '?'); } inline bool wc_imatch(const std::string& wild_card, const std::string& str) { - return match_impl( - wild_card.data(), wild_card.data() + wild_card.size(), - str.data(), str.data() + str.size(), + return match_impl( + wild_card.data(), + wild_card.data() + wild_card.size(), + str.data(), + str.data() + str.size(), '*', '?'); } @@ -696,8 +695,8 @@ namespace exprtk itr_t p_itr = pattern.begin(); itr_t s_itr = str .begin(); - itr_t p_end = pattern.end(); - itr_t s_end = str .end(); + const itr_t p_end = pattern.end(); + const itr_t s_end = str .end(); while ((s_end != s_itr) && (p_end != p_itr)) { @@ -1100,7 +1099,7 @@ namespace exprtk template inline T sgn_impl(const T v, real_type_tag) { - if (v > T(0)) return T(+1); + if (v > T(0)) return T(+1); else if (v < T(0)) return T(-1); else return T( 0); } @@ -1108,7 +1107,7 @@ namespace exprtk template inline T sgn_impl(const T v, int_type_tag) { - if (v > T(0)) return T(+1); + if (v > T(0)) return T(+1); else if (v < T(0)) return T(-1); else return T( 0); } @@ -1198,8 +1197,8 @@ namespace exprtk } #if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || !defined(_MSC_VER) - #define exprtk_define_erf(TT,impl) \ - inline TT erf_impl(TT v) { return impl(v); } \ + #define exprtk_define_erf(TT, impl) \ + inline TT erf_impl(const TT v) { return impl(v); } \ exprtk_define_erf( float,::erff) exprtk_define_erf( double,::erf ) @@ -1208,7 +1207,7 @@ namespace exprtk #endif template - inline T erf_impl(T v, real_type_tag) + inline T erf_impl(const T v, real_type_tag) { #if defined(_MSC_VER) && (_MSC_VER < 1900) // Credits: Abramowitz & Stegun Equations 7.1.25-28 @@ -1222,12 +1221,12 @@ namespace exprtk const T t = T(1) / (T(1) + T(0.5) * abs_impl(v,real_type_tag())); - T result = T(1) - t * std::exp((-v * v) - - c[0] + t * (c[1] + t * - (c[2] + t * (c[3] + t * - (c[4] + t * (c[5] + t * - (c[6] + t * (c[7] + t * - (c[8] + t * (c[9])))))))))); + const T result = T(1) - t * std::exp((-v * v) - + c[0] + t * (c[1] + t * + (c[2] + t * (c[3] + t * + (c[4] + t * (c[5] + t * + (c[6] + t * (c[7] + t * + (c[8] + t * (c[9])))))))))); return (v >= T(0)) ? result : -result; #else @@ -1236,14 +1235,14 @@ namespace exprtk } template - inline T erf_impl(T v, int_type_tag) + inline T erf_impl(const T v, int_type_tag) { return erf_impl(static_cast(v),real_type_tag()); } #if (defined(_MSC_VER) && (_MSC_VER >= 1900)) || !defined(_MSC_VER) - #define exprtk_define_erfc(TT,impl) \ - inline TT erfc_impl(TT v) { return impl(v); } \ + #define exprtk_define_erfc(TT, impl) \ + inline TT erfc_impl(const TT v) { return impl(v); } \ exprtk_define_erfc(float ,::erfcf) exprtk_define_erfc(double ,::erfc ) @@ -1252,7 +1251,7 @@ namespace exprtk #endif template - inline T erfc_impl(T v, real_type_tag) + inline T erfc_impl(const T v, real_type_tag) { #if defined(_MSC_VER) && (_MSC_VER < 1900) return T(1) - erf_impl(v,real_type_tag()); @@ -1262,28 +1261,28 @@ namespace exprtk } template - inline T erfc_impl(T v, int_type_tag) + inline T erfc_impl(const T v, int_type_tag) { return erfc_impl(static_cast(v),real_type_tag()); } template - inline T ncdf_impl(T v, real_type_tag) + inline T ncdf_impl(const T v, real_type_tag) { - T cnd = T(0.5) * (T(1) + erf_impl( - abs_impl(v,real_type_tag()) / - T(numeric::constant::sqrt2),real_type_tag())); + const T cnd = T(0.5) * (T(1) + + erf_impl(abs_impl(v,real_type_tag()) / + T(numeric::constant::sqrt2),real_type_tag())); return (v < T(0)) ? (T(1) - cnd) : cnd; } template - inline T ncdf_impl(T v, int_type_tag) + inline T ncdf_impl(const T v, int_type_tag) { return ncdf_impl(static_cast(v),real_type_tag()); } template - inline T sinc_impl(T v, real_type_tag) + inline T sinc_impl(const T v, real_type_tag) { if (std::abs(v) >= std::numeric_limits::epsilon()) return(std::sin(v) / v); @@ -1292,7 +1291,7 @@ namespace exprtk } template - inline T sinc_impl(T v, int_type_tag) + inline T sinc_impl(const T v, int_type_tag) { return sinc_impl(static_cast(v),real_type_tag()); } @@ -1323,14 +1322,14 @@ namespace exprtk template inline T csc_impl(const T v, real_type_tag) { return T(1) / std::sin(v); } template inline T r2d_impl(const T v, real_type_tag) { return (v * T(numeric::constant::_180_pi)); } template inline T d2r_impl(const T v, real_type_tag) { return (v * T(numeric::constant::pi_180)); } - template inline T d2g_impl(const T v, real_type_tag) { return (v * T(20.0/9.0)); } - template inline T g2d_impl(const T v, real_type_tag) { return (v * T(9.0/20.0)); } + template inline T d2g_impl(const T v, real_type_tag) { return (v * T(10.0/9.0)); } + template inline T g2d_impl(const T v, real_type_tag) { return (v * T(9.0/10.0)); } template inline T notl_impl(const T v, real_type_tag) { return (std::not_equal_to()(T(0),v) ? T(0) : T(1)); } template inline T frac_impl(const T v, real_type_tag) { return (v - static_cast(v)); } template inline T trunc_impl(const T v, real_type_tag) { return T(static_cast(v)); } - template inline T const_pi_impl (real_type_tag) { return T(numeric::constant::pi); } - template inline T const_e_impl (real_type_tag) { return T(numeric::constant::e); } + template inline T const_pi_impl(real_type_tag) { return T(numeric::constant::pi); } + template inline T const_e_impl(real_type_tag) { return T(numeric::constant::e); } template inline T const_qnan_impl(real_type_tag) { return std::numeric_limits::quiet_NaN(); } template inline T abs_impl(const T v, int_type_tag) { return ((v >= T(0)) ? v : -v); } @@ -1805,7 +1804,7 @@ namespace exprtk } template - static inline bool parse_inf(Iterator& itr, const Iterator end, T& t, bool negative) + static inline bool parse_inf(Iterator& itr, const Iterator end, T& t, const bool negative) { static const char_t inf_uc[] = "INFINITY"; static const char_t inf_lc[] = "infinity"; @@ -2263,8 +2262,8 @@ namespace exprtk generator() : base_itr_(0) - , s_itr_ (0) - , s_end_ (0) + , s_itr_ (0) + , s_end_ (0) { clear(); } @@ -2380,7 +2379,7 @@ namespace exprtk } } - inline std::string substr(const std::size_t& begin, const std::size_t& end) + inline std::string substr(const std::size_t& begin, const std::size_t& end) const { const details::char_cptr begin_itr = ((base_itr_ + begin) < s_end_) ? (base_itr_ + begin) : s_end_; const details::char_cptr end_itr = ((base_itr_ + end ) < s_end_) ? (base_itr_ + end ) : s_end_; @@ -2400,13 +2399,13 @@ namespace exprtk private: - inline bool is_end(details::char_cptr itr) + inline bool is_end(details::char_cptr itr) const { return (s_end_ == itr); } #ifndef exprtk_disable_comments - inline bool is_comment_start(details::char_cptr itr) + inline bool is_comment_start(details::char_cptr itr) const { const char_t c0 = *(itr + 0); const char_t c1 = *(itr + 1); @@ -2421,7 +2420,7 @@ namespace exprtk return false; } #else - inline bool is_comment_start(details::char_cptr) + inline bool is_comment_start(details::char_cptr) const { return false; } @@ -2447,10 +2446,10 @@ namespace exprtk static inline bool comment_start(const char_t c0, const char_t c1, int& mode, int& incr) { mode = 0; - if ('#' == c0) { mode = 1; incr = 1; } + if ('#' == c0) { mode = 1; incr = 1; } else if ('/' == c0) { - if ('/' == c1) { mode = 1; incr = 2; } + if ('/' == c1) { mode = 1; incr = 2; } else if ('*' == c1) { mode = 2; incr = 2; } } return (0 != mode); @@ -2593,7 +2592,7 @@ namespace exprtk token_t::token_type ttype = token_t::e_none; - if ((c0 == '<') && (c1 == '=')) ttype = token_t::e_lte; + if ((c0 == '<') && (c1 == '=')) ttype = token_t::e_lte; else if ((c0 == '>') && (c1 == '=')) ttype = token_t::e_gte; else if ((c0 == '<') && (c1 == '>')) ttype = token_t::e_ne; else if ((c0 == '!') && (c1 == '=')) ttype = token_t::e_ne; @@ -2931,7 +2930,7 @@ namespace exprtk friend class token_modifier; friend class token_inserter; friend class token_joiner; - }; + }; // class generator class helper_interface { @@ -2948,8 +2947,7 @@ namespace exprtk { public: - virtual ~token_scanner() - {} + virtual ~token_scanner() {} explicit token_scanner(const std::size_t& stride) : stride_(stride) @@ -3049,7 +3047,7 @@ namespace exprtk private: const std::size_t stride_; - }; + }; // class token_scanner class token_modifier : public helper_interface { @@ -3350,7 +3348,7 @@ namespace exprtk return -1; } } - if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_symbol )) match = true; + if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_symbol )) match = true; else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lbracket )) match = true; else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lcrlbracket)) match = true; else if ((t0.type == lexer::token::e_number ) && (t1.type == lexer::token::e_lsqrbracket)) match = true; @@ -3598,7 +3596,7 @@ namespace exprtk { details::char_t c = t.value[0]; - if (t.type == lexer::token::e_lbracket ) stack_.push(std::make_pair(')',t.position)); + if (t.type == lexer::token::e_lbracket ) stack_.push(std::make_pair(')',t.position)); else if (t.type == lexer::token::e_lcrlbracket) stack_.push(std::make_pair('}',t.position)); else if (t.type == lexer::token::e_lsqrbracket) stack_.push(std::make_pair(']',t.position)); else if (exprtk::details::is_right_bracket(c)) @@ -3632,6 +3630,7 @@ namespace exprtk lexer::token error_token_; }; + template class numeric_checker : public lexer::token_scanner { public: @@ -3658,7 +3657,7 @@ namespace exprtk { if (token::e_number == t.type) { - double v; + T v; if (!exprtk::details::string_to_real(t.value,v)) { @@ -4859,8 +4858,8 @@ namespace exprtk private: - control_block(const control_block&); - control_block& operator=(const control_block&); + control_block(const control_block&) exprtk_delete; + control_block& operator=(const control_block&) exprtk_delete; inline void create_data() { @@ -4927,11 +4926,6 @@ namespace exprtk return control_block_->data; } - inline std::size_t size() - { - return control_block_->size; - } - inline std::size_t size() const { return control_block_->size; @@ -4970,7 +4964,7 @@ namespace exprtk private: - static inline std::size_t min_size(control_block* cb0, control_block* cb1) + static inline std::size_t min_size(const control_block* cb0, const control_block* cb1) { const std::size_t size0 = cb0->size; const std::size_t size1 = cb1->size; @@ -5199,8 +5193,7 @@ namespace exprtk typedef typename nci_t::noderef_list_t noderef_list_t; typedef node_depth_base > ndb_t; - virtual ~expression_node() - {} + virtual ~expression_node() {} inline virtual T value() const { @@ -5216,7 +5209,7 @@ namespace exprtk { return e_none; } - }; + }; // class expression_node template inline bool is_generally_string_node(const expression_node* node); @@ -5354,7 +5347,11 @@ namespace exprtk template inline bool is_constant_node(const expression_node* node) { - return node && (details::expression_node::e_constant == node->type()); + return node && + ( + details::expression_node::e_constant == node->type() || + details::expression_node::e_stringconst == node->type() + ); } template @@ -5867,7 +5864,8 @@ namespace exprtk private: - array_vector_impl operator=(const array_vector_impl&); + array_vector_impl(const array_vector_impl&) exprtk_delete; + array_vector_impl& operator=(const array_vector_impl&) exprtk_delete; const Type* vec_; const std::size_t size_; @@ -5899,7 +5897,8 @@ namespace exprtk private: - sequence_vector_impl operator=(const sequence_vector_impl&); + sequence_vector_impl(const sequence_vector_impl&) exprtk_delete; + sequence_vector_impl& operator=(const sequence_vector_impl&) exprtk_delete; sequence_t& sequence_; }; @@ -5938,7 +5937,8 @@ namespace exprtk private: - vector_view_impl operator=(const vector_view_impl&); + vector_view_impl(const vector_view_impl&) exprtk_delete; + vector_view_impl& operator=(const vector_view_impl&) exprtk_delete; vector_view_t& vec_view_; }; @@ -6000,12 +6000,12 @@ namespace exprtk { public: - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_null; } @@ -6070,7 +6070,7 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); @@ -6083,27 +6083,22 @@ namespace exprtk return (equality_) ? T(0) : T(1); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_nulleq; } - inline operator_type operation() const - { - return details::e_eq; - } - - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -6123,25 +6118,25 @@ namespace exprtk : value_(v) {} - inline T value() const + inline T value() const exprtk_override { return value_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_constant; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return reinterpret_cast*>(0); } private: - literal_node(literal_node&) {} - literal_node& operator=(literal_node&) { return (*this); } + literal_node(const literal_node&) exprtk_delete; + literal_node& operator=(const literal_node&) exprtk_delete; const T value_; }; @@ -6159,8 +6154,7 @@ namespace exprtk typedef range_pack range_t; - virtual ~range_interface() - {} + virtual ~range_interface() {} virtual range_t& range_ref() = 0; @@ -6175,8 +6169,7 @@ namespace exprtk typedef range_data_type range_data_type_t; - virtual ~string_base_node() - {} + virtual ~string_base_node() {} virtual std::string str () const = 0; @@ -6204,50 +6197,50 @@ namespace exprtk rp_.cache.second = rp_.n1_c.second; } - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringconst; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return reinterpret_cast*>(0); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return value_.data(); } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return rp_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return rp_; } private: - string_literal_node(const string_literal_node&); - string_literal_node& operator=(const string_literal_node&); + string_literal_node(const string_literal_node&) exprtk_delete; + string_literal_node& operator=(const string_literal_node&) exprtk_delete; const std::string value_; range_t rp_; @@ -6268,7 +6261,7 @@ namespace exprtk construct_branch_pair(branch_,branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); @@ -6277,17 +6270,17 @@ namespace exprtk return numeric::process(operation_,arg); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_unary; } - inline operator_type operation() const + inline operator_type operation() { return operation_; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } @@ -6297,12 +6290,12 @@ namespace exprtk branch_.second = false; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -6329,7 +6322,7 @@ namespace exprtk init_branches<2>(branch_, branch0, branch1); } - inline T value() const + inline T value() const exprtk_override { assert(branch_[0].first); assert(branch_[1].first); @@ -6340,7 +6333,7 @@ namespace exprtk return numeric::process(operation_,arg0,arg1); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_binary; } @@ -6350,7 +6343,7 @@ namespace exprtk return operation_; } - inline expression_node* branch(const std::size_t& index = 0) const + inline expression_node* branch(const std::size_t& index = 0) const exprtk_override { if (0 == index) return branch_[0].first; @@ -6360,12 +6353,12 @@ namespace exprtk return reinterpret_cast(0); } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::template compute_node_depth<2>(branch_); } @@ -6389,7 +6382,7 @@ namespace exprtk init_branches<2>(branch_, branch0, branch1); } - inline T value() const + inline T value() const exprtk_override { assert(branch_[0].first); assert(branch_[1].first); @@ -6400,7 +6393,7 @@ namespace exprtk return Operation::process(arg0,arg1); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_binary_ext; } @@ -6410,7 +6403,7 @@ namespace exprtk return Operation::operation(); } - inline expression_node* branch(const std::size_t& index = 0) const + inline expression_node* branch(const std::size_t& index = 0) const exprtk_override { if (0 == index) return branch_[0].first; @@ -6420,12 +6413,12 @@ namespace exprtk return reinterpret_cast(0); } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::template compute_node_depth<2>(branch_); } @@ -6452,7 +6445,7 @@ namespace exprtk init_branches<3>(branch_, branch0, branch1, branch2); } - inline T value() const + inline T value() const exprtk_override { assert(branch_[0].first); assert(branch_[1].first); @@ -6478,17 +6471,17 @@ namespace exprtk } } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_trinary; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::template compute_node_depth<3>(branch_); } @@ -6517,22 +6510,22 @@ namespace exprtk init_branches<4>(branch_, branch0, branch1, branch2, branch3); } - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_quaternary; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::template compute_node_depth<4>(branch_); } @@ -6560,7 +6553,7 @@ namespace exprtk construct_branch_pair(alternative_, alternative); } - inline T value() const + inline T value() const exprtk_override { assert(condition_ .first); assert(consequent_ .first); @@ -6572,19 +6565,19 @@ namespace exprtk return alternative_.first->value(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_conditional; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(condition_ , node_delete_list); expression_node::ndb_t::collect(consequent_ , node_delete_list); expression_node::ndb_t::collect(alternative_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth (condition_, consequent_, alternative_); @@ -6613,7 +6606,7 @@ namespace exprtk construct_branch_pair(consequent_, consequent); } - inline T value() const + inline T value() const exprtk_override { assert(condition_ .first); assert(consequent_.first); @@ -6624,18 +6617,18 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_conditional; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(condition_ , node_delete_list); expression_node::ndb_t::collect(consequent_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t:: compute_node_depth(condition_, consequent_); @@ -6660,8 +6653,7 @@ namespace exprtk T value; }; - class continue_exception - {}; + class continue_exception {}; template class break_node exprtk_final : public expression_node @@ -6676,7 +6668,7 @@ namespace exprtk construct_branch_pair(return_, ret); } - inline T value() const + inline T value() const exprtk_override { const T result = return_.first ? return_.first->value() : @@ -6689,17 +6681,17 @@ namespace exprtk #endif } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_break; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(return_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(return_); } @@ -6714,7 +6706,7 @@ namespace exprtk { public: - inline T value() const + inline T value() const exprtk_override { throw continue_exception(); #ifndef _MSC_VER @@ -6722,22 +6714,24 @@ namespace exprtk #endif } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_break; } }; #endif - #ifdef exprtk_enable_runtime_checks struct loop_runtime_checker { - loop_runtime_checker(loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0), + loop_runtime_checker(loop_runtime_check_ptr loop_runtime_check, loop_runtime_check::loop_types lp_typ = loop_runtime_check::e_invalid) : iteration_count_(0) - , loop_runtime_check_(loop_rt_chk) - , loop_type(lp_typ) - {} + , loop_runtime_check_(loop_runtime_check) + , max_loop_iterations_(loop_runtime_check_->max_loop_iterations) + , loop_type_(lp_typ) + { + assert(loop_runtime_check_); + } inline void reset(const _uint64_t initial_value = 0) const { @@ -6748,14 +6742,14 @@ namespace exprtk { if ( (0 == loop_runtime_check_) || - (++iteration_count_ <= loop_runtime_check_->max_loop_iterations) + (++iteration_count_ <= max_loop_iterations_) ) { return true; } loop_runtime_check::violation_context ctxt; - ctxt.loop = loop_type; + ctxt.loop = loop_type_; ctxt.violation = loop_runtime_check::e_iteration_count; loop_runtime_check_->handle_runtime_violation(ctxt); @@ -6765,28 +6759,12 @@ namespace exprtk mutable _uint64_t iteration_count_; mutable loop_runtime_check_ptr loop_runtime_check_; - loop_runtime_check::loop_types loop_type; + const details::_uint64_t& max_loop_iterations_; + loop_runtime_check::loop_types loop_type_; }; - #else - struct loop_runtime_checker - { - loop_runtime_checker(loop_runtime_check_ptr, loop_runtime_check::loop_types) - {} - - inline void reset(const _uint64_t = 0) const - {} - - inline bool check() const - { - return true; - } - }; - #endif template - class while_loop_node exprtk_final - : public expression_node, - public loop_runtime_checker + class while_loop_node : public expression_node { public: @@ -6794,24 +6772,20 @@ namespace exprtk typedef std::pair branch_t; while_loop_node(expression_ptr condition, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk,loop_runtime_check::e_while_loop) + expression_ptr loop_body) { construct_branch_pair(condition_, condition); construct_branch_pair(loop_body_, loop_body); } - inline T value() const + inline T value() const exprtk_override { assert(condition_.first); assert(loop_body_.first); T result = T(0); - loop_runtime_checker::reset(); - - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(condition_)) { result = loop_body_.first->value(); } @@ -6819,32 +6793,65 @@ namespace exprtk return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_while; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(condition_ , node_delete_list); expression_node::ndb_t::collect(loop_body_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(condition_, loop_body_); } - private: + protected: branch_t condition_; branch_t loop_body_; }; template - class repeat_until_loop_node exprtk_final - : public expression_node, - public loop_runtime_checker + class while_loop_rtc_node exprtk_final + : public while_loop_node + , public loop_runtime_checker + { + public: + + typedef while_loop_node parent_t; + typedef expression_node* expression_ptr; + + while_loop_rtc_node(expression_ptr condition, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(condition, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_while_loop) + {} + + inline T value() const exprtk_override + { + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); + + T result = T(0); + + loop_runtime_checker::reset(); + + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + result = parent_t::loop_body_.first->value(); + } + + return result; + } + }; + + template + class repeat_until_loop_node : public expression_node { public: @@ -6852,58 +6859,88 @@ namespace exprtk typedef std::pair branch_t; repeat_until_loop_node(expression_ptr condition, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_repeat_until_loop) + expression_ptr loop_body) { construct_branch_pair(condition_, condition); construct_branch_pair(loop_body_, loop_body); } - inline T value() const + inline T value() const exprtk_override { assert(condition_.first); assert(loop_body_.first); T result = T(0); - loop_runtime_checker::reset(1); - do { result = loop_body_.first->value(); } - while (is_false(condition_.first) && loop_runtime_checker::check()); + while (is_false(condition_.first)); return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_repeat; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(condition_ , node_delete_list); expression_node::ndb_t::collect(loop_body_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(condition_, loop_body_); } - private: + protected: branch_t condition_; branch_t loop_body_; }; template - class for_loop_node exprtk_final - : public expression_node, - public loop_runtime_checker + class repeat_until_loop_rtc_node exprtk_final + : public repeat_until_loop_node + , public loop_runtime_checker + { + public: + + typedef repeat_until_loop_node parent_t; + typedef expression_node* expression_ptr; + + repeat_until_loop_rtc_node(expression_ptr condition, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(condition, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_repeat_until_loop) + {} + + inline T value() const exprtk_override + { + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); + + T result = T(0); + + loop_runtime_checker::reset(1); + + do + { + result = parent_t::loop_body_.first->value(); + } + while (is_false(parent_t::condition_.first) && loop_runtime_checker::check()); + + return result; + } + }; + + template + class for_loop_node : public expression_node { public: @@ -6913,9 +6950,7 @@ namespace exprtk for_loop_node(expression_ptr initialiser, expression_ptr condition, expression_ptr incrementor, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_for_loop) + expression_ptr loop_body) { construct_branch_pair(initialiser_, initialiser); construct_branch_pair(condition_ , condition ); @@ -6923,21 +6958,19 @@ namespace exprtk construct_branch_pair(loop_body_ , loop_body ); } - inline T value() const + inline T value() const exprtk_override { assert(condition_.first); assert(loop_body_.first); T result = T(0); - loop_runtime_checker::reset(); - if (initialiser_.first) initialiser_.first->value(); if (incrementor_.first) { - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(condition_)) { result = loop_body_.first->value(); incrementor_.first->value(); @@ -6945,7 +6978,7 @@ namespace exprtk } else { - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(condition_)) { result = loop_body_.first->value(); } @@ -6954,12 +6987,12 @@ namespace exprtk return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_for; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(initialiser_ , node_delete_list); expression_node::ndb_t::collect(condition_ , node_delete_list); @@ -6967,13 +7000,13 @@ namespace exprtk expression_node::ndb_t::collect(loop_body_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth (initialiser_, condition_, incrementor_, loop_body_); } - private: + protected: branch_t initialiser_; branch_t condition_ ; @@ -6981,40 +7014,83 @@ namespace exprtk branch_t loop_body_ ; }; - #ifndef exprtk_disable_break_continue template - class while_loop_bc_node exprtk_final - : public expression_node, - public loop_runtime_checker + class for_loop_rtc_node exprtk_final + : public for_loop_node + , public loop_runtime_checker { public: + typedef for_loop_node parent_t; typedef expression_node* expression_ptr; - typedef std::pair branch_t; - while_loop_bc_node(expression_ptr condition, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_while_loop) - { - construct_branch_pair(condition_, condition); - construct_branch_pair(loop_body_, loop_body); - } + for_loop_rtc_node(expression_ptr initialiser, + expression_ptr condition, + expression_ptr incrementor, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(initialiser, condition, incrementor, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_for_loop) + {} - inline T value() const + inline T value() const exprtk_override { - assert(condition_.first); - assert(loop_body_.first); + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); T result = T(0); loop_runtime_checker::reset(); - while (is_true(condition_) && loop_runtime_checker::check()) + if (parent_t::initialiser_.first) + parent_t::initialiser_.first->value(); + + if (parent_t::incrementor_.first) + { + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + result = parent_t::loop_body_.first->value(); + parent_t::incrementor_.first->value(); + } + } + else + { + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + result = parent_t::loop_body_.first->value(); + } + } + + return result; + } + }; + + #ifndef exprtk_disable_break_continue + template + class while_loop_bc_node : public while_loop_node + { + public: + + typedef while_loop_node parent_t; + typedef expression_node* expression_ptr; + + while_loop_bc_node(expression_ptr condition, + expression_ptr loop_body) + : parent_t(condition, loop_body) + {} + + inline T value() const exprtk_override + { + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); + + T result = T(0); + + while (is_true(parent_t::condition_)) { try { - result = loop_body_.first->value(); + result = parent_t::loop_body_.first->value(); } catch(const break_exception& e) { @@ -7026,62 +7102,77 @@ namespace exprtk return result; } + }; - inline typename expression_node::node_type type() const - { - return expression_node::e_while; - } + template + class while_loop_bc_rtc_node exprtk_final + : public while_loop_bc_node + , public loop_runtime_checker + { + public: - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) - { - expression_node::ndb_t::collect(condition_ , node_delete_list); - expression_node::ndb_t::collect(loop_body_ , node_delete_list); - } + typedef while_loop_bc_node parent_t; + typedef expression_node* expression_ptr; + + while_loop_bc_rtc_node(expression_ptr condition, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(condition, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_while_loop) + {} - std::size_t node_depth() const + inline T value() const exprtk_override { - return expression_node::ndb_t::compute_node_depth(condition_, loop_body_); - } + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); - private: + T result = T(0); - branch_t condition_; - branch_t loop_body_; + loop_runtime_checker::reset(); + + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + try + { + result = parent_t::loop_body_.first->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + } + + return result; + } }; template - class repeat_until_loop_bc_node exprtk_final - : public expression_node, - public loop_runtime_checker + class repeat_until_loop_bc_node : public repeat_until_loop_node { public: - typedef expression_node* expression_ptr; - typedef std::pair branch_t; + typedef repeat_until_loop_node parent_t; + typedef expression_node* expression_ptr; repeat_until_loop_bc_node(expression_ptr condition, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_repeat_until_loop) - { - construct_branch_pair(condition_, condition); - construct_branch_pair(loop_body_, loop_body); - } + expression_ptr loop_body) + : parent_t(condition, loop_body) + {} - inline T value() const + inline T value() const exprtk_override { - assert(condition_.first); - assert(loop_body_.first); + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); T result = T(0); - loop_runtime_checker::reset(); - do { try { - result = loop_body_.first->value(); + result = parent_t::loop_body_.first->value(); } catch(const break_exception& e) { @@ -7090,75 +7181,89 @@ namespace exprtk catch(const continue_exception&) {} } - while (is_false(condition_.first) && loop_runtime_checker::check()); + while (is_false(parent_t::condition_.first)); return result; } + }; - inline typename expression_node::node_type type() const - { - return expression_node::e_repeat; - } + template + class repeat_until_loop_bc_rtc_node exprtk_final + : public repeat_until_loop_bc_node, + public loop_runtime_checker + { + public: - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) - { - expression_node::ndb_t::collect(condition_ , node_delete_list); - expression_node::ndb_t::collect(loop_body_ , node_delete_list); - } + typedef repeat_until_loop_bc_node parent_t; + typedef expression_node* expression_ptr; - std::size_t node_depth() const + repeat_until_loop_bc_rtc_node(expression_ptr condition, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(condition, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_repeat_until_loop) + {} + + inline T value() const exprtk_override { - return expression_node::ndb_t::compute_node_depth(condition_, loop_body_); - } + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); - private: + T result = T(0); - branch_t condition_; - branch_t loop_body_; + loop_runtime_checker::reset(); + + do + { + try + { + result = parent_t::loop_body_.first->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + } + while (is_false(parent_t::condition_.first) && loop_runtime_checker::check()); + + return result; + } }; template - class for_loop_bc_node exprtk_final - : public expression_node, - public loop_runtime_checker + class for_loop_bc_node : public for_loop_node { public: + typedef for_loop_node parent_t; typedef expression_node* expression_ptr; - typedef std::pair branch_t; for_loop_bc_node(expression_ptr initialiser, expression_ptr condition, expression_ptr incrementor, - expression_ptr loop_body, - loop_runtime_check_ptr loop_rt_chk = loop_runtime_check_ptr(0)) - : loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_for_loop) - { - construct_branch_pair(initialiser_, initialiser); - construct_branch_pair(condition_ , condition ); - construct_branch_pair(incrementor_, incrementor); - construct_branch_pair(loop_body_ , loop_body ); - } + expression_ptr loop_body) + : parent_t(initialiser, condition, incrementor, loop_body) + {} - inline T value() const + inline T value() const exprtk_override { - assert(condition_.first); - assert(loop_body_.first); + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); T result = T(0); - loop_runtime_checker::reset(); - - if (initialiser_.first) - initialiser_.first->value(); + if (parent_t::initialiser_.first) + parent_t::initialiser_.first->value(); - if (incrementor_.first) + if (parent_t::incrementor_.first) { - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(parent_t::condition_)) { try { - result = loop_body_.first->value(); + result = parent_t::loop_body_.first->value(); } catch(const break_exception& e) { @@ -7167,16 +7272,16 @@ namespace exprtk catch(const continue_exception&) {} - incrementor_.first->value(); + parent_t::incrementor_.first->value(); } } else { - while (is_true(condition_) && loop_runtime_checker::check()) + while (is_true(parent_t::condition_)) { try { - result = loop_body_.first->value(); + result = parent_t::loop_body_.first->value(); } catch(const break_exception& e) { @@ -7189,32 +7294,76 @@ namespace exprtk return result; } + }; - inline typename expression_node::node_type type() const - { - return expression_node::e_for; - } + template + class for_loop_bc_rtc_node exprtk_final + : public for_loop_bc_node + , public loop_runtime_checker + { + public: - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) - { - expression_node::ndb_t::collect(initialiser_ , node_delete_list); - expression_node::ndb_t::collect(condition_ , node_delete_list); - expression_node::ndb_t::collect(incrementor_ , node_delete_list); - expression_node::ndb_t::collect(loop_body_ , node_delete_list); - } + typedef for_loop_bc_node parent_t; + typedef expression_node* expression_ptr; - std::size_t node_depth() const + for_loop_bc_rtc_node(expression_ptr initialiser, + expression_ptr condition, + expression_ptr incrementor, + expression_ptr loop_body, + loop_runtime_check_ptr loop_rt_chk) + : parent_t(initialiser, condition, incrementor, loop_body) + , loop_runtime_checker(loop_rt_chk, loop_runtime_check::e_for_loop) + {} + + inline T value() const exprtk_override { - return expression_node::ndb_t::compute_node_depth - (initialiser_, condition_, incrementor_, loop_body_); - } + assert(parent_t::condition_.first); + assert(parent_t::loop_body_.first); - private: + T result = T(0); - branch_t initialiser_; - branch_t condition_ ; - branch_t incrementor_; - branch_t loop_body_ ; + loop_runtime_checker::reset(); + + if (parent_t::initialiser_.first) + parent_t::initialiser_.first->value(); + + if (parent_t::incrementor_.first) + { + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + try + { + result = parent_t::loop_body_.first->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + + parent_t::incrementor_.first->value(); + } + } + else + { + while (is_true(parent_t::condition_) && loop_runtime_checker::check()) + { + try + { + result = parent_t::loop_body_.first->value(); + } + catch(const break_exception& e) + { + return e.value; + } + catch(const continue_exception&) + {} + } + } + + return result; + } }; #endif @@ -7249,7 +7398,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (!arg_list_.empty()) { @@ -7272,17 +7421,17 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const exprtk_final + inline typename expression_node::node_type type() const exprtk_override exprtk_final { return expression_node::e_switch; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(arg_list_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::compute_node_depth(arg_list_); } @@ -7305,7 +7454,7 @@ namespace exprtk : switch_node(arg_list) {} - inline T value() const + inline T value() const exprtk_override { return Switch_N::process(switch_node::arg_list_); } @@ -7342,7 +7491,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { T result = T(0); @@ -7367,17 +7516,17 @@ namespace exprtk return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_mswitch; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(arg_list_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::compute_node_depth(arg_list_); } @@ -7392,8 +7541,7 @@ namespace exprtk { public: - virtual ~ivariable() - {} + virtual ~ivariable() {} virtual T& ref() = 0; virtual const T& ref() const = 0; @@ -7421,22 +7569,22 @@ namespace exprtk return this < (&v); } - inline T value() const + inline T value() const exprtk_override { return (*value_); } - inline T& ref() + inline T& ref() exprtk_override { return (*value_); } - inline const T& ref() const + inline const T& ref() const exprtk_override { return (*value_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_variable; } @@ -7545,7 +7693,7 @@ namespace exprtk cache.first = r0; cache.second = r1; - #ifndef exprtk_enable_runtime_checks + #ifndef exprtk_enable_range_runtime_checks return (r0 <= r1); #else return range_runtime_check(r0, r1, size); @@ -7568,7 +7716,7 @@ namespace exprtk std::pair n1_c; mutable cached_range_t cache; - #ifdef exprtk_enable_runtime_checks + #ifdef exprtk_enable_range_runtime_checks bool range_runtime_check(const std::size_t r0, const std::size_t r1, const std::size_t size) const @@ -7624,8 +7772,7 @@ namespace exprtk typedef vector_node* vector_node_ptr; typedef vec_data_store vds_t; - virtual ~vector_interface() - {} + virtual ~vector_interface() {} virtual std::size_t size () const = 0; @@ -7647,10 +7794,10 @@ namespace exprtk { public: - typedef expression_node* expression_ptr; + typedef expression_node* expression_ptr; typedef vector_holder vector_holder_t; typedef vector_node* vector_node_ptr; - typedef vec_data_store vds_t; + typedef vec_data_store vds_t; explicit vector_node(vector_holder_t* vh) : vector_holder_(vh) @@ -7664,37 +7811,37 @@ namespace exprtk , vds_(vds) {} - inline T value() const + inline T value() const exprtk_override { return vds().data()[0]; } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return const_cast(this); } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return this; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vector; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -7729,22 +7876,22 @@ namespace exprtk construct_branch_pair(index_, index); } - inline T value() const + inline T value() const exprtk_override { return *(vector_base_ + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline T& ref() + inline T& ref() exprtk_override { return *(vector_base_ + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline const T& ref() const + inline const T& ref() const exprtk_override { return *(vector_base_ + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecelem; } @@ -7754,12 +7901,12 @@ namespace exprtk return (*vec_holder_); } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(index_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(index_); } @@ -7792,22 +7939,22 @@ namespace exprtk construct_branch_pair(index_, index); } - inline T value() const + inline T value() const exprtk_override { return *(vds_.data() + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline T& ref() + inline T& ref() exprtk_override { return *(vds_.data() + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline const T& ref() const + inline const T& ref() const exprtk_override { return *(vds_.data() + static_cast(details::numeric::to_int64(index_.first->value()))); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_rbvecelem; } @@ -7817,12 +7964,12 @@ namespace exprtk return (*vector_holder_); } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(index_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(index_); } @@ -7854,22 +8001,22 @@ namespace exprtk vector_holder_->set_ref(&vds_.ref()); } - inline T value() const + inline T value() const exprtk_override { return *(vds_.data() + index_); } - inline T& ref() + inline T& ref() exprtk_override { return *(vds_.data() + index_); } - inline const T& ref() const + inline const T& ref() const exprtk_override { return *(vds_.data() + index_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_rbveccelem; } @@ -7903,7 +8050,7 @@ namespace exprtk , single_value_initialse_(single_value_initialse) {} - inline T value() const + inline T value() const exprtk_override { if (single_value_initialse_) { @@ -7914,16 +8061,16 @@ namespace exprtk } else { - std::size_t il_size = initialiser_list_.size(); + const std::size_t initialiser_list_size = initialiser_list_.size(); - for (std::size_t i = 0; i < il_size; ++i) + for (std::size_t i = 0; i < initialiser_list_size; ++i) { *(vector_base_ + i) = initialiser_list_[i]->value(); } - if (il_size < size_) + if (initialiser_list_size < size_) { - for (std::size_t i = il_size; i < size_; ++i) + for (std::size_t i = initialiser_list_size; i < size_; ++i) { *(vector_base_ + i) = T(0); } @@ -7933,24 +8080,25 @@ namespace exprtk return *(vector_base_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecdefass; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(initialiser_list_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(initialiser_list_); } private: - vector_assignment_node& operator=(const vector_assignment_node&); + vector_assignment_node(const vector_assignment_node&) exprtk_delete; + vector_assignment_node& operator=(const vector_assignment_node&) exprtk_delete; mutable T* vector_base_; std::vector initialiser_list_; @@ -7971,13 +8119,13 @@ namespace exprtk , var1_(var1) {} - inline T value() const + inline T value() const exprtk_override { std::swap(var0_->ref(),var1_->ref()); return var1_->ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_swap; } @@ -8002,13 +8150,13 @@ namespace exprtk , var1_(dynamic_cast(var1)) {} - inline T value() const + inline T value() const exprtk_override { std::swap(var0_->ref(),var1_->ref()); return var1_->ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_swap; } @@ -8070,7 +8218,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8094,32 +8242,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return vec0_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return vec0_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvecswap; } - std::size_t size() const + std::size_t size() const exprtk_override { return vec_size_; } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -8142,7 +8290,7 @@ namespace exprtk { public: - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; static std::string null_value; @@ -8164,7 +8312,7 @@ namespace exprtk return this < (&v); } - inline T value() const + inline T value() const exprtk_override { rp_.n1_c.second = (*value_).size() - 1; rp_.cache.second = rp_.n1_c.second; @@ -8172,17 +8320,17 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return ref(); } - char_cptr base() const + char_cptr base() const exprtk_override { return &(*value_)[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return ref().size(); } @@ -8197,21 +8345,30 @@ namespace exprtk return (*value_); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return rp_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return rp_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringvar; } + void rebase(std::string& s) + { + value_ = &s; + rp_.n0_c = std::make_pair(true,0); + rp_.n1_c = std::make_pair(true,value_->size() - 1); + rp_.cache.first = rp_.n0_c.second; + rp_.cache.second = rp_.n1_c.second; + } + private: std::string* value_; @@ -8229,7 +8386,7 @@ namespace exprtk { public: - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; static std::string null_value; @@ -8248,22 +8405,22 @@ namespace exprtk return this < (&v); } - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - inline std::string str() const + inline std::string str() const exprtk_override { return (*value_); } - char_cptr base() const + char_cptr base() const exprtk_override { return &(*value_)[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return ref().size(); } @@ -8283,17 +8440,17 @@ namespace exprtk return (*value_); } - inline range_t& range_ref() + inline range_t& range_ref() exprtk_override { return rp_; } - inline const range_t& range_ref() const + inline const range_t& range_ref() const exprtk_override { return rp_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringvarrng; } @@ -8315,7 +8472,7 @@ namespace exprtk { public: - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; explicit const_string_range_node(const std::string& v, const range_t& rp) : value_(v) @@ -8327,22 +8484,22 @@ namespace exprtk rp_.free(); } - inline T value() const + inline T value() const exprtk_override { return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return value_.data(); } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } @@ -8352,24 +8509,25 @@ namespace exprtk return rp_; } - range_t& range_ref() + range_t& range_ref() exprtk_override { return rp_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return rp_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_cstringvarrng; } private: - const_string_range_node& operator=(const const_string_range_node&); + const_string_range_node(const const_string_range_node&) exprtk_delete; + const_string_range_node& operator=(const const_string_range_node&) exprtk_delete; const std::string value_; range_t rp_; @@ -8386,13 +8544,12 @@ namespace exprtk typedef expression_node * expression_ptr; typedef stringvar_node * strvar_node_ptr; typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; typedef std::pair branch_t; - generic_string_range_node(expression_ptr str_branch, const range_t& brange) : initialised_(false) , str_base_ptr_ (0) @@ -8429,7 +8586,7 @@ namespace exprtk base_range_.free(); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8464,42 +8621,42 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return &value_[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return range_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return range_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strgenrange; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -8523,22 +8680,22 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; + typedef typename range_interface::range_t range_t; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef range_t* range_ptr; + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; string_concat_node(const operator_type& opr, expression_ptr branch0, expression_ptr branch1) : binary_node(opr, branch0, branch1) - , initialised_(false) - , str0_base_ptr_ (0) - , str1_base_ptr_ (0) - , str0_range_ptr_(0) - , str1_range_ptr_(0) + , initialised_(false) + , str0_base_ptr_ (0) + , str1_base_ptr_ (0) + , str0_range_ptr_(0) + , str1_range_ptr_(0) { range_.n0_c = std::make_pair(true,0); range_.n1_c = std::make_pair(true,0); @@ -8580,7 +8737,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8618,32 +8775,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return &value_[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return range_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return range_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strconcat; } @@ -8667,13 +8824,13 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef stringvar_node * strvar_node_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef stringvar_node * strvar_node_ptr; + typedef string_base_node* str_base_ptr; swap_string_node(expression_ptr branch0, expression_ptr branch1) : binary_node(details::e_swap, branch0, branch1), @@ -8696,7 +8853,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8712,32 +8869,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return str0_node_ptr_->str(); } - char_cptr base() const + char_cptr base() const exprtk_override { return str0_node_ptr_->base(); } - std::size_t size() const + std::size_t size() const exprtk_override { return str0_node_ptr_->size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return str0_node_ptr_->range_ref(); } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return str0_node_ptr_->range_ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strswap; } @@ -8754,12 +8911,12 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; swap_genstrings_node(expression_ptr branch0, expression_ptr branch1) @@ -8808,7 +8965,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -8891,15 +9048,15 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strswap; } private: - swap_genstrings_node(swap_genstrings_node&); - swap_genstrings_node& operator=(swap_genstrings_node&); + swap_genstrings_node(const swap_genstrings_node&) exprtk_delete; + swap_genstrings_node& operator=(const swap_genstrings_node&) exprtk_delete; str_base_ptr str0_base_ptr_; str_base_ptr str1_base_ptr_; @@ -8923,12 +9080,12 @@ namespace exprtk : value_(&v) {} - inline T value() const + inline T value() const exprtk_override { return T((*value_).size()); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringvarsize; } @@ -8964,7 +9121,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { T result = std::numeric_limits::quiet_NaN(); @@ -8977,17 +9134,17 @@ namespace exprtk return result; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringsize; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -9018,13 +9175,13 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef stringvar_node * strvar_node_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef stringvar_node * strvar_node_ptr; + typedef string_base_node* str_base_ptr; assignment_string_node(const operator_type& opr, expression_ptr branch0, @@ -9066,7 +9223,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -9093,32 +9250,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return str0_node_ptr_->str(); } - char_cptr base() const + char_cptr base() const exprtk_override { return str0_node_ptr_->base(); } - std::size_t size() const + std::size_t size() const exprtk_override { return str0_node_ptr_->size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return str0_node_ptr_->range_ref(); } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return str0_node_ptr_->range_ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strass; } @@ -9140,14 +9297,14 @@ namespace exprtk { public: + typedef typename range_interface::range_t range_t; + typedef range_t* range_ptr; + typedef range_interface irange_t; + typedef irange_t* irange_ptr; typedef expression_node * expression_ptr; typedef stringvar_node * strvar_node_ptr; typedef string_range_node* str_rng_node_ptr; typedef string_base_node * str_base_ptr; - typedef range_pack range_t; - typedef range_t* range_ptr; - typedef range_interface irange_t; - typedef irange_t* irange_ptr; assignment_string_range_node(const operator_type& opr, expression_ptr branch0, @@ -9198,7 +9355,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -9233,32 +9390,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return str0_base_ptr_->str(); } - char_cptr base() const + char_cptr base() const exprtk_override { return str0_base_ptr_->base(); } - std::size_t size() const + std::size_t size() const exprtk_override { return str0_base_ptr_->size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return str0_rng_node_ptr_->range_ref(); } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return str0_rng_node_ptr_->range_ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strass; } @@ -9281,17 +9438,17 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; conditional_string_node(expression_ptr condition, expression_ptr consequent, expression_ptr alternative) - : trinary_node(details::e_default,consequent,alternative,condition) + : trinary_node(details::e_default, consequent, alternative, condition) , initialised_(false) , str0_base_ptr_ (0) , str1_base_ptr_ (0) @@ -9341,7 +9498,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -9393,32 +9550,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return value_; } - char_cptr base() const + char_cptr base() const exprtk_override { return &value_[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return value_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return range_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return range_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strcondition; } @@ -9446,12 +9603,12 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; cons_conditional_str_node(expression_ptr condition, expression_ptr consequent) @@ -9486,7 +9643,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -9544,7 +9701,7 @@ namespace exprtk return range_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strccondition; } @@ -9569,12 +9726,12 @@ namespace exprtk { public: - typedef expression_node * expression_ptr; - typedef string_base_node* str_base_ptr; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef range_t* range_ptr; typedef range_interface irange_t; typedef irange_t* irange_ptr; + typedef expression_node * expression_ptr; + typedef string_base_node* str_base_ptr; typedef std::pair branch_t; template ::quiet_NaN(); } - std::string str() const + std::string str() const exprtk_override { return str_base_ptr_->str(); } - char_cptr base() const + char_cptr base() const exprtk_override { return str_base_ptr_->base(); } - std::size_t size() const + std::size_t size() const exprtk_override { return str_base_ptr_->size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return str_range_ptr_->range_ref(); } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return str_range_ptr_->range_ref(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_stringvararg; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(final_node_ , node_delete_list); expression_node::ndb_t::collect(arg_list_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return std::max( expression_node::ndb_t::compute_node_depth(final_node_), @@ -9714,7 +9871,7 @@ namespace exprtk typedef typename functor_t::ufunc_t unary_functor_t; }; - #define define_sfop3(NN,OP0,OP1) \ + #define define_sfop3(NN, OP0, OP1) \ template \ struct sf##NN##_op : public sf_base \ { \ @@ -9778,7 +9935,7 @@ namespace exprtk define_sfop3(46,x * numeric::cos(y) - z ,"") define_sfop3(47,details::is_true(x) ? y : z,"") - #define define_sfop4(NN,OP0,OP1) \ + #define define_sfop4(NN, OP0, OP1) \ template \ struct sf##NN##_op : public sf_base \ { \ @@ -9927,7 +10084,7 @@ namespace exprtk : trinary_node(opr, branch0, branch1, branch2) {} - inline T value() const + inline T value() const exprtk_override { assert(trinary_node::branch_[0].first); assert(trinary_node::branch_[1].first); @@ -9956,7 +10113,7 @@ namespace exprtk : quaternary_node(opr, branch0, branch1, branch2, branch3) {} - inline T value() const + inline T value() const exprtk_override { assert(quaternary_node::branch_[0].first); assert(quaternary_node::branch_[1].first); @@ -9985,20 +10142,20 @@ namespace exprtk , v2_(v2) {} - inline T value() const + inline T value() const exprtk_override { return SpecialFunction::process(v0_, v1_, v2_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_trinary; } private: - sf3_var_node(sf3_var_node&); - sf3_var_node& operator=(sf3_var_node&); + sf3_var_node(const sf3_var_node&) exprtk_delete; + sf3_var_node& operator=(const sf3_var_node&) exprtk_delete; const T& v0_; const T& v1_; @@ -10019,20 +10176,20 @@ namespace exprtk , v3_(v3) {} - inline T value() const + inline T value() const exprtk_override { return SpecialFunction::process(v0_, v1_, v2_, v3_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_trinary; } private: - sf4_var_node(sf4_var_node&); - sf4_var_node& operator=(sf4_var_node&); + sf4_var_node(const sf4_var_node&) exprtk_delete; + sf4_var_node& operator=(const sf4_var_node&) exprtk_delete; const T& v0_; const T& v1_; @@ -10068,22 +10225,22 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { return VarArgFunction::process(arg_list_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vararg; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(arg_list_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(arg_list_); } @@ -10121,7 +10278,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (!arg_list_.empty()) return VarArgFunction::process(arg_list_); @@ -10129,7 +10286,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vararg; } @@ -10160,7 +10317,7 @@ namespace exprtk ivec_ptr_ = 0; } - inline T value() const + inline T value() const exprtk_override { if (ivec_ptr_) { @@ -10174,17 +10331,17 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecfunc; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(v_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(v_); } @@ -10214,7 +10371,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (var_node_ptr_) { @@ -10254,7 +10411,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (vec_node_ptr_) { @@ -10294,7 +10451,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (rbvec_node_ptr_) { @@ -10334,7 +10491,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (rbvec_node_ptr_) { @@ -10379,7 +10536,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (vec_node_ptr_) { @@ -10439,32 +10596,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return vec_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return vec_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvalass; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -10529,7 +10686,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -10594,32 +10751,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() exprtk_override { return vec0_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() const exprtk_override { return vec0_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvecass; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -10652,7 +10809,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (var_node_ptr_) { @@ -10691,7 +10848,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (vec_node_ptr_) { @@ -10730,7 +10887,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (rbvec_node_ptr_) { @@ -10769,7 +10926,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (rbvec_node_ptr_) { @@ -10813,7 +10970,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if (vec_node_ptr_) { @@ -10864,7 +11021,6 @@ namespace exprtk } exprtk_disable_fallthrough_end - #undef exprtk_loop #undef case_stmt @@ -10874,37 +11030,37 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return vec_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return vec_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecopvalass; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } - bool side_effect() const + bool side_effect() const exprtk_override { return true; } @@ -10963,7 +11119,7 @@ namespace exprtk assert(initialised_); } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -11029,37 +11185,37 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return vec0_node_ptr_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return vec0_node_ptr_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecopvecass; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } - bool side_effect() const + bool side_effect() const exprtk_override { return true; } @@ -11154,7 +11310,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -11222,32 +11378,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvecarith; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds_.size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -11317,7 +11473,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { if (vec0_node_ptr_) { @@ -11383,32 +11539,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvalarith; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -11476,7 +11632,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { if (vec1_node_ptr_) { @@ -11542,32 +11698,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecvalarith; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -11633,7 +11789,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { assert(unary_node::branch_.first); @@ -11697,32 +11853,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecunaryop; } - std::size_t size() const + std::size_t size() const exprtk_override { return vds().size(); } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } @@ -11804,7 +11960,7 @@ namespace exprtk delete temp_vec_node_; } - inline T value() const + inline T value() const exprtk_override { if (initialised_) { @@ -11838,44 +11994,44 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - vector_node_ptr vec() const + vector_node_ptr vec() const exprtk_override { return temp_vec_node_; } - vector_node_ptr vec() + vector_node_ptr vec() exprtk_override { return temp_vec_node_; } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vecondition; } - std::size_t size() const + std::size_t size() const exprtk_override { return vec_size_; } - vds_t& vds() + vds_t& vds() exprtk_override { return vds_; } - const vds_t& vds() const + const vds_t& vds() const exprtk_override { return vds_; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(condition_ , node_delete_list); expression_node::ndb_t::collect(consequent_ , node_delete_list); expression_node::ndb_t::collect(alternative_ , node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth (condition_, consequent_, alternative_); @@ -11908,7 +12064,7 @@ namespace exprtk : binary_node(opr, branch0, branch1) {} - inline T value() const + inline T value() const exprtk_override { assert(binary_node::branch_[0].first); assert(binary_node::branch_[1].first); @@ -11935,7 +12091,7 @@ namespace exprtk : binary_node(opr, branch0, branch1) {} - inline T value() const + inline T value() const exprtk_override { assert(binary_node::branch_[0].first); assert(binary_node::branch_[1].first); @@ -11995,7 +12151,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { // Needed for incompetent and broken msvc compiler versions #ifdef _MSC_VER @@ -12015,17 +12171,17 @@ namespace exprtk #endif } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_function; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::template compute_node_depth(branch_); } @@ -12264,7 +12420,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { if (function_) return (*function_)(); @@ -12272,7 +12428,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_function; } @@ -12302,7 +12458,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { if (function_) { @@ -12313,12 +12469,12 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_vafunction; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { for (std::size_t i = 0; i < arg_list_.size(); ++i) { @@ -12329,7 +12485,7 @@ namespace exprtk } } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(arg_list_); } @@ -12362,7 +12518,7 @@ namespace exprtk typedef vector_node_t* vector_node_ptr_t; typedef range_interface range_interface_t; typedef range_data_type range_data_type_t; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; typedef std::pair branch_t; typedef std::pair void_t; @@ -12377,15 +12533,14 @@ namespace exprtk , arg_list_(arg_list) {} - virtual ~generic_function_node() - {} + virtual ~generic_function_node() {} - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const exprtk_final + std::size_t node_depth() const exprtk_override exprtk_final { return expression_node::ndb_t::compute_node_depth(branch_); } @@ -12481,7 +12636,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { if (function_) { @@ -12496,7 +12651,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_genfunction; } @@ -12560,7 +12715,7 @@ namespace exprtk public: typedef generic_function_node gen_function_t; - typedef range_pack range_t; + typedef typename range_interface::range_t range_t; string_function_node(StringFunction* func, const std::vector& arg_list) @@ -12577,7 +12732,7 @@ namespace exprtk return this < (&fn); } - inline T value() const + inline T value() const exprtk_override { if (gen_function_t::function_) { @@ -12601,32 +12756,32 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strfunction; } - std::string str() const + std::string str() const exprtk_override { return ret_string_; } - char_cptr base() const + char_cptr base() const exprtk_override { return &ret_string_[0]; } - std::size_t size() const + std::size_t size() const exprtk_override { return ret_string_.size(); } - range_t& range_ref() + range_t& range_ref() exprtk_override { return range_; } - const range_t& range_ref() const + const range_t& range_ref() const exprtk_override { return range_; } @@ -12644,7 +12799,7 @@ namespace exprtk public: typedef generic_function_node gen_function_t; - typedef range_pack range_t; + typedef typename gen_function_t::range_t range_t; multimode_genfunction_node(GenericFunction* func, const std::size_t& param_seq_index, @@ -12653,7 +12808,7 @@ namespace exprtk , param_seq_index_(param_seq_index) {} - inline T value() const + inline T value() const exprtk_override { if (gen_function_t::function_) { @@ -12672,7 +12827,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const exprtk_final + inline typename expression_node::node_type type() const exprtk_override exprtk_final { return expression_node::e_genfunction; } @@ -12689,7 +12844,7 @@ namespace exprtk public: typedef string_function_node str_function_t; - typedef range_pack range_t; + typedef typename str_function_t::range_t range_t; multimode_strfunction_node(StringFunction* func, const std::size_t& param_seq_index, @@ -12698,7 +12853,7 @@ namespace exprtk , param_seq_index_(param_seq_index) {} - inline T value() const + inline T value() const exprtk_override { if (str_function_t::function_) { @@ -12723,7 +12878,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_strfunction; } @@ -12742,8 +12897,7 @@ namespace exprtk { public: - virtual ~null_igenfunc() - {} + virtual ~null_igenfunc() {} typedef type_store generic_type; typedef typename generic_type::parameter_list parameter_list_t; @@ -12760,10 +12914,10 @@ namespace exprtk { public: - typedef null_igenfunc igeneric_function_t; + typedef results_context results_context_t; + typedef null_igenfunc igeneric_function_t; typedef igeneric_function_t* igeneric_function_ptr; typedef generic_function_node gen_function_t; - typedef results_context results_context_t; return_node(const std::vector& arg_list, results_context_t& rc) @@ -12771,7 +12925,7 @@ namespace exprtk , results_context_(&rc) {} - inline T value() const + inline T value() const exprtk_override { if ( (0 != results_context_) && @@ -12789,7 +12943,7 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_return; } @@ -12815,7 +12969,7 @@ namespace exprtk construct_branch_pair(body_, body); } - inline T value() const + inline T value() const exprtk_override { assert(body_.first); @@ -12833,7 +12987,7 @@ namespace exprtk } } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_retenv; } @@ -12843,12 +12997,12 @@ namespace exprtk return &return_invoked_; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(body_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(body_); } @@ -14091,8 +14245,7 @@ namespace exprtk { public: - virtual ~vov_base_node() - {} + virtual ~vov_base_node() {} inline virtual operator_type operation() const { @@ -14109,8 +14262,7 @@ namespace exprtk { public: - virtual ~cov_base_node() - {} + virtual ~cov_base_node() {} inline virtual operator_type operation() const { @@ -14127,8 +14279,7 @@ namespace exprtk { public: - virtual ~voc_base_node() - {} + virtual ~voc_base_node() {} inline virtual operator_type operation() const { @@ -14145,8 +14296,7 @@ namespace exprtk { public: - virtual ~vob_base_node() - {} + virtual ~vob_base_node() {} virtual const T& v() const = 0; }; @@ -14156,8 +14306,7 @@ namespace exprtk { public: - virtual ~bov_base_node() - {} + virtual ~bov_base_node() {} virtual const T& v() const = 0; }; @@ -14167,8 +14316,7 @@ namespace exprtk { public: - virtual ~cob_base_node() - {} + virtual ~cob_base_node() {} inline virtual operator_type operation() const { @@ -14187,8 +14335,7 @@ namespace exprtk { public: - virtual ~boc_base_node() - {} + virtual ~boc_base_node() {} inline virtual operator_type operation() const { @@ -14207,8 +14354,7 @@ namespace exprtk { public: - virtual ~uv_base_node() - {} + virtual ~uv_base_node() {} inline virtual operator_type operation() const { @@ -14223,8 +14369,7 @@ namespace exprtk { public: - virtual ~sos_base_node() - {} + virtual ~sos_base_node() {} inline virtual operator_type operation() const { @@ -14237,8 +14382,7 @@ namespace exprtk { public: - virtual ~sosos_base_node() - {} + virtual ~sosos_base_node() {} inline virtual operator_type operation() const { @@ -14251,8 +14395,7 @@ namespace exprtk { public: - virtual ~T0oT1oT2_base_node() - {} + virtual ~T0oT1oT2_base_node() {} virtual std::string type_id() const = 0; }; @@ -14262,8 +14405,7 @@ namespace exprtk { public: - virtual ~T0oT1oT2oT3_base_node() - {} + virtual ~T0oT1oT2oT3_base_node() {} virtual std::string type_id() const = 0; }; @@ -14280,30 +14422,30 @@ namespace exprtk : v_(var) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(v_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } private: - unary_variable_node(unary_variable_node&); - unary_variable_node& operator=(unary_variable_node&); + unary_variable_node(const unary_variable_node&) exprtk_delete; + unary_variable_node& operator=(const unary_variable_node&) exprtk_delete; const T& v_; }; @@ -14328,21 +14470,16 @@ namespace exprtk , f_ (bf ) {} - inline T value() const + inline T value() const exprtk_override { return f_(u0_(v0_),u1_(v1_)); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_uvouv; } - inline operator_type operation() const - { - return details::e_default; - } - inline const T& v0() { return v0_; @@ -14370,8 +14507,8 @@ namespace exprtk private: - uvouv_node(uvouv_node&); - uvouv_node& operator=(uvouv_node&); + uvouv_node(const uvouv_node&) exprtk_delete; + uvouv_node& operator=(const uvouv_node&) exprtk_delete; const T& v0_; const T& v1_; @@ -14385,31 +14522,31 @@ namespace exprtk { public: - typedef expression_node* expression_ptr; + typedef Operation operation_t; + typedef expression_node* expression_ptr; typedef std::pair branch_t; - typedef Operation operation_t; explicit unary_branch_node(expression_ptr branch) { construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { return Operation::process(branch_.first->value()); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() { return Operation::operation(); } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } @@ -14419,20 +14556,20 @@ namespace exprtk branch_.second = false; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - unary_branch_node(unary_branch_node&); - unary_branch_node& operator=(unary_branch_node&); + unary_branch_node(const unary_branch_node&) exprtk_delete; + unary_branch_node& operator=(const unary_branch_node&) exprtk_delete; branch_t branch_; }; @@ -14615,7 +14752,7 @@ namespace exprtk template const typename expression_node::node_type nodetype_T0oT1::result = expression_node::e_none; - #define synthesis_node_type_define(T0_,T1_,v_) \ + #define synthesis_node_type_define(T0_, T1_, v_) \ template \ struct nodetype_T0oT1 { static const typename expression_node::node_type result; }; \ template \ @@ -14637,7 +14774,7 @@ namespace exprtk template const typename expression_node::node_type nodetype_T0oT1oT2::result = expression_node::e_none; - #define synthesis_node_type_define(T0_,T1_,T2_,v_) \ + #define synthesis_node_type_define(T0_, T1_, T2_, v_) \ template \ struct nodetype_T0oT1oT2 { static const typename expression_node::node_type result; }; \ template \ @@ -14659,7 +14796,7 @@ namespace exprtk template const typename expression_node::node_type nodetype_T0oT1oT2oT3::result = expression_node::e_none; - #define synthesis_node_type_define(T0_,T1_,T2_,T3_,v_) \ + #define synthesis_node_type_define(T0_, T1_, T2_, T3_, v_) \ template \ struct nodetype_T0oT1oT2oT3 { static const typename expression_node::node_type result; }; \ template \ @@ -14699,18 +14836,18 @@ namespace exprtk , f_ (p2) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1::result; return result; } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return e_default; } - inline T value() const + inline T value() const exprtk_override { return f_(t0_,t1_); } @@ -14742,8 +14879,8 @@ namespace exprtk private: - T0oT1(T0oT1&) {} - T0oT1& operator=(T0oT1&) { return (*this); } + T0oT1(const T0oT1&) exprtk_delete; + T0oT1& operator=(const T0oT1&) { return (*this); } T0 t0_; T1 t1_; @@ -14769,18 +14906,18 @@ namespace exprtk , f1_(p4) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; return result; } - inline operator_type operation() const + inline operator_type operation() { return e_default; } - inline T value() const + inline T value() const exprtk_override { return ProcessMode::process(t0_, t1_, t2_, f0_, f1_); } @@ -14810,7 +14947,7 @@ namespace exprtk return f1_; } - std::string type_id() const + std::string type_id() const exprtk_override { return id(); } @@ -14830,8 +14967,8 @@ namespace exprtk private: - T0oT1oT2(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -14865,7 +15002,7 @@ namespace exprtk , f2_(p6) {} - inline T value() const + inline T value() const exprtk_override { return ProcessMode::process(t0_, t1_, t2_, t3_, f0_, f1_, f2_); } @@ -14905,7 +15042,7 @@ namespace exprtk return f2_; } - inline std::string type_id() const + inline std::string type_id() const exprtk_override { return id(); } @@ -14927,8 +15064,8 @@ namespace exprtk private: - T0oT1oT2oT3(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2oT3(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -14956,18 +15093,18 @@ namespace exprtk , f_ (p3) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; return result; } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return e_default; } - inline T value() const + inline T value() const exprtk_override { return f_(t0_, t1_, t2_); } @@ -15012,8 +15149,8 @@ namespace exprtk private: - T0oT1oT2_sf3(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2_sf3(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -15026,8 +15163,7 @@ namespace exprtk { public: - virtual ~sf3ext_type_node() - {} + virtual ~sf3ext_type_node() {} virtual T0 t0() const = 0; @@ -15044,7 +15180,7 @@ namespace exprtk typedef typename details::functor_t functor_t; typedef typename functor_t::tfunc_t tfunc_t; typedef T value_type; - typedef T0oT1oT2_sf3ext node_type; + typedef T0oT1oT2_sf3ext node_type; T0oT1oT2_sf3ext(T0 p0, T1 p1, T2 p2) : t0_(p0) @@ -15052,38 +15188,38 @@ namespace exprtk , t2_(p2) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2::result; return result; } - inline operator_type operation() const + inline operator_type operation() { return e_default; } - inline T value() const + inline T value() const exprtk_override { return SF3Operation::process(t0_, t1_, t2_); } - T0 t0() const + T0 t0() const exprtk_override { return t0_; } - T1 t1() const + T1 t1() const exprtk_override { return t1_; } - T2 t2() const + T2 t2() const exprtk_override { return t2_; } - std::string type_id() const + std::string type_id() const exprtk_override { return id(); } @@ -15103,8 +15239,8 @@ namespace exprtk private: - T0oT1oT2_sf3ext(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2_sf3ext(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -15133,7 +15269,7 @@ namespace exprtk typedef typename details::functor_t functor_t; typedef typename functor_t::qfunc_t qfunc_t; typedef T value_type; - typedef T0oT1oT2oT3_sf4 node_type; + typedef T0oT1oT2oT3_sf4 node_type; T0oT1oT2oT3_sf4(T0 p0, T1 p1, T2 p2, T3 p3, const qfunc_t p4) : t0_(p0) @@ -15143,18 +15279,18 @@ namespace exprtk , f_ (p4) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2oT3::result; return result; } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return e_default; } - inline T value() const + inline T value() const exprtk_override { return f_(t0_, t1_, t2_, t3_); } @@ -15204,8 +15340,8 @@ namespace exprtk private: - T0oT1oT2oT3_sf4(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2oT3_sf4(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -15222,7 +15358,7 @@ namespace exprtk typedef typename details::functor_t functor_t; typedef typename functor_t::tfunc_t tfunc_t; typedef T value_type; - typedef T0oT1oT2oT3_sf4ext node_type; + typedef T0oT1oT2oT3_sf4ext node_type; T0oT1oT2oT3_sf4ext(T0 p0, T1 p1, T2 p2, T3 p3) : t0_(p0) @@ -15231,18 +15367,13 @@ namespace exprtk , t3_(p3) {} - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { static const typename expression_node::node_type result = nodetype_T0oT1oT2oT3::result; return result; } - inline operator_type operation() const - { - return e_default; - } - - inline T value() const + inline T value() const exprtk_override { return SF4Operation::process(t0_, t1_, t2_, t3_); } @@ -15267,7 +15398,7 @@ namespace exprtk return t3_; } - std::string type_id() const + std::string type_id() const exprtk_override { return id(); } @@ -15287,8 +15418,8 @@ namespace exprtk private: - T0oT1oT2oT3_sf4ext(node_type&) {} - node_type& operator=(node_type&) { return (*this); } + T0oT1oT2oT3_sf4ext(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) { return (*this); } T0 t0_; T1 t1_; @@ -15354,27 +15485,27 @@ namespace exprtk , v1_(var1) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(v0_,v1_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T& v0() const + inline const T& v0() const exprtk_override { return v0_; } - inline const T& v1() const + inline const T& v1() const exprtk_override { return v1_; } @@ -15386,8 +15517,8 @@ namespace exprtk private: - vov_node(vov_node&); - vov_node& operator=(vov_node&); + vov_node(const vov_node&) exprtk_delete; + vov_node& operator=(const vov_node&) exprtk_delete; }; template @@ -15404,27 +15535,27 @@ namespace exprtk , v_(var) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(c_,v_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T c() const + inline const T c() const exprtk_override { return c_; } - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } @@ -15436,8 +15567,8 @@ namespace exprtk private: - cov_node(const cov_node&); - cov_node& operator=(const cov_node&); + cov_node(const cov_node&) exprtk_delete; + cov_node& operator=(const cov_node&) exprtk_delete; }; template @@ -15454,22 +15585,22 @@ namespace exprtk , c_(const_var) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(v_,c_); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T c() const + inline const T c() const exprtk_override { return c_; } - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } @@ -15481,8 +15612,8 @@ namespace exprtk private: - voc_node(const voc_node&); - voc_node& operator=(const voc_node&); + voc_node(const voc_node&) exprtk_delete; + voc_node& operator=(const voc_node&) exprtk_delete; }; template @@ -15501,41 +15632,36 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return Operation::process(v_,branch_.first->value()); } - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - vob_node(const vob_node&); - vob_node& operator=(const vob_node&); + vob_node(const vob_node&) exprtk_delete; + vob_node& operator=(const vob_node&) exprtk_delete; const T& v_; branch_t branch_; @@ -15557,41 +15683,36 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return Operation::process(branch_.first->value(),v_); } - inline operator_type operation() const - { - return Operation::operation(); - } - - inline const T& v() const + inline const T& v() const exprtk_override { return v_; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - bov_node(const bov_node&); - bov_node& operator=(const bov_node&); + bov_node(const bov_node&) exprtk_delete; + bov_node& operator=(const bov_node&) exprtk_delete; const T& v_; branch_t branch_; @@ -15613,52 +15734,52 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return Operation::process(c_,branch_.first->value()); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T c() const + inline const T c() const exprtk_override { return c_; } - inline void set_c(const T new_c) + inline void set_c(const T new_c) exprtk_override { (*const_cast(&c_)) = new_c; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - inline expression_node* move_branch(const std::size_t&) + inline expression_node* move_branch(const std::size_t&) exprtk_override { branch_.second = false; return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - cob_node(const cob_node&); - cob_node& operator=(const cob_node&); + cob_node(const cob_node&) exprtk_delete; + cob_node& operator=(const cob_node&) exprtk_delete; const T c_; branch_t branch_; @@ -15680,52 +15801,52 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return Operation::process(branch_.first->value(),c_); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } - inline const T c() const + inline const T c() const exprtk_override { return c_; } - inline void set_c(const T new_c) + inline void set_c(const T new_c) exprtk_override { (*const_cast(&c_)) = new_c; } - inline expression_node* branch(const std::size_t&) const + inline expression_node* branch(const std::size_t&) const exprtk_override { return branch_.first; } - inline expression_node* move_branch(const std::size_t&) + inline expression_node* move_branch(const std::size_t&) exprtk_override { branch_.second = false; return branch_.first; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - boc_node(const boc_node&); - boc_node& operator=(const boc_node&); + boc_node(const boc_node&) exprtk_delete; + boc_node& operator=(const boc_node&) exprtk_delete; const T c_; branch_t branch_; @@ -15746,17 +15867,17 @@ namespace exprtk , s1_(p1) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(s0_,s1_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -15778,8 +15899,8 @@ namespace exprtk private: - sos_node(sos_node&); - sos_node& operator=(sos_node&); + sos_node(const sos_node&) exprtk_delete; + sos_node& operator=(const sos_node&) exprtk_delete; }; template @@ -15789,6 +15910,7 @@ namespace exprtk typedef expression_node* expression_ptr; typedef Operation operation_t; + typedef str_xrox_node node_type; // string-range op string node explicit str_xrox_node(SType0 p0, SType1 p1, RangePack rp0) @@ -15802,7 +15924,7 @@ namespace exprtk rp0_.free(); } - inline T value() const + inline T value() const exprtk_override { std::size_t r0 = 0; std::size_t r1 = 0; @@ -15813,12 +15935,12 @@ namespace exprtk return T(0); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -15841,8 +15963,8 @@ namespace exprtk private: - str_xrox_node(str_xrox_node&); - str_xrox_node& operator=(str_xrox_node&); + str_xrox_node(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) exprtk_delete; }; template @@ -15852,6 +15974,7 @@ namespace exprtk typedef expression_node* expression_ptr; typedef Operation operation_t; + typedef str_xoxr_node node_type; // string op string range node explicit str_xoxr_node(SType0 p0, SType1 p1, RangePack rp1) @@ -15865,7 +15988,7 @@ namespace exprtk rp1_.free(); } - inline T value() const + inline T value() const exprtk_override { std::size_t r0 = 0; std::size_t r1 = 0; @@ -15876,12 +15999,12 @@ namespace exprtk return T(0); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -15904,8 +16027,8 @@ namespace exprtk private: - str_xoxr_node(str_xoxr_node&); - str_xoxr_node& operator=(str_xoxr_node&); + str_xoxr_node(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) exprtk_delete; }; template @@ -15915,6 +16038,7 @@ namespace exprtk typedef expression_node* expression_ptr; typedef Operation operation_t; + typedef str_xroxr_node node_type; // string-range op string-range node explicit str_xroxr_node(SType0 p0, SType1 p1, RangePack rp0, RangePack rp1) @@ -15930,7 +16054,7 @@ namespace exprtk rp1_.free(); } - inline T value() const + inline T value() const exprtk_override { std::size_t r0_0 = 0; std::size_t r0_1 = 0; @@ -15951,12 +16075,12 @@ namespace exprtk return T(0); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -15980,8 +16104,8 @@ namespace exprtk private: - str_xroxr_node(str_xroxr_node&); - str_xroxr_node& operator=(str_xroxr_node&); + str_xroxr_node(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) exprtk_delete; }; template @@ -16036,7 +16160,7 @@ namespace exprtk } } - inline T value() const + inline T value() const exprtk_override { if ( str0_base_ptr_ && @@ -16072,20 +16196,15 @@ namespace exprtk return std::numeric_limits::quiet_NaN(); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const - { - return Operation::operation(); - } - private: - str_sogens_node(str_sogens_node&); - str_sogens_node& operator=(str_sogens_node&); + str_sogens_node(const str_sogens_node&) exprtk_delete; + str_sogens_node& operator=(const str_sogens_node&) exprtk_delete; str_base_ptr str0_base_ptr_; str_base_ptr str1_base_ptr_; @@ -16100,6 +16219,7 @@ namespace exprtk typedef expression_node* expression_ptr; typedef Operation operation_t; + typedef sosos_node node_type; // variable op variable node explicit sosos_node(SType0 p0, SType1 p1, SType2 p2) @@ -16108,17 +16228,17 @@ namespace exprtk , s2_(p2) {} - inline T value() const + inline T value() const exprtk_override { return Operation::process(s0_, s1_, s2_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return Operation::type(); } - inline operator_type operation() const + inline operator_type operation() const exprtk_override { return Operation::operation(); } @@ -16146,8 +16266,8 @@ namespace exprtk private: - sosos_node(sosos_node&); - sosos_node& operator=(sosos_node&); + sosos_node(const node_type&) exprtk_delete; + node_type& operator=(const node_type&) exprtk_delete; }; #endif @@ -16163,20 +16283,20 @@ namespace exprtk : v_(v) {} - inline T value() const + inline T value() const exprtk_override { return PowOp::result(v_); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_ipow; } private: - ipow_node(const ipow_node&); - ipow_node& operator=(const ipow_node&); + ipow_node(const ipow_node&) exprtk_delete; + ipow_node& operator=(const ipow_node&) exprtk_delete; const T& v_; }; @@ -16195,31 +16315,31 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return PowOp::result(branch_.first->value()); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_ipow; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - bipow_node(const bipow_node&); - bipow_node& operator=(const bipow_node&); + bipow_node(const bipow_node&) exprtk_delete; + bipow_node& operator=(const bipow_node&) exprtk_delete; branch_t branch_; }; @@ -16236,20 +16356,20 @@ namespace exprtk : v_(v) {} - inline T value() const + inline T value() const exprtk_override { return (T(1) / PowOp::result(v_)); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_ipowinv; } private: - ipowinv_node(const ipowinv_node&); - ipowinv_node& operator=(const ipowinv_node&); + ipowinv_node(const ipowinv_node&) exprtk_delete; + ipowinv_node& operator=(const ipowinv_node&) exprtk_delete; const T& v_; }; @@ -16268,31 +16388,31 @@ namespace exprtk construct_branch_pair(branch_, branch); } - inline T value() const + inline T value() const exprtk_override { assert(branch_.first); return (T(1) / PowOp::result(branch_.first->value())); } - inline typename expression_node::node_type type() const + inline typename expression_node::node_type type() const exprtk_override { return expression_node::e_ipowinv; } - void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) + void collect_nodes(typename expression_node::noderef_list_t& node_delete_list) exprtk_override { expression_node::ndb_t::template collect(branch_, node_delete_list); } - std::size_t node_depth() const + std::size_t node_depth() const exprtk_override { return expression_node::ndb_t::compute_node_depth(branch_); } private: - bipowninv_node(const bipowninv_node&); - bipowninv_node& operator=(const bipowninv_node&); + bipowninv_node(const bipowninv_node&) exprtk_delete; + bipowninv_node& operator=(const bipowninv_node&) exprtk_delete; branch_t branch_; }; @@ -16824,7 +16944,7 @@ namespace exprtk inline void load_operations_map(std::multimap& m) { - #define register_op(Symbol,Type,Args) \ + #define register_op(Symbol, Type, Args) \ m.insert(std::make_pair(std::string(Symbol),details::base_operation_t(Type,Args))); \ register_op("abs" , e_abs , 1) @@ -16976,8 +17096,7 @@ namespace exprtk : param_count(pc) {} - virtual ~ifunction() - {} + virtual ~ifunction() {} #define empty_method_body(N) \ { \ @@ -17068,8 +17187,7 @@ namespace exprtk { public: - virtual ~ivararg_function() - {} + virtual ~ivararg_function() {} inline virtual T operator() (const std::vector&) { @@ -17099,8 +17217,7 @@ namespace exprtk , rtrn_type(rtr_type) {} - virtual ~igeneric_function() - {} + virtual ~igeneric_function() {} #define igeneric_function_empty_body(N) \ { \ @@ -17128,6 +17245,43 @@ namespace exprtk return_type rtrn_type; }; + #ifndef exprtk_disable_string_capabilities + template + class stringvar_base + { + public: + + typedef typename details::stringvar_node stringvar_node_t; + + stringvar_base(const std::string& name, stringvar_node_t* svn) + : name_(name) + , string_varnode_(svn) + {} + + bool valid() const + { + return !name_.empty() && (0 != string_varnode_); + } + + std::string name() const + { + assert(string_varnode_); + return name_; + } + + void rebase(std::string& s) + { + assert(string_varnode_); + string_varnode_->rebase(s); + } + + private: + + std::string name_; + stringvar_node_t* string_varnode_; + }; + #endif + template class parser; template class expression_helper; @@ -17974,6 +18128,24 @@ namespace exprtk else return local_data().stringvar_store.get(string_name); } + + inline stringvar_base get_stringvar_base(const std::string& string_name) const + { + static stringvar_base null_stringvar_base("",reinterpret_cast(0)); + if (!valid()) + return null_stringvar_base; + else if (!valid_symbol(string_name)) + return null_stringvar_base; + + stringvar_ptr stringvar = local_data().stringvar_store.get(string_name); + + if (0 == stringvar) + { + return null_stringvar_base; + } + + return stringvar_base(string_name,stringvar); + } #endif inline function_ptr get_function(const std::string& function_name) const @@ -18732,7 +18904,7 @@ namespace exprtk control_block* control_block_; friend class parser; - }; + }; // class symbol_table template class function_compositor; @@ -18743,8 +18915,8 @@ namespace exprtk private: typedef details::expression_node* expression_ptr; - typedef details::vector_holder* vector_holder_ptr; - typedef std::vector > symtab_list_t; + typedef details::vector_holder* vector_holder_ptr; + typedef std::vector > symtab_list_t; struct control_block { @@ -19106,7 +19278,7 @@ namespace exprtk friend class parser; friend class expression_helper; friend class function_compositor; - }; + }; // class expression template class expression_helper @@ -19315,10 +19487,16 @@ namespace exprtk typedef details::while_loop_node while_loop_node_t; typedef details::repeat_until_loop_node repeat_until_loop_node_t; typedef details::for_loop_node for_loop_node_t; + typedef details::while_loop_rtc_node while_loop_rtc_node_t; + typedef details::repeat_until_loop_rtc_node repeat_until_loop_rtc_node_t; + typedef details::for_loop_rtc_node for_loop_rtc_node_t; #ifndef exprtk_disable_break_continue typedef details::while_loop_bc_node while_loop_bc_node_t; typedef details::repeat_until_loop_bc_node repeat_until_loop_bc_node_t; typedef details::for_loop_bc_node for_loop_bc_node_t; + typedef details::while_loop_bc_rtc_node while_loop_bc_rtc_node_t; + typedef details::repeat_until_loop_bc_rtc_node repeat_until_loop_bc_rtc_node_t; + typedef details::for_loop_bc_rtc_node for_loop_bc_rtc_node_t; #endif typedef details::switch_node switch_node_t; typedef details::variable_node variable_node_t; @@ -19356,10 +19534,10 @@ namespace exprtk typedef details::vector_holder* vector_holder_ptr; typedef typename details::functor_t functor_t; - typedef typename functor_t::qfunc_t quaternary_functor_t; - typedef typename functor_t::tfunc_t trinary_functor_t; - typedef typename functor_t::bfunc_t binary_functor_t; - typedef typename functor_t::ufunc_t unary_functor_t; + typedef typename functor_t::qfunc_t quaternary_functor_t; + typedef typename functor_t::tfunc_t trinary_functor_t; + typedef typename functor_t::bfunc_t binary_functor_t; + typedef typename functor_t::ufunc_t unary_functor_t; typedef details::operator_type operator_t; @@ -19678,7 +19856,8 @@ namespace exprtk private: - scope_element_manager& operator=(const scope_element_manager&); + scope_element_manager(const scope_element_manager&) exprtk_delete; + scope_element_manager& operator=(const scope_element_manager&) exprtk_delete; parser_t& parser_; std::vector element_; @@ -19718,7 +19897,8 @@ namespace exprtk private: - scope_handler& operator=(const scope_handler&); + scope_handler(const scope_handler&) exprtk_delete; + scope_handler& operator=(const scope_handler&) exprtk_delete; parser_t& parser_; }; @@ -19756,7 +19936,8 @@ namespace exprtk private: - stack_limit_handler& operator=(const stack_limit_handler&); + stack_limit_handler(const stack_limit_handler&) exprtk_delete; + stack_limit_handler& operator=(const stack_limit_handler&) exprtk_delete; parser_t& parser_; bool limit_exceeded_; @@ -19766,14 +19947,14 @@ namespace exprtk { symbol_table_list_t symtab_list_; - typedef typename symbol_table_t::local_data_t local_data_t; - typedef typename symbol_table_t::variable_ptr variable_ptr; - typedef typename symbol_table_t::function_ptr function_ptr; + typedef typename symbol_table_t::local_data_t local_data_t; + typedef typename symbol_table_t::variable_ptr variable_ptr; + typedef typename symbol_table_t::function_ptr function_ptr; #ifndef exprtk_disable_string_capabilities typedef typename symbol_table_t::stringvar_ptr stringvar_ptr; #endif - typedef typename symbol_table_t::vector_holder_ptr vector_holder_ptr; - typedef typename symbol_table_t::vararg_function_ptr vararg_function_ptr; + typedef typename symbol_table_t::vector_holder_ptr vector_holder_ptr; + typedef typename symbol_table_t::vararg_function_ptr vararg_function_ptr; typedef typename symbol_table_t::generic_function_ptr generic_function_ptr; inline bool empty() const @@ -20262,8 +20443,7 @@ namespace exprtk : mode(m) {} - virtual ~unknown_symbol_resolver() - {} + virtual ~unknown_symbol_resolver() {} virtual bool process(const std::string& /*unknown_symbol*/, usr_symbol_type& st, @@ -21134,8 +21314,7 @@ namespace exprtk expression_generator_.set_strength_reduction_state(settings_.strength_reduction_enabled()); } - ~parser() - {} + ~parser() {} inline void init_precompilation() { @@ -21300,11 +21479,8 @@ namespace exprtk inline expression_t compile(const std::string& expression_string, symbol_table_t& symtab) { expression_t expression; - expression.register_symbol_table(symtab); - compile(expression_string,expression); - return expression; } @@ -21373,7 +21549,7 @@ namespace exprtk if (helper_assembly_.error_token_scanner) { lexer::helper::bracket_checker* bracket_checker_ptr = 0; - lexer::helper::numeric_checker* numeric_checker_ptr = 0; + lexer::helper::numeric_checker* numeric_checker_ptr = 0; lexer::helper::sequence_validator* sequence_validator_ptr = 0; lexer::helper::sequence_validator_3tokens* sequence_validator3_ptr = 0; @@ -21385,7 +21561,7 @@ namespace exprtk "ERR005 - Mismatched brackets: '" + bracket_checker_ptr->error_token().value + "'", exprtk_error_location)); } - else if (0 != (numeric_checker_ptr = dynamic_cast(helper_assembly_.error_token_scanner))) + else if (0 != (numeric_checker_ptr = dynamic_cast*>(helper_assembly_.error_token_scanner))) { for (std::size_t i = 0; i < numeric_checker_ptr->error_count(); ++i) { @@ -21625,7 +21801,7 @@ namespace exprtk scoped_vec_delete sdd((*this),arg_list); lexer::token begin_token; - lexer::token end_token; + lexer::token end_token; for ( ; ; ) { @@ -22088,7 +22264,8 @@ namespace exprtk private: - scoped_expression_delete& operator=(const scoped_expression_delete&); + scoped_expression_delete(const scoped_expression_delete&) exprtk_delete; + scoped_expression_delete& operator=(const scoped_expression_delete&) exprtk_delete; }; template @@ -22125,7 +22302,8 @@ namespace exprtk private: - scoped_delete& operator=(const scoped_delete&); + scoped_delete(const scoped_delete&) exprtk_delete; + scoped_delete& operator=(const scoped_delete&) exprtk_delete; }; template @@ -22158,7 +22336,8 @@ namespace exprtk private: - scoped_deq_delete& operator=(const scoped_deq_delete&); + scoped_deq_delete(const scoped_deq_delete&) exprtk_delete; + scoped_deq_delete& operator=(const scoped_deq_delete&) exprtk_delete; }; template @@ -22191,7 +22370,8 @@ namespace exprtk private: - scoped_vec_delete& operator=(const scoped_vec_delete&); + scoped_vec_delete(const scoped_vec_delete&) exprtk_delete; + scoped_vec_delete& operator=(const scoped_vec_delete&) exprtk_delete; }; struct scoped_bool_negator @@ -22867,20 +23047,22 @@ namespace exprtk } else if (token_is(token_t::e_rbracket)) { - // 00. if (x) y; - // 01. if (x) y; else z; - // 02. if (x) y; else {z0; ... zn;} - // 03. if (x) y; else if (z) w; - // 04. if (x) y; else if (z) w; else u; - // 05. if (x) y; else if (z) w; else {u0; ... un;} - // 06. if (x) y; else if (z) {w0; ... wn;} - // 07. if (x) {y0; ... yn;} - // 08. if (x) {y0; ... yn;} else z; - // 09. if (x) {y0; ... yn;} else {z0; ... zn;}; - // 10. if (x) {y0; ... yn;} else if (z) w; - // 11. if (x) {y0; ... yn;} else if (z) w; else u; - // 12. if (x) {y0; ... nex;} else if (z) w; else {u0 ... un;} - // 13. if (x) {y0; ... yn;} else if (z) {w0; ... wn;} + /* + 00. if (x) y; + 01. if (x) y; else z; + 02. if (x) y; else {z0; ... zn;} + 03. if (x) y; else if (z) w; + 04. if (x) y; else if (z) w; else u; + 05. if (x) y; else if (z) w; else {u0; ... un;} + 06. if (x) y; else if (z) {w0; ... wn;} + 07. if (x) {y0; ... yn;} + 08. if (x) {y0; ... yn;} else z; + 09. if (x) {y0; ... yn;} else {z0; ... zn;}; + 10. if (x) {y0; ... yn;} else if (z) w; + 11. if (x) {y0; ... yn;} else if (z) w; else u; + 12. if (x) {y0; ... nex;} else if (z) w; else {u0 ... un;} + 13. if (x) {y0; ... yn;} else if (z) {w0; ... wn;} + */ return parse_conditional_statement_02(condition); } @@ -24898,8 +25080,8 @@ namespace exprtk } } - type_checker(const type_checker&); - type_checker& operator=(const type_checker&); + type_checker(const type_checker&) exprtk_delete; + type_checker& operator=(const type_checker&) exprtk_delete; bool invalid_state_; parser_t& parser_; @@ -26504,7 +26686,7 @@ namespace exprtk { bool implied_mul = false; - if (is_generally_string_node(branch)) + if (details::is_generally_string_node(branch)) return true; const lexer::parser_helper::token_advance_mode hold = prsrhlpr_t::e_hold; @@ -26880,83 +27062,85 @@ namespace exprtk static const std::string symbol_return = "return" ; static const std::string symbol_not = "not" ; - if (valid_vararg_operation(current_token().value)) + const std::string symbol = current_token().value; + + if (valid_vararg_operation(symbol)) { return parse_vararg_function(); } - else if (details::imatch(current_token().value, symbol_not)) + else if (details::imatch(symbol, symbol_not)) { return parse_not_statement(); } - else if (valid_base_operation(current_token().value)) + else if (valid_base_operation(symbol)) { return parse_base_operation(); } else if ( - details::imatch(current_token().value, symbol_if) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_if) && + settings_.control_struct_enabled(symbol) ) { return parse_conditional_statement(); } else if ( - details::imatch(current_token().value, symbol_while) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_while) && + settings_.control_struct_enabled(symbol) ) { return parse_while_loop(); } else if ( - details::imatch(current_token().value, symbol_repeat) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_repeat) && + settings_.control_struct_enabled(symbol) ) { return parse_repeat_until_loop(); } else if ( - details::imatch(current_token().value, symbol_for) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_for) && + settings_.control_struct_enabled(symbol) ) { return parse_for_loop(); } else if ( - details::imatch(current_token().value, symbol_switch) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_switch) && + settings_.control_struct_enabled(symbol) ) { return parse_switch_statement(); } - else if (details::is_valid_sf_symbol(current_token().value)) + else if (details::is_valid_sf_symbol(symbol)) { return parse_special_function(); } - else if (details::imatch(current_token().value, symbol_null)) + else if (details::imatch(symbol, symbol_null)) { return parse_null_statement(); } #ifndef exprtk_disable_break_continue - else if (details::imatch(current_token().value, symbol_break)) + else if (details::imatch(symbol, symbol_break)) { return parse_break_statement(); } - else if (details::imatch(current_token().value, symbol_continue)) + else if (details::imatch(symbol, symbol_continue)) { return parse_continue_statement(); } #endif - else if (details::imatch(current_token().value, symbol_var)) + else if (details::imatch(symbol, symbol_var)) { return parse_define_var_statement(); } - else if (details::imatch(current_token().value, symbol_swap)) + else if (details::imatch(symbol, symbol_swap)) { return parse_swap_statement(); } #ifndef exprtk_disable_return_statement else if ( - details::imatch(current_token().value, symbol_return) && - settings_.control_struct_enabled(current_token().value) + details::imatch(symbol, symbol_return) && + settings_.control_struct_enabled(symbol) ) { return parse_return_statement(); @@ -26971,7 +27155,7 @@ namespace exprtk set_error( make_error(parser_error::e_symtab, current_token(), - "ERR202 - Variable or function detected, yet symbol-table is invalid, Symbol: " + current_token().value, + "ERR202 - Variable or function detected, yet symbol-table is invalid, Symbol: " + symbol, exprtk_error_location)); return error_node(); @@ -27046,13 +27230,13 @@ namespace exprtk "ERR205 - Expected ')' instead of: '" + current_token().value + "'", exprtk_error_location)); - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } else if (!post_bracket_process(token_t::e_lbracket,branch)) { - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } @@ -27071,13 +27255,13 @@ namespace exprtk "ERR206 - Expected ']' instead of: '" + current_token().value + "'", exprtk_error_location)); - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } else if (!post_bracket_process(token_t::e_lsqrbracket,branch)) { - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } @@ -27096,13 +27280,13 @@ namespace exprtk "ERR207 - Expected '}' instead of: '" + current_token().value + "'", exprtk_error_location)); - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } else if (!post_bracket_process(token_t::e_lcrlbracket,branch)) { - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } @@ -27124,7 +27308,7 @@ namespace exprtk if (0 == result) { - free_node(node_allocator_,branch); + details::free_node(node_allocator_,branch); return error_node(); } @@ -28055,9 +28239,9 @@ namespace exprtk { if ((0 == condition) || (0 == consequent)) { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, consequent ); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent ); + details::free_node(*node_allocator_, alternative); return error_node(); } @@ -28067,16 +28251,16 @@ namespace exprtk // True branch if (details::is_true(condition)) { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, alternative); return consequent; } // False branch else { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, consequent); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent); if (alternative) return alternative; @@ -28101,9 +28285,9 @@ namespace exprtk { if ((0 == condition) || (0 == consequent)) { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, consequent ); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent ); + details::free_node(*node_allocator_, alternative); return error_node(); } @@ -28113,16 +28297,16 @@ namespace exprtk // True branch if (details::is_true(condition)) { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, alternative); return consequent; } // False branch else { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, consequent); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent); if (alternative) return alternative; @@ -28152,9 +28336,9 @@ namespace exprtk { if ((0 == condition) || (0 == consequent)) { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, consequent ); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent ); + details::free_node(*node_allocator_, alternative); return error_node(); } @@ -28164,16 +28348,16 @@ namespace exprtk // True branch if (details::is_true(condition)) { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, alternative); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, alternative); return consequent; } // False branch else { - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, consequent); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, consequent); if (alternative) return alternative; @@ -28206,9 +28390,9 @@ namespace exprtk inline expression_node_ptr while_loop(expression_node_ptr& condition, expression_node_ptr& branch, - const bool brkcont = false) const + const bool break_continue_present = false) const { - if (!brkcont && details::is_constant_node(condition)) + if (!break_continue_present && details::is_constant_node(condition)) { expression_node_ptr result = error_node(); if (details::is_true(condition)) @@ -28217,32 +28401,39 @@ namespace exprtk else result = node_allocator_->allocate >(); - free_node(*node_allocator_, condition); - free_node(*node_allocator_, branch ); + details::free_node(*node_allocator_, condition); + details::free_node(*node_allocator_, branch ); return result; } else if (details::is_null_node(condition)) { - free_node(*node_allocator_,condition); + details::free_node(*node_allocator_,condition); return branch; } - else if (!brkcont) - return node_allocator_->allocate - ( - condition, - branch, - get_loop_runtime_check(loop_runtime_check::e_while_loop) - ); + + loop_runtime_check_ptr rtc = get_loop_runtime_check(loop_runtime_check::e_while_loop); + + if (!break_continue_present) + { + if (rtc) + return node_allocator_->allocate + (condition, branch, rtc); + else + return node_allocator_->allocate + (condition, branch); + } #ifndef exprtk_disable_break_continue else - return node_allocator_->allocate - ( - condition, - branch, - get_loop_runtime_check(loop_runtime_check::e_while_loop) - ); + { + if (rtc) + return node_allocator_->allocate + (condition, branch, rtc); + else + return node_allocator_->allocate + (condition, branch); + } #else return error_node(); #endif @@ -28250,9 +28441,9 @@ namespace exprtk inline expression_node_ptr repeat_until_loop(expression_node_ptr& condition, expression_node_ptr& branch, - const bool brkcont = false) const + const bool break_continue_present = false) const { - if (!brkcont && details::is_constant_node(condition)) + if (!break_continue_present && details::is_constant_node(condition)) { if ( details::is_true(condition) && @@ -28264,32 +28455,39 @@ namespace exprtk return branch; } - free_node(*node_allocator_, condition); - free_node(*node_allocator_, branch ); + details::free_node(*node_allocator_, condition); + details::free_node(*node_allocator_, branch ); return error_node(); } else if (details::is_null_node(condition)) { - free_node(*node_allocator_,condition); + details::free_node(*node_allocator_,condition); return branch; } - else if (!brkcont) - return node_allocator_->allocate - ( - condition, - branch, - get_loop_runtime_check(loop_runtime_check::e_repeat_until_loop) - ); + + loop_runtime_check_ptr rtc = get_loop_runtime_check(loop_runtime_check::e_repeat_until_loop); + + if (!break_continue_present) + { + if (rtc) + return node_allocator_->allocate + (condition, branch, rtc); + else + return node_allocator_->allocate + (condition, branch); + } #ifndef exprtk_disable_break_continue else - return node_allocator_->allocate - ( - condition, - branch, - get_loop_runtime_check(loop_runtime_check::e_repeat_until_loop) - ); + { + if (rtc) + return node_allocator_->allocate + (condition, branch, rtc); + else + return node_allocator_->allocate + (condition, branch); + } #else return error_node(); #endif @@ -28299,9 +28497,9 @@ namespace exprtk expression_node_ptr& condition, expression_node_ptr& incrementor, expression_node_ptr& loop_body, - bool brkcont = false) const + bool break_continue_present = false) const { - if (!brkcont && details::is_constant_node(condition)) + if (!break_continue_present && details::is_constant_node(condition)) { expression_node_ptr result = error_node(); @@ -28311,43 +28509,67 @@ namespace exprtk else result = node_allocator_->allocate >(); - free_node(*node_allocator_, initialiser); - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, incrementor); - free_node(*node_allocator_, loop_body ); + details::free_node(*node_allocator_, initialiser); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, incrementor); + details::free_node(*node_allocator_, loop_body ); return result; } else if (details::is_null_node(condition) || (0 == condition)) { - free_node(*node_allocator_, initialiser); - free_node(*node_allocator_, condition ); - free_node(*node_allocator_, incrementor); + details::free_node(*node_allocator_, initialiser); + details::free_node(*node_allocator_, condition ); + details::free_node(*node_allocator_, incrementor); return loop_body; } - else if (!brkcont) - return node_allocator_->allocate - ( - initialiser, - condition, - incrementor, - loop_body, - get_loop_runtime_check(loop_runtime_check::e_for_loop) - ); + loop_runtime_check_ptr rtc = get_loop_runtime_check(loop_runtime_check::e_for_loop); + + if (!break_continue_present) + { + if (rtc) + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body, + rtc + ); + else + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body + ); + } #ifndef exprtk_disable_break_continue else - return node_allocator_->allocate - ( - initialiser, - condition, - incrementor, - loop_body, - get_loop_runtime_check(loop_runtime_check::e_for_loop) - ); + { + if (rtc) + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body, + rtc + ); + else + return node_allocator_->allocate + ( + initialiser, + condition, + incrementor, + loop_body + ); + } #else - return error_node(); + return error_node(); #endif } @@ -28416,7 +28638,7 @@ namespace exprtk if (current_expr && (current_expr != result)) { - free_node(*node_allocator_,current_expr); + details::free_node(*node_allocator_,current_expr); } } @@ -28630,7 +28852,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(v); \ @@ -28645,7 +28867,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > > \ (operation, branch[0]); \ @@ -28661,7 +28883,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(branch[0]); \ @@ -28885,7 +29107,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : temp_node = node_allocator_-> \ allocate > > \ (arg_list); \ @@ -28927,7 +29149,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(arg_list); \ @@ -28952,7 +29174,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(arg_list[0]); \ @@ -28999,7 +29221,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate > >(arg_list); \ @@ -29228,8 +29450,8 @@ namespace exprtk } else { - details::free_node (*node_allocator_,result ); - details::free_all_nodes(*node_allocator_,arg_list); + details::free_node (*node_allocator_, result ); + details::free_all_nodes(*node_allocator_, arg_list); return error_node(); } @@ -29449,7 +29671,7 @@ namespace exprtk if (details::is_ivector_node(branch[1])) return synthesize_expression(operation, branch); - else + else return synthesize_expression(operation, branch); } else @@ -29469,7 +29691,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29489,7 +29711,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29509,7 +29731,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29529,7 +29751,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29551,7 +29773,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29569,7 +29791,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29630,7 +29852,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29644,7 +29866,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29658,7 +29880,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29691,7 +29913,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29706,7 +29928,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29721,7 +29943,7 @@ namespace exprtk { switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ template allocate_rrr > > \ (operation, branch[0], branch[1]); \ @@ -29831,8 +30053,8 @@ namespace exprtk if (result) { - free_node(*node_allocator_, branch[0]); - free_node(*node_allocator_, branch[1]); + details::free_node(*node_allocator_, branch[0]); + details::free_node(*node_allocator_, branch[1]); return result; } @@ -30105,7 +30327,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate > > \ (branch[0], branch[1]); \ @@ -30137,7 +30359,7 @@ namespace exprtk if (synthesis_result) { - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); return result; } } @@ -30158,7 +30380,7 @@ namespace exprtk { const Type& v1 = static_cast(branch[1])->v(); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); switch (operation) { @@ -30180,7 +30402,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_rc > > \ (v, branch[1]); \ @@ -30212,7 +30434,7 @@ namespace exprtk if (synthesis_result) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return result; } @@ -30236,7 +30458,7 @@ namespace exprtk { const Type& v0 = static_cast(branch[0])->v(); - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); switch (operation) { @@ -30266,7 +30488,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_cr > > \ (branch[0], v); \ @@ -30287,17 +30509,17 @@ namespace exprtk { const Type c = static_cast*>(branch[0])->value(); - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } @@ -30378,7 +30600,7 @@ namespace exprtk default : return error_node(); } - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); return new_cobnode; } @@ -30395,7 +30617,7 @@ namespace exprtk if (synthesis_result) { - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); return result; } @@ -30404,7 +30626,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_tt > > \ (c, branch[1]); \ @@ -30429,13 +30651,13 @@ namespace exprtk if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return expr_gen(std::numeric_limits::quiet_NaN()); } @@ -30523,7 +30745,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_cr > > \ (branch[0], c); \ @@ -30553,33 +30775,33 @@ namespace exprtk if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(std::numeric_limits::quiet_NaN())); } else if (std::equal_to()(T(0),c) && (details::e_add == operation)) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return branch[0]; } else if (std::equal_to()(T(1),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return branch[0]; } else if (std::equal_to()(T(1),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return branch[0]; } @@ -30622,13 +30844,13 @@ namespace exprtk template allocate_tt > > (cobnode->c() / c, cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); } } if (result) { - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } @@ -30641,27 +30863,27 @@ namespace exprtk if (std::equal_to()(T(0),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_div == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[1]); return expr_gen(T(0)); } else if (std::equal_to()(T(0),c) && (details::e_add == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return branch[1]; } else if (std::equal_to()(T(1),c) && (details::e_mul == operation)) { - free_node(*expr_gen.node_allocator_, branch[0]); + details::free_node(*expr_gen.node_allocator_, branch[0]); return branch[1]; } @@ -30679,7 +30901,7 @@ namespace exprtk template allocate_tt > > (c - cobnode->c(), cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_sub == cobnode->operation()) @@ -30695,7 +30917,7 @@ namespace exprtk template allocate_tt > > (c - cobnode->c(), cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_mul == cobnode->operation()) @@ -30711,7 +30933,7 @@ namespace exprtk template allocate_tt > > (c / cobnode->c(), cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_div == cobnode->operation()) @@ -30727,13 +30949,13 @@ namespace exprtk template allocate_tt > > (c / cobnode->c(), cobnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } if (result) { - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); } } @@ -30786,7 +31008,7 @@ namespace exprtk template allocate_tt > > (bocnode->move_branch(0), c - bocnode->c()); - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); } else if (details::e_sub == operation) { @@ -30808,7 +31030,7 @@ namespace exprtk if (result) { - free_node(*expr_gen.node_allocator_, branch[1]); + details::free_node(*expr_gen.node_allocator_, branch[1]); } } @@ -30832,7 +31054,7 @@ namespace exprtk template allocate_tt > > (c - bocnode->c(), bocnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_sub == bocnode->operation()) @@ -30843,7 +31065,7 @@ namespace exprtk template allocate_tt > > (bocnode->move_branch(0), c - bocnode->c()); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } else if (details::e_sub == operation) { @@ -30851,7 +31073,7 @@ namespace exprtk template allocate_tt > > (c + bocnode->c(), bocnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_mul == bocnode->operation()) @@ -30867,7 +31089,7 @@ namespace exprtk template allocate_tt > > (c / bocnode->c(), bocnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } else if (details::e_div == bocnode->operation()) @@ -30883,13 +31105,13 @@ namespace exprtk template allocate_tt > > (c * bocnode->c(), bocnode->move_branch(0)); - free_node(*expr_gen.node_allocator_,branch[1]); + details::free_node(*expr_gen.node_allocator_,branch[1]); } } if (result) { - free_node(*expr_gen.node_allocator_,branch[0]); + details::free_node(*expr_gen.node_allocator_,branch[0]); } } @@ -30932,7 +31154,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_rr > > \ (v1, v2); \ @@ -30967,7 +31189,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_cr > > \ (c, v); \ @@ -31011,7 +31233,7 @@ namespace exprtk switch (operation) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return expr_gen.node_allocator_-> \ template allocate_rc > > \ (v, c); \ @@ -31080,7 +31302,6 @@ namespace exprtk case details::e_sf##op : return details::T0oT1oT2oT3_sf4ext >:: \ allocate(*(expr_gen.node_allocator_), t0, t1, t2, t3); \ - #define case_stmt1(op) \ case details::e_sf4ext##op : return details::T0oT1oT2oT3_sf4ext >:: \ allocate(*(expr_gen.node_allocator_), t0, t1, t2, t3); \ @@ -32027,7 +32248,9 @@ namespace exprtk struct synthesize_cocov_expression0 { typedef typename cocov_t::type0 node_type; - static inline expression_node_ptr process(expression_generator&, const details::operator_type&, expression_node_ptr (&)[2]) + static inline expression_node_ptr process(expression_generator&, + const details::operator_type&, + expression_node_ptr (&)[2]) { // (c0 o0 c1) o1 (v) - Not possible. return error_node(); @@ -32284,7 +32507,9 @@ namespace exprtk { typedef typename vococ_t::type0 node_type; - static inline expression_node_ptr process(expression_generator&, const details::operator_type&, expression_node_ptr (&)[2]) + static inline expression_node_ptr process(expression_generator&, + const details::operator_type&, + expression_node_ptr (&)[2]) { // (v) o0 (c0 o1 c1) - Not possible. exprtk_debug(("(v) o0 (c0 o1 c1) - Not possible.\n")); @@ -33360,7 +33585,7 @@ namespace exprtk const bool synthesis_result = synthesize_sf3ext_expression:: - template compile(expr_gen,specfunc, c0, v0, v1, result); + template compile(expr_gen, specfunc, c0, v0, v1, result); exprtk_debug(("(c * v0) +/- (v1 * c) --> (covov) c * (v0 +/- v1)\n")); @@ -34623,7 +34848,9 @@ namespace exprtk struct synthesize_vococov_expression2 { typedef typename vococov_t::type2 node_type; - static inline expression_node_ptr process(expression_generator&, const details::operator_type&, expression_node_ptr (&)[2]) + static inline expression_node_ptr process(expression_generator&, + const details::operator_type&, + expression_node_ptr (&)[2]) { // v0 o0 ((c0 o1 c1) o2 v1) - Not possible exprtk_debug(("v0 o0 ((c0 o1 c1) o2 v1) - Not possible\n")); @@ -34631,7 +34858,9 @@ namespace exprtk } static inline std::string id(expression_generator&, - const details::operator_type, const details::operator_type, const details::operator_type) + const details::operator_type, + const details::operator_type, + const details::operator_type) { return "INVALID"; } @@ -35665,7 +35894,9 @@ namespace exprtk struct synthesize_vococov_expression4 { typedef typename vococov_t::type4 node_type; - static inline expression_node_ptr process(expression_generator&, const details::operator_type&, expression_node_ptr (&)[2]) + static inline expression_node_ptr process(expression_generator&, + const details::operator_type&, + expression_node_ptr (&)[2]) { // ((v0 o0 (c0 o1 c1)) o2 v1) - Not possible exprtk_debug(("((v0 o0 (c0 o1 c1)) o2 v1) - Not possible\n")); @@ -35673,7 +35904,9 @@ namespace exprtk } static inline std::string id(expression_generator&, - const details::operator_type, const details::operator_type, const details::operator_type) + const details::operator_type, + const details::operator_type, + const details::operator_type) { return "INVALID"; } @@ -35774,7 +36007,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_ttt >,T0,T1> \ (s0, s1, rp0); \ @@ -35792,7 +36025,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_ttt >,T0,T1> \ (s0, s1, rp1); \ @@ -35810,7 +36043,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_tttt >,T0,T1> \ (s0, s1, rp0, rp1); \ @@ -35826,7 +36059,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_tt >,T0,T1>(s0, s1); \ @@ -35852,7 +36085,7 @@ namespace exprtk static_cast*>(branch[0])->range_ref().clear(); - free_node(*node_allocator_,branch[0]); + details::free_node(*node_allocator_,branch[0]); return synthesize_str_xrox_expression_impl(opr, s0, s1, rp0); } @@ -35865,7 +36098,7 @@ namespace exprtk static_cast*>(branch[1])->range_ref().clear(); - free_node(*node_allocator_,branch[1]); + details::free_node(*node_allocator_,branch[1]); return synthesize_str_xoxr_expression_impl(opr, s0, s1, rp1); } @@ -35878,7 +36111,7 @@ namespace exprtk static_cast*>(branch[1])->range_ref().clear(); - free_node(*node_allocator_,branch[1]); + details::free_node(*node_allocator_,branch[1]); return synthesize_str_xoxr_expression_impl(opr, s0, s1, rp1); } @@ -35935,9 +36168,9 @@ namespace exprtk inline expression_node_ptr synthesize_srocs_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { - std::string& s0 = static_cast*> (branch[0])->ref (); + std::string& s0 = static_cast* >(branch[0])->ref (); std::string s1 = static_cast*>(branch[1])->str (); - range_t rp0 = static_cast*> (branch[0])->range(); + range_t rp0 = static_cast* >(branch[0])->range(); static_cast*>(branch[0])->range_ref().clear(); @@ -35949,9 +36182,9 @@ namespace exprtk inline expression_node_ptr synthesize_srocsr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { - std::string& s0 = static_cast*> (branch[0])->ref (); + std::string& s0 = static_cast* >(branch[0])->ref (); std::string s1 = static_cast*>(branch[1])->str (); - range_t rp0 = static_cast*> (branch[0])->range(); + range_t rp0 = static_cast* >(branch[0])->range(); range_t rp1 = static_cast*>(branch[1])->range(); static_cast*> (branch[0])->range_ref().clear(); @@ -35996,14 +36229,14 @@ namespace exprtk inline expression_node_ptr synthesize_csocsr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { - const std::string s0 = static_cast*> (branch[0])->str (); + const std::string s0 = static_cast* >(branch[0])->str (); std::string s1 = static_cast*>(branch[1])->str (); range_t rp1 = static_cast*>(branch[1])->range(); static_cast*>(branch[1])->range_ref().clear(); - free_node(*node_allocator_,branch[0]); - free_node(*node_allocator_,branch[1]); + details::free_node(*node_allocator_,branch[0]); + details::free_node(*node_allocator_,branch[1]); return synthesize_str_xoxr_expression_impl(opr, s0, s1, rp1); } @@ -36011,12 +36244,12 @@ namespace exprtk inline expression_node_ptr synthesize_csros_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { std::string s0 = static_cast*>(branch[0])->str (); - std::string& s1 = static_cast*> (branch[1])->ref (); + std::string& s1 = static_cast* >(branch[1])->ref (); range_t rp0 = static_cast*>(branch[0])->range(); static_cast*>(branch[0])->range_ref().clear(); - free_node(*node_allocator_,branch[0]); + details::free_node(*node_allocator_,branch[0]); return synthesize_str_xrox_expression_impl(opr, s0, s1, rp0); } @@ -36024,15 +36257,15 @@ namespace exprtk inline expression_node_ptr synthesize_csrosr_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { const std::string s0 = static_cast*>(branch[0])->str (); - std::string& s1 = static_cast*> (branch[1])->ref (); + std::string& s1 = static_cast* >(branch[1])->ref (); const range_t rp0 = static_cast*>(branch[0])->range(); - const range_t rp1 = static_cast*> (branch[1])->range(); + const range_t rp1 = static_cast* >(branch[1])->range(); static_cast*>(branch[0])->range_ref().clear(); static_cast*> (branch[1])->range_ref().clear(); - free_node(*node_allocator_,branch[0]); - free_node(*node_allocator_,branch[1]); + details::free_node(*node_allocator_,branch[0]); + details::free_node(*node_allocator_,branch[1]); return synthesize_str_xroxr_expression_impl(opr, s0, s1, rp0, rp1); } @@ -36040,7 +36273,7 @@ namespace exprtk inline expression_node_ptr synthesize_csrocs_expression(const details::operator_type& opr, expression_node_ptr (&branch)[2]) { const std::string s0 = static_cast*>(branch[0])->str (); - const std::string s1 = static_cast*> (branch[1])->str (); + const std::string s1 = static_cast* >(branch[1])->str (); const range_t rp0 = static_cast*>(branch[0])->range(); static_cast*>(branch[0])->range_ref().clear(); @@ -36069,7 +36302,7 @@ namespace exprtk { switch (opr) { - #define case_stmt(op0,op1) \ + #define case_stmt(op0, op1) \ case op0 : return node_allocator_-> \ allocate_ttt > > \ (opr, branch[0], branch[1]); \ @@ -36131,28 +36364,28 @@ namespace exprtk } else if (b0_is_s) { - if (b1_is_s ) return synthesize_sos_expression (opr,branch); + if (b1_is_s ) return synthesize_sos_expression (opr,branch); else if (b1_is_cs ) return synthesize_socs_expression (opr,branch); else if (b1_is_sr ) return synthesize_sosr_expression (opr,branch); else if (b1_is_csr) return synthesize_socsr_expression (opr,branch); } else if (b0_is_cs) { - if (b1_is_s ) return synthesize_csos_expression (opr,branch); + if (b1_is_s ) return synthesize_csos_expression (opr,branch); else if (b1_is_cs ) return synthesize_csocs_expression (opr,branch); else if (b1_is_sr ) return synthesize_csosr_expression (opr,branch); else if (b1_is_csr) return synthesize_csocsr_expression(opr,branch); } else if (b0_is_sr) { - if (b1_is_s ) return synthesize_sros_expression (opr,branch); + if (b1_is_s ) return synthesize_sros_expression (opr,branch); else if (b1_is_sr ) return synthesize_srosr_expression (opr,branch); else if (b1_is_cs ) return synthesize_srocs_expression (opr,branch); else if (b1_is_csr) return synthesize_srocsr_expression(opr,branch); } else if (b0_is_csr) { - if (b1_is_s ) return synthesize_csros_expression (opr,branch); + if (b1_is_s ) return synthesize_csros_expression (opr,branch); else if (b1_is_sr ) return synthesize_csrosr_expression (opr,branch); else if (b1_is_cs ) return synthesize_csrocs_expression (opr,branch); else if (b1_is_csr) return synthesize_csrocsr_expression(opr,branch); @@ -36232,9 +36465,9 @@ namespace exprtk details::is_string_node(branch[2]) ) { - std::string& s0 = static_cast< details::stringvar_node*>(branch[0])->ref(); + std::string& s0 = static_cast* >(branch[0])->ref(); std::string s1 = static_cast*>(branch[1])->str(); - std::string& s2 = static_cast< details::stringvar_node*>(branch[2])->ref(); + std::string& s2 = static_cast* >(branch[2])->ref(); typedef typename details::sosos_node > inrange_t; @@ -36248,8 +36481,8 @@ namespace exprtk details::is_const_string_node(branch[2]) ) { - std::string& s0 = static_cast< details::stringvar_node*>(branch[0])->ref(); - std::string& s1 = static_cast< details::stringvar_node*>(branch[1])->ref(); + std::string& s0 = static_cast* >(branch[0])->ref(); + std::string& s1 = static_cast* >(branch[1])->ref(); std::string s2 = static_cast*>(branch[2])->str(); typedef typename details::sosos_node > inrange_t; @@ -36467,7 +36700,7 @@ namespace exprtk sf3_map_t* sf3_map_; sf4_map_t* sf4_map_; parser_t* parser_; - }; + }; // class expression_generator inline void set_error(const parser_error::type& error_type) { @@ -36557,7 +36790,7 @@ namespace exprtk inline void load_unary_operations_map(unary_op_map_t& m) { - #define register_unary_op(Op,UnaryFunctor) \ + #define register_unary_op(Op, UnaryFunctor) \ m.insert(std::make_pair(Op,UnaryFunctor::process)); \ register_unary_op(details::e_abs , details::abs_op ) @@ -36606,7 +36839,7 @@ namespace exprtk { typedef typename binary_op_map_t::value_type value_type; - #define register_binary_op(Op,BinaryFunctor) \ + #define register_binary_op(Op, BinaryFunctor) \ m.insert(value_type(Op,BinaryFunctor::process)); \ register_binary_op(details::e_add , details::add_op ) @@ -36634,7 +36867,7 @@ namespace exprtk { typedef typename inv_binary_op_map_t::value_type value_type; - #define register_binary_op(Op,BinaryFunctor) \ + #define register_binary_op(Op, BinaryFunctor) \ m.insert(value_type(BinaryFunctor::process,Op)); \ register_binary_op(details::e_add , details::add_op ) @@ -36747,8 +36980,8 @@ namespace exprtk private: - parser(const parser&); - parser& operator=(const parser&); + parser(const parser&) exprtk_delete; + parser& operator=(const parser&) exprtk_delete; settings_store settings_; expression_generator expression_generator_; @@ -36778,7 +37011,7 @@ namespace exprtk lexer::helper::operator_joiner operator_joiner_3_; lexer::helper::symbol_replacer symbol_replacer_; lexer::helper::bracket_checker bracket_checker_; - lexer::helper::numeric_checker numeric_checker_; + lexer::helper::numeric_checker numeric_checker_; lexer::helper::sequence_validator sequence_validator_; lexer::helper::sequence_validator_3tokens sequence_validator_3tkns_; @@ -36786,7 +37019,7 @@ namespace exprtk template friend void details::disable_type_checking(ParserType& p); - }; + }; // class parser namespace details { @@ -36794,8 +37027,8 @@ namespace exprtk struct collector_helper { typedef exprtk::symbol_table symbol_table_t; - typedef exprtk::expression expression_t; - typedef exprtk::parser parser_t; + typedef exprtk::expression expression_t; + typedef exprtk::parser parser_t; typedef typename parser_t::dependent_entity_collector::symbol_t symbol_t; typedef typename parser_t::unknown_symbol_resolver usr_t; @@ -37459,8 +37692,7 @@ namespace exprtk disable_has_side_effects(*this); } - virtual ~polynomial() - {} + virtual ~polynomial() {} #define poly_rtrn(NN) \ return (NN != N) ? std::numeric_limits::quiet_NaN() : @@ -37480,47 +37712,60 @@ namespace exprtk poly_rtrn(3) (poly_impl::evaluate(x, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c4, const T& c3, const T& c2, const T& c1, + const T& c0) { poly_rtrn(4) (poly_impl::evaluate(x, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c5, const T& c4, const T& c3, const T& c2, + const T& c1, const T& c0) { poly_rtrn(5) (poly_impl::evaluate(x, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c6, const T& c5, const T& c4, const T& c3, + const T& c2, const T& c1, const T& c0) { poly_rtrn(6) (poly_impl::evaluate(x, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c7, const T& c6, const T& c5, const T& c4, + const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(7) (poly_impl::evaluate(x, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c8, const T& c7, const T& c6, const T& c5, + const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(8) (poly_impl::evaluate(x, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c9, const T& c8, const T& c7, const T& c6, + const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, + const T& c0) { poly_rtrn(9) (poly_impl::evaluate(x, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c10, const T& c9, const T& c8, const T& c7, + const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, + const T& c1, const T& c0) { poly_rtrn(10) (poly_impl::evaluate(x, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c11, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c11, const T& c10, const T& c9, const T& c8, + const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, + const T& c2, const T& c1, const T& c0) { poly_rtrn(11) (poly_impl::evaluate(x, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } - inline virtual T operator() (const T& x, const T& c12, const T& c11, const T& c10, const T& c9, const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, const T& c3, const T& c2, const T& c1, const T& c0) + inline virtual T operator() (const T& x, const T& c12, const T& c11, const T& c10, const T& c9, + const T& c8, const T& c7, const T& c6, const T& c5, const T& c4, + const T& c3, const T& c2, const T& c1, const T& c0) { poly_rtrn(12) (poly_impl::evaluate(x, c12, c11, c10, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0)); } @@ -37665,45 +37910,51 @@ namespace exprtk v.resize(pc); } - virtual ~base_func() - {} + virtual ~base_func() {} + + #define exprtk_assign(Index) \ + (*v[Index]) = v##Index; \ inline void update(const T& v0) { - (*v[0]) = v0; + exprtk_assign(0) } inline void update(const T& v0, const T& v1) { - (*v[0]) = v0; (*v[1]) = v1; + exprtk_assign(0) exprtk_assign(1) } inline void update(const T& v0, const T& v1, const T& v2) { - (*v[0]) = v0; (*v[1]) = v1; - (*v[2]) = v2; + exprtk_assign(0) exprtk_assign(1) + exprtk_assign(2) } inline void update(const T& v0, const T& v1, const T& v2, const T& v3) { - (*v[0]) = v0; (*v[1]) = v1; - (*v[2]) = v2; (*v[3]) = v3; + exprtk_assign(0) exprtk_assign(1) + exprtk_assign(2) exprtk_assign(3) } inline void update(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4) { - (*v[0]) = v0; (*v[1]) = v1; - (*v[2]) = v2; (*v[3]) = v3; - (*v[4]) = v4; + exprtk_assign(0) exprtk_assign(1) + exprtk_assign(2) exprtk_assign(3) + exprtk_assign(4) } inline void update(const T& v0, const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) { - (*v[0]) = v0; (*v[1]) = v1; - (*v[2]) = v2; (*v[3]) = v3; - (*v[4]) = v4; (*v[5]) = v5; + exprtk_assign(0) exprtk_assign(1) + exprtk_assign(2) exprtk_assign(3) + exprtk_assign(4) exprtk_assign(5) } + #ifdef exprtk_assign + #undef exprtk_assign + #endif + inline function_t& setup(expression_t& expr) { expression = expr; @@ -37894,8 +38145,8 @@ namespace exprtk private: - scoped_bft(scoped_bft&); - scoped_bft& operator=(scoped_bft&); + scoped_bft(const scoped_bft&) exprtk_delete; + scoped_bft& operator=(const scoped_bft&) exprtk_delete; }; struct func_1param : public base_func @@ -38297,7 +38548,7 @@ namespace exprtk std::map expr_map_; std::vector fp_map_; std::vector auxiliary_symtab_list_; - }; + }; // class function_compositor template inline bool pgo_primer() @@ -38742,7 +38993,7 @@ namespace exprtk bool register_package(exprtk::symbol_table& symtab) { - #define exprtk_register_function(FunctionName,FunctionType) \ + #define exprtk_register_function(FunctionName, FunctionType) \ if (!symtab.add_function(FunctionName,FunctionType)) \ { \ exprtk_debug(( \ @@ -38965,11 +39216,13 @@ namespace exprtk template file_descriptor* make_handle(T v) { - file_descriptor* fd = reinterpret_cast(0); + details::file_descriptor* fd = reinterpret_cast(0); + + const std::size_t fd_size = sizeof(details::file_descriptor*); std::memcpy(reinterpret_cast(&fd), reinterpret_cast(&v), - sizeof(fd)); + fd_size); return fd; } @@ -39028,9 +39281,11 @@ namespace exprtk { T t = T(0); + const std::size_t fd_size = sizeof(details::file_descriptor*); + std::memcpy(reinterpret_cast(&t ), reinterpret_cast(&fd), - sizeof(fd)); + fd_size); return t; } else @@ -39231,7 +39486,7 @@ namespace exprtk bool register_package(exprtk::symbol_table& symtab) { - #define exprtk_register_function(FunctionName,FunctionType) \ + #define exprtk_register_function(FunctionName, FunctionType) \ if (!symtab.add_function(FunctionName,FunctionType)) \ { \ exprtk_debug(( \ @@ -40392,7 +40647,7 @@ namespace exprtk bool register_package(exprtk::symbol_table& symtab) { - #define exprtk_register_function(FunctionName,FunctionType) \ + #define exprtk_register_function(FunctionName, FunctionType) \ if (!symtab.add_function(FunctionName,FunctionType)) \ { \ exprtk_debug(( \ @@ -40440,11 +40695,11 @@ namespace exprtk namespace information { static const char* library = "Mathematical Expression Toolkit"; - static const char* version = "2.718281828459045235360287471352" - "66249775724709369995957496696762" - "77240766303535475945713821785251" - "66427427466391932003059921817413"; - static const char* date = "20210101"; + static const char* version = "2.7182818284590452353602874713526" + "624977572470936999595749669676277" + "240766303535475945713821785251664" + "274274663919320030599218174135966"; + static const char* date = "20220101"; static inline std::string data() { @@ -40480,6 +40735,10 @@ namespace exprtk #undef exprtk_final #endif + #ifdef exprtk_delete + #undef exprtk_delete + #endif + } // namespace exprtk #endif diff --git a/tests/model_enforcer_test.cpp b/tests/model_enforcer_test.cpp index 9ae04e87..c402bd1e 100644 --- a/tests/model_enforcer_test.cpp +++ b/tests/model_enforcer_test.cpp @@ -21,15 +21,28 @@ #include "config_path.h" namespace { + std::string global_sub; + std::string global_obj; + std::string global_act; -casbin::Scope InitializeParams(const std::string& sub, const std::string& obj, const std::string& act){ - casbin::Scope scope = casbin::InitializeScope(); - casbin::PushObject(scope, "r"); - casbin::PushStringPropToObject(scope, "r", sub, "sub"); - casbin::PushStringPropToObject(scope, "r", obj, "obj"); - casbin::PushStringPropToObject(scope, "r", act, "act"); +template +std::shared_ptr InitializeParams(const std::string& sub, const std::string& obj, const std::string& act) { + auto evaluator = std::make_shared(); + evaluator->InitialObject("r"); - return scope; + // Because of "Short String Optimization", these strings's data is in stack. + // For MSVC compiler, when this stack frame return, these memory will can't access. + // So we need keep this memory accessiable. + + global_sub = sub; + global_obj = obj; + global_act = act; + + evaluator->PushObjectString("r", "sub", global_sub); + evaluator->PushObjectString("r", "obj", global_obj); + evaluator->PushObjectString("r", "act", global_act); + + return evaluator; } casbin::Scope InitializeParamsWithoutUsers(const std::string& obj, const std::string& act) { @@ -78,127 +91,240 @@ void TestEnforce(casbin::Enforcer& e, casbin::Scope& scope, bool res) { ASSERT_EQ(res, e.Enforce(evaluator)); } +void TestEnforce(casbin::Enforcer& e, std::shared_ptr evaluator, bool res) { + ASSERT_EQ(res, e.Enforce(evaluator)); +} + TEST(TestModelEnforcer, TestBasicModel) { casbin::Enforcer e(basic_model_path, basic_policy_path); - casbin::Scope scope; - - scope = InitializeParams("alice", "data1", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "write"); - TestEnforce(e, scope, true); + std::shared_ptr evaluator; + + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, true); + + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, true); } TEST(TestModelEnforcer, TestBasicModelWithoutSpaces) { casbin::Enforcer e(basic_model_without_spaces_path, basic_policy_path); - casbin::Scope scope = InitializeParams("alice", "data1", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "write"); - TestEnforce(e, scope, true); + std::shared_ptr evaluator; + + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, true); + + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, true); } TEST(TestModelEnforcer, TestBasicModelNoPolicy) { casbin::Enforcer e(basic_model_path); - casbin::Scope scope = InitializeParams("alice", "data1", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "write"); - TestEnforce(e, scope, false); + std::shared_ptr evaluator; + + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, false); + + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, false); } TEST(TestModelEnforcer, TestBasicModelWithRoot) { casbin::Enforcer e(basic_with_root_model_path, basic_policy_path); - casbin::Scope scope = InitializeParams("alice", "data1", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "write"); - TestEnforce(e, scope, true); - scope = InitializeParams("root", "data1", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("root", "data1", "write"); - TestEnforce(e, scope, true); - scope = InitializeParams("root", "data2", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("root", "data2", "write"); - TestEnforce(e, scope, true); + std::shared_ptr evaluator; + + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data1", "write"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data2", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data2", "write"); + TestEnforce(e, evaluator, true); + + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data1", "write"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data2", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data2", "write"); + TestEnforce(e, evaluator, true); } TEST(TestModelEnforcer, TestBasicModelWithRootNoPolicy) { casbin::Enforcer e(basic_with_root_model_path); - casbin::Scope scope = InitializeParams("alice", "data1", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("root", "data1", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("root", "data1", "write"); - TestEnforce(e, scope, true); - scope = InitializeParams("root", "data2", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("root", "data2", "write"); - TestEnforce(e, scope, true); + std::shared_ptr evaluator; + + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("root", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data1", "write"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data2", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data2", "write"); + TestEnforce(e, evaluator, true); + + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("root", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data1", "write"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data2", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("root", "data2", "write"); + TestEnforce(e, evaluator, true); } TEST(TestModelEnforcer, TestBasicModelWithoutUsers) { @@ -230,43 +356,47 @@ TEST(TestModelEnforcer, TestBasicModelWithoutResources) { TEST(TestModelEnforcer, TestRBACModel) { casbin::Enforcer e(rbac_model_path, rbac_policy_path); - casbin::Scope scope = InitializeParams("alice", "data1", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "data2", "write"); - TestEnforce(e, scope, true); - scope = InitializeParams("bob", "data1", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "write"); - TestEnforce(e, scope, true); + std::shared_ptr evaluator; + + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, true); } TEST(TestModelEnforcer, TestRBACModelWithResourceRoles) { casbin::Enforcer e(rbac_with_resource_roles_model_path, rbac_with_resource_roles_policy_path); - casbin::Scope scope = InitializeParams("alice", "data1", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "data1", "write"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "write"); - TestEnforce(e, scope, true); - scope = InitializeParams("bob", "data1", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "write"); - TestEnforce(e, scope, true); + std::shared_ptr evaluator; + + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, true); } TEST(TestModelEnforcer, TestRBACModelWithDomains) { @@ -397,29 +527,31 @@ TEST(TestModelEnforcer, TestRBACModelWithDomainsAtRuntimeMockAdapter) { TEST(TestModelEnforcer, TestRBACModelWithDeny) { casbin::Enforcer e(rbac_with_deny_model_path, rbac_with_deny_policy_path); - casbin::Scope scope = InitializeParams("alice", "data1", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "data2", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "write"); - TestEnforce(e, scope, true); + std::shared_ptr evaluator; + + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, true); } TEST(TestModelEnforcer, TestRBACModelWithOnlyDeny) { casbin::Enforcer e(rbac_with_not_deny_model_path, rbac_with_deny_policy_path); - casbin::Scope scope = InitializeParams("alice", "data2", "write"); - TestEnforce(e, scope, false); + auto evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, false); } TEST(TestModelEnforcer, TestRBACModelWithCustomData) { @@ -431,22 +563,22 @@ TEST(TestModelEnforcer, TestRBACModelWithCustomData) { std::vector params{ "bob", "data2_admin", "custom_data" }; e.AddGroupingPolicy(params); - casbin::Scope scope = InitializeParams("alice", "data1", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "data2", "write"); - TestEnforce(e, scope, true); - scope = InitializeParams("bob", "data1", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("bob", "data2", "write"); - TestEnforce(e, scope, true); + auto evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, true); // You should also take the custom data as a parameter when deleting a grouping policy. // e.RemoveGroupingPolicy("bob", "data2_admin") won't work. @@ -454,22 +586,22 @@ TEST(TestModelEnforcer, TestRBACModelWithCustomData) { params = std::vector{ "bob", "data2_admin", "custom_data" }; e.RemoveGroupingPolicy(params); - scope = InitializeParams("alice", "data1", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("alice", "data2", "read"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "data2", "write"); - TestEnforce(e, scope, true); - scope = InitializeParams("bob", "data1", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data1", "write"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "read"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "data2", "write"); - TestEnforce(e, scope, true); + evaluator = InitializeParams("alice", "data1", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("alice", "data2", "read"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "data2", "write"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("bob", "data1", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data1", "write"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "read"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "data2", "write"); + TestEnforce(e, evaluator, true); } TEST(TestModelEnforcer, TestRBACModelWithPattern) { @@ -481,42 +613,42 @@ TEST(TestModelEnforcer, TestRBACModelWithPattern) { // of checking whether "/book/:id" equals the obj: "/book/1", it checks whether the pattern matches. // You can see it as normal RBAC: "/book/:id" == "/book/1" becomes KeyMatch2("/book/:id", "/book/1") e.AddNamedMatchingFunc("p", "", casbin::KeyMatch2); - casbin::Scope scope = InitializeParams("alice", "/book/1", "GET"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "/book/2", "GET"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "/pen/1", "GET"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "/pen/2", "GET"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "/book/1", "GET"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "/book/2", "GET"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "/pen/1", "GET"); - TestEnforce(e, scope, true); - scope = InitializeParams("bob", "/pen/2", "GET"); - TestEnforce(e, scope, true); + auto evaluator = InitializeParams("alice", "/book/1", "GET"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "/book/2", "GET"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "/pen/1", "GET"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "/pen/2", "GET"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "/book/1", "GET"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "/book/2", "GET"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "/pen/1", "GET"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("bob", "/pen/2", "GET"); + TestEnforce(e, evaluator, true); // AddMatchingFunc() is actually setting a function because only one function is allowed, // so when we set "KeyMatch3", we are actually replacing "KeyMatch2" with "KeyMatch3". e.AddNamedMatchingFunc("p", "", casbin::KeyMatch3); - scope = InitializeParams("alice", "/book2/1", "GET"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "/book2/2", "GET"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "/pen2/1", "GET"); - TestEnforce(e, scope, true); - scope = InitializeParams("alice", "/pen2/2", "GET"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "/book2/1", "GET"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "/book2/2", "GET"); - TestEnforce(e, scope, false); - scope = InitializeParams("bob", "/pen2/1", "GET"); - TestEnforce(e, scope, true); - scope = InitializeParams("bob", "/pen2/2", "GET"); - TestEnforce(e, scope, true); + evaluator = InitializeParams("alice", "/book2/1", "GET"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "/book2/2", "GET"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "/pen2/1", "GET"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("alice", "/pen2/2", "GET"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "/book2/1", "GET"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "/book2/2", "GET"); + TestEnforce(e, evaluator, false); + evaluator = InitializeParams("bob", "/pen2/1", "GET"); + TestEnforce(e, evaluator, true); + evaluator = InitializeParams("bob", "/pen2/2", "GET"); + TestEnforce(e, evaluator, true); } TEST(TestModelEnforcer, TestABACModelWithJson) {