blob: 414d4fdbda19c0b742ced33da837c6d4c15027d0 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Yingdi Yu5e974202014-01-29 16:59:06 -08002/**
Qiuhan Ding699725d2015-05-24 01:41:09 -07003 * Copyright (c) 2013-2015 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Yingdi Yu5e974202014-01-29 16:59:06 -080020 */
21
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080022#ifndef NDN_UTIL_REGEX_REGEX_COMPONENT_MATCHER_HPP
23#define NDN_UTIL_REGEX_REGEX_COMPONENT_MATCHER_HPP
Yingdi Yu5e974202014-01-29 16:59:06 -080024
25#include <boost/regex.hpp>
26
27#include "regex-matcher.hpp"
28#include "regex-pseudo-matcher.hpp"
29
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080030namespace ndn {
31
Yingdi Yu5e974202014-01-29 16:59:06 -080032class RegexComponentMatcher : public RegexMatcher
33{
34public:
35 /**
36 * @brief Create a RegexComponent matcher from expr
37 * @param expr The standard regular expression to match a component
Alexander Afanasyevb6b21b32014-04-28 22:38:03 -070038 * @param backrefManager The back reference manager
39 * @param isExactMatch The flag to provide exact match
Yingdi Yu5e974202014-01-29 16:59:06 -080040 */
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070041 RegexComponentMatcher(const std::string& expr,
Alexander Afanasyevb6b21b32014-04-28 22:38:03 -070042 shared_ptr<RegexBackrefManager> backrefManager,
43 bool isExactMatch = true);
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070044
Alexander Afanasyevb6b21b32014-04-28 22:38:03 -070045 virtual
Qiuhan Ding699725d2015-05-24 01:41:09 -070046 ~RegexComponentMatcher() NDN_CXX_DECL_FINAL;
Yingdi Yu5e974202014-01-29 16:59:06 -080047
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070048 virtual bool
Qiuhan Ding699725d2015-05-24 01:41:09 -070049 match(const Name& name, size_t offset, size_t len = 1) NDN_CXX_DECL_FINAL;
Yingdi Yu5e974202014-01-29 16:59:06 -080050
51protected:
52 /**
53 * @brief Compile the regular expression to generate the more matchers when necessary
54 * @returns true if compiling succeeds
55 */
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070056 virtual void
Qiuhan Ding699725d2015-05-24 01:41:09 -070057 compile() NDN_CXX_DECL_FINAL;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070058
Yingdi Yu5e974202014-01-29 16:59:06 -080059private:
Alexander Afanasyevb6b21b32014-04-28 22:38:03 -070060 bool m_isExactMatch;
Yingdi Yu5e974202014-01-29 16:59:06 -080061 boost::regex m_componentRegex;
Alexander Afanasyevb6b21b32014-04-28 22:38:03 -070062 std::vector<shared_ptr<RegexPseudoMatcher> > m_pseudoMatchers;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070063
Yingdi Yu5e974202014-01-29 16:59:06 -080064};
Yingdi Yu5e974202014-01-29 16:59:06 -080065
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080066} // namespace ndn
67
68#endif // NDN_UTIL_REGEX_REGEX_COMPONENT_MATCHER_HPP