regex: move method definitions to .cpp files
Change-Id: Ifa66c886bd3f920821b0a498f714da24d51b042e
diff --git a/src/util/regex/regex-component-matcher.hpp b/src/util/regex/regex-component-matcher.hpp
index 3140375..4c5ecf0 100644
--- a/src/util/regex/regex-component-matcher.hpp
+++ b/src/util/regex/regex-component-matcher.hpp
@@ -25,12 +25,13 @@
#define NDN_UTIL_REGEX_REGEX_COMPONENT_MATCHER_HPP
#include "regex-matcher.hpp"
-#include "regex-pseudo-matcher.hpp"
#include <boost/regex.hpp>
namespace ndn {
+class RegexPseudoMatcher;
+
class RegexComponentMatcher : public RegexMatcher
{
public:
@@ -57,70 +58,6 @@
std::vector<shared_ptr<RegexPseudoMatcher>> m_pseudoMatchers;
};
-inline
-RegexComponentMatcher::RegexComponentMatcher(const std::string& expr,
- shared_ptr<RegexBackrefManager> backrefManager,
- bool isExactMatch)
- : RegexMatcher(expr, EXPR_COMPONENT, std::move(backrefManager))
- , m_isExactMatch(isExactMatch)
-{
- compile();
-}
-
-// Re: http://www.boost.org/users/history/version_1_56_0.html
-//
-// Breaking change: corrected behavior of basic_regex<>::mark_count() to match existing
-// documentation, basic_regex<>::subexpression(n) changed to match, see
-// https://svn.boost.org/trac/boost/ticket/9227
-//
-static constexpr size_t BOOST_REGEXP_MARK_COUNT_CORRECTION =
-#if BOOST_VERSION < 105600
- 1;
-#else
- 0;
-#endif
-
-inline void
-RegexComponentMatcher::compile()
-{
- m_componentRegex = boost::regex(m_expr);
-
- m_pseudoMatchers.clear();
- m_pseudoMatchers.push_back(make_shared<RegexPseudoMatcher>());
-
- for (size_t i = 1; i <= m_componentRegex.mark_count() - BOOST_REGEXP_MARK_COUNT_CORRECTION; i++) {
- m_pseudoMatchers.push_back(make_shared<RegexPseudoMatcher>());
- m_backrefManager->pushRef(m_pseudoMatchers.back());
- }
-}
-
-inline bool
-RegexComponentMatcher::match(const Name& name, size_t offset, size_t len)
-{
- m_matchResult.clear();
-
- if (m_expr.empty()) {
- m_matchResult.push_back(name.get(offset));
- return true;
- }
-
- if (!m_isExactMatch)
- BOOST_THROW_EXCEPTION(Error("Non-exact component search is not supported yet"));
-
- boost::smatch subResult;
- std::string targetStr = name.get(offset).toUri();
- if (boost::regex_match(targetStr, subResult, m_componentRegex)) {
- for (size_t i = 1; i <= m_componentRegex.mark_count() - BOOST_REGEXP_MARK_COUNT_CORRECTION; i++) {
- m_pseudoMatchers[i]->resetMatchResult();
- m_pseudoMatchers[i]->setMatchResult(subResult[i]);
- }
- m_matchResult.push_back(name.get(offset));
- return true;
- }
-
- return false;
-}
-
} // namespace ndn
#endif // NDN_UTIL_REGEX_REGEX_COMPONENT_MATCHER_HPP