blob: e2eabe8ef10eedbfc33a9f2af8805cbda7209678 [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();
Yingdi Yu5e974202014-01-29 16:59:06 -080033};
34
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080035} // namespace ndn
Yingdi Yu5e974202014-01-29 16:59:06 -080036
Alexander Afanasyev36b84cf2014-02-17 19:34:18 -080037#include "regex-pattern-list-matcher.hpp"
38
39namespace ndn {
40
41inline RegexBackrefMatcher::RegexBackrefMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backRefManager)
42 : RegexMatcher (expr, EXPR_BACKREF, backRefManager)
43{
44 // compile();
45}
46
47inline void
48RegexBackrefMatcher::compile()
49{
50 int lastIndex = m_expr.size() - 1;
51 if('(' == m_expr[0] && ')' == m_expr[lastIndex]){
52 // m_backRefManager->pushRef(this);
53
54 shared_ptr<RegexMatcher> matcher(new RegexPatternListMatcher(m_expr.substr(1, lastIndex - 1), m_backrefManager));
55 m_matcherList.push_back(matcher);
56 }
57 else
58 throw RegexMatcher::Error(std::string("Error: RegexBackrefMatcher.Compile(): ")
59 + " Unrecognoized format " + m_expr);
60}
61
62
63} // namespace ndn
64
65#endif // NDN_UTIL_REGEX_REGEX_BACKREF_MATCHER_HPP
Yingdi Yu5e974202014-01-29 16:59:06 -080066
67