blob: 56919f59f0c13cefebac597990be10aebc3291cc [file] [log] [blame]
Yingdi Yu5e974202014-01-29 16:59:06 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
11 *
12 * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
Yingdi Yu5e974202014-01-29 16:59:06 -080013 */
14
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080015#ifndef NDN_UTIL_REGEX_BACKREF_MANAGER_HPP
16#define NDN_UTIL_REGEX_BACKREF_MANAGER_HPP
Yingdi Yu5e974202014-01-29 16:59:06 -080017
Yingdi Yu5e974202014-01-29 16:59:06 -080018#include "../../common.hpp"
19
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080020namespace ndn {
Yingdi Yu5e974202014-01-29 16:59:06 -080021
22class RegexMatcher;
23
24class RegexBackrefManager
25{
26public:
27 RegexBackrefManager(){}
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070028
Yingdi Yu5e974202014-01-29 16:59:06 -080029 virtual ~RegexBackrefManager();
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070030
31 int
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080032 pushRef(shared_ptr<RegexMatcher> matcher);
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070033
34 void
Yingdi Yu5e974202014-01-29 16:59:06 -080035 popRef();
36
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070037 size_t
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080038 size();
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070039
40 shared_ptr<RegexMatcher>
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080041 getBackRef(int i);
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070042
Yingdi Yu5e974202014-01-29 16:59:06 -080043private:
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080044 std::vector<shared_ptr<RegexMatcher> > m_backRefs;
Yingdi Yu5e974202014-01-29 16:59:06 -080045};
46
Yingdi Yu5e974202014-01-29 16:59:06 -080047
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080048inline RegexBackrefManager::~RegexBackrefManager()
49{
50 m_backRefs.clear();
51}
52
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070053inline int
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080054RegexBackrefManager::pushRef(shared_ptr<RegexMatcher> matcher)
55{
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070056 size_t last = m_backRefs.size();
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080057 m_backRefs.push_back(matcher);
58
59 return last;
60}
61
62inline void
63RegexBackrefManager::popRef()
64{
65 m_backRefs.pop_back();
66}
67
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070068inline size_t
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080069RegexBackrefManager::size()
70{
71 return m_backRefs.size();
72}
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070073
74inline shared_ptr<RegexMatcher>
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080075RegexBackrefManager::getBackRef(int i)
76{
77 return m_backRefs[i];
78}
79
80
81} // namespace ndn
82
83#endif // NDN_UTIL_REGEX_BACKREF_MANAGER_HPP