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_REPEAT_MATCHER_HPP |
| 9 | #define NDN_REGEX_REPEAT_MATCHER_HPP |
| 10 | |
| 11 | #include "regex-matcher.hpp" |
| 12 | |
| 13 | namespace ndn |
| 14 | { |
| 15 | |
| 16 | class RegexRepeatMatcher : public RegexMatcher |
| 17 | { |
| 18 | public: |
| 19 | RegexRepeatMatcher(const std::string expr, ptr_lib::shared_ptr<RegexBackrefManager> backRefManager, int indicator); |
| 20 | |
| 21 | virtual ~RegexRepeatMatcher(){} |
| 22 | |
| 23 | virtual bool |
| 24 | match(const Name & name, const int & offset, const int & len); |
| 25 | |
| 26 | protected: |
| 27 | /** |
| 28 | * @brief Compile the regular expression to generate the more matchers when necessary |
| 29 | * @returns true if compiling succeeds |
| 30 | */ |
| 31 | virtual void |
| 32 | compile(); |
| 33 | |
| 34 | |
| 35 | private: |
| 36 | bool |
| 37 | parseRepetition(); |
| 38 | |
| 39 | bool |
| 40 | recursiveMatch (int repeat, |
| 41 | const Name & name, |
| 42 | const int & offset, |
| 43 | const int &len); |
| 44 | |
| 45 | private: |
| 46 | int m_indicator; |
| 47 | int m_repeatMin; |
| 48 | int m_repeatMax; |
| 49 | }; |
| 50 | |
| 51 | }//ndn |
| 52 | |
| 53 | #endif |