blob: bebaedb2f55e38e809df692bfd7cda536e17a64f [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(){}
21
22 virtual ~RegexBackrefManager();
23
24 int
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080025 pushRef(shared_ptr<RegexMatcher> matcher);
Yingdi Yu5e974202014-01-29 16:59:06 -080026
27 void
28 popRef();
29
30 int
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080031 size();
Yingdi Yu5e974202014-01-29 16:59:06 -080032
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080033 shared_ptr<RegexMatcher>
34 getBackRef(int i);
Yingdi Yu5e974202014-01-29 16:59:06 -080035
36private:
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
46inline int
47RegexBackrefManager::pushRef(shared_ptr<RegexMatcher> matcher)
48{
49 int last = m_backRefs.size();
50 m_backRefs.push_back(matcher);
51
52 return last;
53}
54
55inline void
56RegexBackrefManager::popRef()
57{
58 m_backRefs.pop_back();
59}
60
61inline int
62RegexBackrefManager::size()
63{
64 return m_backRefs.size();
65}
66
67inline shared_ptr<RegexMatcher>
68RegexBackrefManager::getBackRef(int i)
69{
70 return m_backRefs[i];
71}
72
73
74} // namespace ndn
75
76#endif // NDN_UTIL_REGEX_BACKREF_MANAGER_HPP