blob: f11e431780229c251858f15321af0c02c55cd3ac [file] [log] [blame]
Yingdi Yu5e974202014-01-29 16:59:06 -08001/* -*- 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 Afanasyev36b84cf2014-02-17 19:34:18 -08008#ifndef NDN_UTIL_REGEX_BACKREF_MANAGER_HPP
9#define NDN_UTIL_REGEX_BACKREF_MANAGER_HPP
Yingdi Yu5e974202014-01-29 16:59:06 -080010
Yingdi Yu5e974202014-01-29 16:59:06 -080011#include "../../common.hpp"
12
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080013namespace ndn {
Yingdi Yu5e974202014-01-29 16:59:06 -080014
15class RegexMatcher;
16
17class RegexBackrefManager
18{
19public:
20 RegexBackrefManager(){}
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070021
Yingdi Yu5e974202014-01-29 16:59:06 -080022 virtual ~RegexBackrefManager();
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070023
24 int
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080025 pushRef(shared_ptr<RegexMatcher> matcher);
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070026
27 void
Yingdi Yu5e974202014-01-29 16:59:06 -080028 popRef();
29
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070030 size_t
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080031 size();
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070032
33 shared_ptr<RegexMatcher>
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080034 getBackRef(int i);
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070035
Yingdi Yu5e974202014-01-29 16:59:06 -080036private:
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080037 std::vector<shared_ptr<RegexMatcher> > m_backRefs;
Yingdi Yu5e974202014-01-29 16:59:06 -080038};
39
Yingdi Yu5e974202014-01-29 16:59:06 -080040
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080041inline RegexBackrefManager::~RegexBackrefManager()
42{
43 m_backRefs.clear();
44}
45
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070046inline int
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080047RegexBackrefManager::pushRef(shared_ptr<RegexMatcher> matcher)
48{
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070049 size_t last = m_backRefs.size();
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080050 m_backRefs.push_back(matcher);
51
52 return last;
53}
54
55inline void
56RegexBackrefManager::popRef()
57{
58 m_backRefs.pop_back();
59}
60
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070061inline size_t
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080062RegexBackrefManager::size()
63{
64 return m_backRefs.size();
65}
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070066
67inline shared_ptr<RegexMatcher>
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080068RegexBackrefManager::getBackRef(int i)
69{
70 return m_backRefs[i];
71}
72
73
74} // namespace ndn
75
76#endif // NDN_UTIL_REGEX_BACKREF_MANAGER_HPP