regex-top-matcher.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2021 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * 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.
20  *
21  * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
22  */
23 
24 #ifndef NDN_CXX_UTIL_REGEX_REGEX_TOP_MATCHER_HPP
25 #define NDN_CXX_UTIL_REGEX_REGEX_TOP_MATCHER_HPP
26 
28 
29 namespace ndn {
30 
31 class RegexPatternListMatcher;
32 class RegexBackrefManager;
33 
35 {
36 public:
37  explicit
38  RegexTopMatcher(const std::string& expr, const std::string& expand = "");
39 
40  bool
41  match(const Name& name);
42 
43  bool
44  match(const Name& name, size_t offset, size_t len) override;
45 
46  virtual Name
47  expand(const std::string& expand = "");
48 
49  static shared_ptr<RegexTopMatcher>
50  fromName(const Name& name, bool hasAnchor = false);
51 
52 private:
53  void
54  compile();
55 
56  static std::string
57  getItemFromExpand(const std::string& expand, size_t& offset);
58 
59  static std::string
60  convertSpecialChar(const std::string& str);
61 
63  const std::string m_expand;
64  shared_ptr<RegexPatternListMatcher> m_primaryMatcher;
65  shared_ptr<RegexPatternListMatcher> m_secondaryMatcher;
66  shared_ptr<RegexBackrefManager> m_primaryBackrefManager;
67  shared_ptr<RegexBackrefManager> m_secondaryBackrefManager;
68  bool m_isSecondaryUsed;
69 };
70 
71 } // namespace ndn
72 
73 #endif // NDN_CXX_UTIL_REGEX_REGEX_TOP_MATCHER_HPP
Represents an absolute name.
Definition: name.hpp:44
static shared_ptr< RegexTopMatcher > fromName(const Name &name, bool hasAnchor=false)
bool match(const Name &name)
virtual Name expand(const std::string &expand="")
RegexTopMatcher(const std::string &expr, const std::string &expand="")
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:48
Definition: data.cpp:25