casbin / casbin-cpp

An authorization library that supports access control models like ACL, RBAC, ABAC in C/C++
https://casbin.org
Apache License 2.0
223 stars 61 forks source link

Register keyGet function for evaluator #215

Closed cs1137195420 closed 1 year ago

cs1137195420 commented 2 years ago

Part of: #209 The updated KeyGet* functions have not been registered in the evaluator yet, so they cannot be called internally in the enforcer.

To solve this problem, I modified numeric_type to string in exprtk_config.h, and added the ExprtkGetFunction and ExprtkGetWithPathFunction struct to implement the registration of the KeyGet* functions.

But while running CI, I encountered some error messages, one of them is that the function in exprtk cannot be overloaded. It seems that the string type cannot be overloaded in exprtk as a template type. I'm not quite sure how to fix this. Can anyone give some suggestions?

Here is some error message:

/home/runner/work/casbin-cpp/casbin-cpp/include/casbin/model/../exprtk/exprtk.hpp:18112:27: error: ‘exprtk::symbol_table<T>::variable_t* exprtk::symbol_table<T>::get_variable(const T&) const [with T = std::__cxx11::basic_string<char>; exprtk::symbol_table<T>::variable_ptr = exprtk::details::variable_node<std::__cxx11::basic_string<char> >*; exprtk::symbol_table<T>::variable_t = exprtk::details::variable_node<std::__cxx11::basic_string<char> >]’ cannot be overloaded with ‘exprtk::symbol_table<T>::variable_t* exprtk::symbol_table<T>::get_variable(const string&) const [with T = std::__cxx11::basic_string<char>; exprtk::symbol_table<T>::variable_ptr = exprtk::details::variable_node<std::__cxx11::basic_string<char> >*; exprtk::symbol_table<T>::variable_t = exprtk::details::variable_node<std::__cxx11::basic_string<char> >; std::string = std::__cxx11::basic_string<char>]’
/home/runner/work/casbin-cpp/casbin-cpp/include/casbin/model/../exprtk/exprtk.hpp:13127:64: error: no match for ‘operator-’ (operand types are ‘const std::__cxx11::basic_string<char>’ and ‘const std::__cxx11::basic_string<char>’)
13127 |          static inline T process(Type t1, Type t2) { return t1 - t2; }
      |  
casbin-bot commented 2 years ago

@EmperorYP7 @sheny1xuan @cs1137195420