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 REGEX_COMPONENT_SET_MATCHER_HPP |
| 9 | #define REGEX_COMPONENT_SET_MATCHER_HPP |
| 10 | |
| 11 | #include <set> |
| 12 | |
| 13 | #include "regex-matcher.hpp" |
| 14 | #include "regex-component-matcher.hpp" |
| 15 | |
| 16 | namespace ndn |
| 17 | { |
| 18 | |
| 19 | class RegexComponentSetMatcher : public RegexMatcher |
| 20 | { |
| 21 | |
| 22 | public: |
| 23 | /** |
| 24 | * @brief Create a RegexComponentSetMatcher matcher from expr |
| 25 | * @param expr The standard regular expression to match a component |
| 26 | * @param exact The flag to provide exact match |
| 27 | * @param backRefNum The starting back reference number |
| 28 | */ |
| 29 | RegexComponentSetMatcher(const std::string expr, ptr_lib::shared_ptr<RegexBackrefManager> backRefManager); |
| 30 | |
| 31 | virtual ~RegexComponentSetMatcher(); |
| 32 | |
| 33 | virtual bool |
| 34 | match(const Name & name, const int & offset, const int & len = 1); |
| 35 | |
| 36 | protected: |
| 37 | /** |
| 38 | * @brief Compile the regular expression to generate the more matchers when necessary |
| 39 | * @returns true if compiling succeeds |
| 40 | */ |
| 41 | virtual void |
| 42 | compile(); |
| 43 | |
| 44 | private: |
| 45 | int |
| 46 | extractComponent(int index); |
| 47 | |
| 48 | void |
| 49 | compileSingleComponent(); |
| 50 | |
| 51 | void |
| 52 | compileMultipleComponents(const int start, const int lastIndex); |
| 53 | |
| 54 | private: |
| 55 | std::set<ptr_lib::shared_ptr<RegexComponentMatcher> > m_components; |
| 56 | bool m_include; |
| 57 | }; |
| 58 | |
| 59 | }//ndn |
| 60 | |
| 61 | #endif |