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_TOP_MATCHER_HPP |
| 9 | #define NDN_REGEX_TOP_MATCHER_HPP |
| 10 | |
| 11 | #include <string> |
| 12 | |
| 13 | #include "regex-matcher.hpp" |
| 14 | #include "regex-pattern-list-matcher.hpp" |
| 15 | |
| 16 | namespace ndn |
| 17 | { |
| 18 | class RegexTopMatcher: public RegexMatcher |
| 19 | { |
| 20 | public: |
| 21 | RegexTopMatcher(const std::string & expr, const std::string & expand = ""); |
| 22 | |
| 23 | virtual ~RegexTopMatcher(); |
| 24 | |
| 25 | bool |
| 26 | match(const Name & name); |
| 27 | |
| 28 | virtual bool |
| 29 | match (const Name & name, const int & offset, const int & len); |
| 30 | |
| 31 | virtual Name |
| 32 | expand (const std::string & expand = ""); |
| 33 | |
| 34 | static ptr_lib::shared_ptr<RegexTopMatcher> |
| 35 | fromName(const Name& name, bool hasAnchor=false); |
| 36 | |
| 37 | protected: |
| 38 | virtual void |
| 39 | compile(); |
| 40 | |
| 41 | private: |
| 42 | std::string |
| 43 | getItemFromExpand(const std::string & expand, int & offset); |
| 44 | |
| 45 | static std::string |
| 46 | convertSpecialChar(const std::string& str); |
| 47 | |
| 48 | private: |
| 49 | const std::string m_expand; |
| 50 | ptr_lib::shared_ptr<RegexPatternListMatcher> m_primaryMatcher; |
| 51 | ptr_lib::shared_ptr<RegexPatternListMatcher> m_secondaryMatcher; |
| 52 | ptr_lib::shared_ptr<RegexBackrefManager> m_primaryBackRefManager; |
| 53 | ptr_lib::shared_ptr<RegexBackrefManager> m_secondaryBackRefManager; |
| 54 | bool m_secondaryUsed; |
| 55 | }; |
| 56 | |
| 57 | } |
| 58 | |
| 59 | #endif |
| 60 | |