示例#1
0
void
NdnRegexComponentSetMatcher::compile()
{
  if (expr_.size() < 2)
    throw NdnRegexMatcherBase::Error
      ("Regexp compile error (cannot parse " + expr_ + ")");

  switch (expr_[0]) {
  case '<':
    return compileSingleComponent();

  case '[':
    {
      size_t lastIndex = expr_.size() - 1;
      if (']' != expr_[lastIndex])
        throw NdnRegexMatcherBase::Error
          ("Regexp compile error (no matching ']' in " + expr_ + ")");

      if ('^' == expr_[1]) {
        isInclusion_ = false;
        compileMultipleComponents(2, lastIndex);
      }
      else
        compileMultipleComponents(1, lastIndex);

      break;
    }

  default:
    throw NdnRegexMatcherBase::Error
      ("Regexp compile error (cannot parse " + expr_ + ")");
  }
}
inline void
RegexComponentSetMatcher::compile()
{
  if (m_expr.size() < 2)
    BOOST_THROW_EXCEPTION(RegexMatcher::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(RegexMatcher::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(RegexMatcher::Error("Regexp compile error (cannot parse " +
                                              m_expr + ")"));
  }
}