blob: 5ae5f35eca6425b3e4c0186f066e39edb4abd2a6 [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_REGEX_BACKREF_MATCHER_HPP
9#define NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP
10
11#include "../../common.hpp"
Yingdi Yu5e974202014-01-29 16:59:06 -080012
13#include "regex-matcher.hpp"
14
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080015namespace ndn {
Yingdi Yu5e974202014-01-29 16:59:06 -080016
17class RegexBackrefMatcher : public RegexMatcher
18{
19public:
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080020 RegexBackrefMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager);
Yingdi Yu5e974202014-01-29 16:59:06 -080021
22 virtual ~RegexBackrefMatcher(){}
23
24 void
25 lateCompile()
26 {
27 compile();
28 }
29
30protected:
31 virtual void
32 compile();
33
34private:
35 int m_refNum;
36};
37
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080038} // namespace ndn
Yingdi Yu5e974202014-01-29 16:59:06 -080039
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080040#include "regex-pattern-list-matcher.hpp"
41
42namespace ndn {
43
44inline RegexBackrefMatcher::RegexBackrefMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager)
45 : RegexMatcher (expr, EXPR_BACKREF, backRefManager)
46{
47 // compile();
48}
49
50inline void
51RegexBackrefMatcher::compile()
52{
53 int lastIndex = m_expr.size() - 1;
54 if('(' == m_expr[0] && ')' == m_expr[lastIndex]){
55 // m_backRefManager->pushRef(this);
56
57 shared_ptr<RegexMatcher> matcher(new RegexPatternListMatcher(m_expr.substr(1, lastIndex - 1), m_backrefManager));
58 m_matcherList.push_back(matcher);
59 }
60 else
61 throw RegexMatcher::Error(std::string("Error: RegexBackrefMatcher.Compile(): ")
62 + " Unrecognoized format " + m_expr);
63}
64
65
66} // namespace ndn
67
68#endif // NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP
Yingdi Yu5e974202014-01-29 16:59:06 -080069
70