JPCRE2  10.31.02
C++ wrapper for PCRE2 library
jpcre2::select< Char_T, Map >::MatchEvaluatorCallback< T1, T2, T3 > Struct Template Reference

This class contains a typedef of a function pointer or a templated function wrapper (std::function) to provide callback function to the MatchEvaluator. More...

#include <jpcre2.hpp>

Detailed Description

template<typename Char_T, template< typename... > class Map = std::map>
template<typename T1, typename T2, typename T3>
struct jpcre2::select< Char_T, Map >::MatchEvaluatorCallback< T1, T2, T3 >

This class contains a typedef of a function pointer or a templated function wrapper (std::function) to provide callback function to the MatchEvaluator.

std::function is used when >=C++11 is being used , otherwise function pointer is used. You can force using function pointer instead of std::function when >=C++11 is used by defining the macro JPCRE2_USE_FUNCTION_POINTER_CALLBACK before including jpcre2.hpp. If you are using lambda function with capture, you must use the std::function approach.

The callback function takes exactly three positional arguments:

Template Parameters
T1The first argument must be jp::NumSub const & aka std::vector<String> const & (or void* if not needed).
T2The second argument must be jp::MapNas const & aka std::map<String, size_t> const & (or void* if not needed).
T3The third argument must be jp::MapNtN const & aka std::map<String, String> const & (or void* if not needed).

Examples:

jp::String myCallback1(jp::NumSub const &m1, void*, void*){
return "("+m1[0]+")";
}
jp::String myCallback2(jp::NumSub const &m1, jp::MapNas const &m2, void*){
return "("+m1[0]+"/"+m2.at("total")+")";
}
//Now you can pass these functions in MatchEvaluator constructors to create a match evaluator
jp::MatchEvaluator me1(myCallback1);
//Examples with lambda (>=C++11)
jp::MatchEvaluator me2([](jp::NumSub const &m1, void*, void*)
{
return "("+m1[0]+")";
});
See also
MatchEvaluator