regex: move method definitions to .cpp files

Change-Id: Ifa66c886bd3f920821b0a498f714da24d51b042e
diff --git a/src/util/regex/regex-component-set-matcher.hpp b/src/util/regex/regex-component-set-matcher.hpp
index 46d8527..3c9fae9 100644
--- a/src/util/regex/regex-component-set-matcher.hpp
+++ b/src/util/regex/regex-component-set-matcher.hpp
@@ -24,13 +24,14 @@
 #ifndef NDN_UTIL_REGEX_REGEX_COMPONENT_SET_MATCHER_HPP
 #define NDN_UTIL_REGEX_REGEX_COMPONENT_SET_MATCHER_HPP
 
-#include "regex-component-matcher.hpp"
 #include "regex-matcher.hpp"
 
 #include <set>
 
 namespace ndn {
 
+class RegexComponentMatcher;
+
 class RegexComponentSetMatcher : public RegexMatcher
 {
 public:
@@ -66,122 +67,6 @@
   bool m_isInclusion;
 };
 
-inline
-RegexComponentSetMatcher::RegexComponentSetMatcher(const std::string& expr,
-                                                   shared_ptr<RegexBackrefManager> backrefManager)
-  : RegexMatcher(expr, EXPR_COMPONENT_SET, std::move(backrefManager))
-  , m_isInclusion(true)
-{
-  compile();
-}
-
-inline void
-RegexComponentSetMatcher::compile()
-{
-  if (m_expr.size() < 2)
-    BOOST_THROW_EXCEPTION(Error("Regexp compile error (cannot parse " + m_expr + ")"));
-
-  switch (m_expr[0]) {
-    case '<':
-      return compileSingleComponent();
-    case '[': {
-      size_t lastIndex = m_expr.size() - 1;
-      if (']' != m_expr[lastIndex])
-        BOOST_THROW_EXCEPTION(Error("Regexp compile error (no matching ']' in " + m_expr + ")"));
-
-      if ('^' == m_expr[1]) {
-        m_isInclusion = false;
-        compileMultipleComponents(2, lastIndex);
-      }
-      else
-        compileMultipleComponents(1, lastIndex);
-      break;
-    }
-    default:
-      BOOST_THROW_EXCEPTION(Error("Regexp compile error (cannot parse " + m_expr + ")"));
-  }
-}
-
-inline void
-RegexComponentSetMatcher::compileSingleComponent()
-{
-  size_t end = extractComponent(1);
-  if (m_expr.size() != end)
-    BOOST_THROW_EXCEPTION(Error("Component expr error " + m_expr));
-
-  m_components.insert(make_shared<RegexComponentMatcher>(m_expr.substr(1, end - 2),
-                                                         m_backrefManager));
-}
-
-inline void
-RegexComponentSetMatcher::compileMultipleComponents(size_t start, size_t lastIndex)
-{
-  size_t index = start;
-  size_t tempIndex = start;
-
-  while (index < lastIndex) {
-    if ('<' != m_expr[index])
-      BOOST_THROW_EXCEPTION(Error("Component expr error " + m_expr));
-
-    tempIndex = index + 1;
-    index = extractComponent(tempIndex);
-    m_components.insert(make_shared<RegexComponentMatcher>(m_expr.substr(tempIndex, index - tempIndex - 1),
-                                                           m_backrefManager));
-  }
-
-  if (index != lastIndex)
-    BOOST_THROW_EXCEPTION(Error("Not sufficient expr to parse " + m_expr));
-}
-
-inline bool
-RegexComponentSetMatcher::match(const Name& name, size_t offset, size_t len)
-{
-  // componentset only matches one component
-  if (len != 1)
-    return false;
-
-  bool isMatched = false;
-  for (const auto& comp : m_components) {
-    if (comp->match(name, offset, len)) {
-      isMatched = true;
-      break;
-    }
-  }
-
-  m_matchResult.clear();
-
-  if (m_isInclusion ? isMatched : !isMatched) {
-    m_matchResult.push_back(name.get(offset));
-    return true;
-  }
-  else
-    return false;
-}
-
-inline size_t
-RegexComponentSetMatcher::extractComponent(size_t index) const
-{
-  size_t lcount = 1;
-  size_t rcount = 0;
-
-  while (lcount > rcount) {
-    switch (m_expr[index]) {
-      case '<':
-        lcount++;
-        break;
-      case '>':
-        rcount++;
-        break;
-      case 0:
-        BOOST_THROW_EXCEPTION(Error("Square brackets mismatch"));
-        break;
-    }
-    index++;
-  }
-
-  return index;
-}
-
 } // namespace ndn
 
 #endif // NDN_UTIL_REGEX_REGEX_COMPONENT_SET_MATCHER_HPP