Yingdi Yu | 5e97420 | 2014-01-29 16:59:06 -0800 | [diff] [blame] | 1 | /* -*- 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 | |
| 8 | #include <boost/regex.hpp> |
| 9 | |
| 10 | #include "regex-backref-matcher.hpp" |
| 11 | #include "regex-pattern-list-matcher.hpp" |
| 12 | |
| 13 | #include "../logging.hpp" |
| 14 | |
| 15 | INIT_LOGGER ("RegexBackrefMatcher"); |
| 16 | |
| 17 | using namespace std; |
| 18 | |
| 19 | namespace ndn |
| 20 | { |
| 21 | |
| 22 | RegexBackrefMatcher::RegexBackrefMatcher(const string expr, ptr_lib::shared_ptr<RegexBackrefManager> backRefManager) |
| 23 | : RegexMatcher (expr, EXPR_BACKREF, backRefManager) |
| 24 | { |
| 25 | // _LOG_TRACE ("Enter RegexBackrefMatcher Constructor: "); |
| 26 | // compile(); |
| 27 | // _LOG_TRACE ("Exit RegexBackrefMatcher Constructor: "); |
| 28 | } |
| 29 | |
| 30 | void |
| 31 | RegexBackrefMatcher::compile() |
| 32 | { |
| 33 | // _LOG_TRACE ("Enter RegexBackrefMatcher::compile()"); |
| 34 | |
| 35 | string errMsg = "Error: RegexBackrefMatcher.Compile(): "; |
| 36 | |
| 37 | // _LOG_DEBUG ("m_backRefManager: " << m_backRefManager); |
| 38 | |
| 39 | int lastIndex = m_expr.size() - 1; |
| 40 | if('(' == m_expr[0] && ')' == m_expr[lastIndex]){ |
| 41 | // m_backRefManager->pushRef(this); |
| 42 | |
| 43 | ptr_lib::shared_ptr<RegexMatcher> matcher = ptr_lib::make_shared<RegexPatternListMatcher>(m_expr.substr(1, lastIndex - 1), m_backrefManager); |
| 44 | m_matcherList.push_back(matcher); |
| 45 | |
| 46 | } |
| 47 | else |
| 48 | throw RegexMatcher::Error(errMsg + " Unrecognoized format " + m_expr); |
| 49 | |
| 50 | // _LOG_TRACE ("Exit RegexBackrefMatcher::compile"); |
| 51 | } |
| 52 | |
| 53 | }//ndn |
| 54 | |
| 55 | |
| 56 | |
| 57 | |