NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
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-2018 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_UTIL_REGEX_REGEX_TOP_MATCHER_HPP
25 #define NDN_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 protected:
53  void
54  compile() override;
55 
56 private:
57  static std::string
58  getItemFromExpand(const std::string& expand, size_t& offset);
59 
60  static std::string
61  convertSpecialChar(const std::string& str);
62 
64  const std::string m_expand;
65  shared_ptr<RegexPatternListMatcher> m_primaryMatcher;
66  shared_ptr<RegexPatternListMatcher> m_secondaryMatcher;
67  shared_ptr<RegexBackrefManager> m_primaryBackrefManager;
68  shared_ptr<RegexBackrefManager> m_secondaryBackrefManager;
69  bool m_isSecondaryUsed;
70 };
71 
72 } // namespace ndn
73 
74 #endif // NDN_UTIL_REGEX_REGEX_TOP_MATCHER_HPP
ndn::RegexTopMatcher::fromName
static shared_ptr< RegexTopMatcher > fromName(const Name &name, bool hasAnchor=false)
Definition: regex-top-matcher.cpp:171
ndn::RegexTopMatcher
Definition: regex-top-matcher.hpp:35
regex-matcher.hpp
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
ndn::RegexMatcher
Definition: regex-matcher.hpp:33
ndn::RegexTopMatcher::expand
virtual Name expand(const std::string &expand="")
Definition: regex-top-matcher.cpp:92
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:48
ndn::RegexTopMatcher::match
bool match(const Name &name)
Definition: regex-top-matcher.cpp:65
ndn::RegexTopMatcher::RegexTopMatcher
RegexTopMatcher(const std::string &expr, const std::string &expand="")
Definition: regex-top-matcher.cpp:33
ndn::RegexTopMatcher::compile
void compile() override
Compile the regular expression to generate the more matchers when necessary.
Definition: regex-top-matcher.cpp:44
ndn::name
Definition: name-component-types.hpp:33
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34