Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Yingdi Yu <yingdi@cs.ucla.edu> |
| 5 | * See COPYING for copyright and distribution information. |
| 6 | */ |
| 7 | |
| 8 | #ifndef NDN_REGEX_COMPONENT_HPP |
| 9 | #define NDN_REGEX_COMPONENT_HPP |
| 10 | |
| 11 | #include <boost/regex.hpp> |
| 12 | |
| 13 | #include "regex-matcher.hpp" |
| 14 | #include "regex-pseudo-matcher.hpp" |
| 15 | |
| 16 | |
| 17 | namespace ndn |
| 18 | { |
| 19 | class RegexComponentMatcher : public RegexMatcher |
| 20 | { |
| 21 | public: |
| 22 | /** |
| 23 | * @brief Create a RegexComponent matcher from expr |
| 24 | * @param expr The standard regular expression to match a component |
| 25 | * @param backRefManager The back reference manager |
| 26 | * @param exact The flag to provide exact match |
| 27 | */ |
| 28 | RegexComponentMatcher(const std::string& expr, |
| 29 | ptr_lib::shared_ptr<RegexBackrefManager> backRefManager, |
| 30 | bool exact = true); |
| 31 | |
| 32 | virtual ~RegexComponentMatcher() {}; |
| 33 | |
| 34 | virtual bool |
| 35 | match(const Name & name, const int & offset, const int &len = 1); |
| 36 | |
| 37 | protected: |
| 38 | /** |
| 39 | * @brief Compile the regular expression to generate the more matchers when necessary |
| 40 | * @returns true if compiling succeeds |
| 41 | */ |
| 42 | virtual void |
| 43 | compile(); |
| 44 | |
| 45 | private: |
| 46 | bool m_exact; |
| 47 | boost::regex m_componentRegex; |
| 48 | std::vector<ptr_lib::shared_ptr<RegexPseudoMatcher> > m_pseudoMatcher; |
| 49 | |
| 50 | }; |
| 51 | |
| 52 | }//ndn |
| 53 | |
| 54 | #endif |