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 | |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 8 | #ifndef NDN_UTIL_REGEX_BACKREF_MANAGER_HPP |
| 9 | #define NDN_UTIL_REGEX_BACKREF_MANAGER_HPP |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 10 | |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 11 | #include "../../common.hpp" |
| 12 | |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 13 | namespace ndn { |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 14 | |
| 15 | class RegexMatcher; |
| 16 | |
| 17 | class RegexBackrefManager |
| 18 | { |
| 19 | public: |
| 20 | RegexBackrefManager(){} |
| 21 | |
| 22 | virtual ~RegexBackrefManager(); |
| 23 | |
| 24 | int |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 25 | pushRef(shared_ptr<RegexMatcher> matcher); |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 26 | |
| 27 | void |
| 28 | popRef(); |
| 29 | |
| 30 | int |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 31 | size(); |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 32 | |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 33 | shared_ptr<RegexMatcher> |
| 34 | getBackRef(int i); |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 35 | |
| 36 | private: |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 37 | std::vector<shared_ptr<RegexMatcher> > m_backRefs; |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 38 | }; |
| 39 | |
Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 40 | |
Alexander Afanasyev | 36b84cf | 2014-02-17 19:34:18 -0800 | [diff] [blame] | 41 | inline RegexBackrefManager::~RegexBackrefManager() |
| 42 | { |
| 43 | m_backRefs.clear(); |
| 44 | } |
| 45 | |
| 46 | inline int |
| 47 | RegexBackrefManager::pushRef(shared_ptr<RegexMatcher> matcher) |
| 48 | { |
| 49 | int last = m_backRefs.size(); |
| 50 | m_backRefs.push_back(matcher); |
| 51 | |
| 52 | return last; |
| 53 | } |
| 54 | |
| 55 | inline void |
| 56 | RegexBackrefManager::popRef() |
| 57 | { |
| 58 | m_backRefs.pop_back(); |
| 59 | } |
| 60 | |
| 61 | inline int |
| 62 | RegexBackrefManager::size() |
| 63 | { |
| 64 | return m_backRefs.size(); |
| 65 | } |
| 66 | |
| 67 | inline shared_ptr<RegexMatcher> |
| 68 | RegexBackrefManager::getBackRef(int i) |
| 69 | { |
| 70 | return m_backRefs[i]; |
| 71 | } |
| 72 | |
| 73 | |
| 74 | } // namespace ndn |
| 75 | |
| 76 | #endif // NDN_UTIL_REGEX_BACKREF_MANAGER_HPP |