示例#1
0
 void operator()(const std::string& ua,
                 const RegexImpl::smatch& matches,
                 const size_t group,
                 Result& result) const
 {
     if (v_)
     {
         result.*f_ = *v_;
         return;
     }
     if (f_ && matches.size() >= group)
     {
         auto v = matches[group].str();
         result.*f_ = fn_ ? fn_(std::move(v)) : std::move(v);
     }
 }
示例#2
0
    inline bool re_search_helper(Text const& txt, const boost::smatch &what, size_t depth, Arg arg, Args&&... args)
    {
        if (depth >= what.size()) {
            return false;
        }

        // If the match was optional and unmatched, skip it and leave the variable uninitialized.
        if (what[depth].matched) {
            try {
                using ArgType = typename std::pointer_traits<Arg>::element_type;
                auto val = boost::lexical_cast<ArgType>(what[depth]);
                *arg = val;
            } catch (const boost::bad_lexical_cast &e) {
                return false;
            }
        }

        return re_search_helper(txt, what, depth+1, std::forward<Args>(args)...);
    }