blob: 764726f1cea93e5c75f6ba25b943817f30d8b4e6 [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
8#ifndef NDN_REGEX_TOP_MATCHER_HPP
9#define NDN_REGEX_TOP_MATCHER_HPP
10
11#include <string>
12
13#include "regex-matcher.hpp"
14#include "regex-pattern-list-matcher.hpp"
15
16namespace ndn
17{
18class RegexTopMatcher: public RegexMatcher
19{
20public:
21 RegexTopMatcher(const std::string & expr, const std::string & expand = "");
22
23 virtual ~RegexTopMatcher();
24
25 bool
26 match(const Name & name);
27
28 virtual bool
29 match (const Name & name, const int & offset, const int & len);
30
31 virtual Name
32 expand (const std::string & expand = "");
33
34 static ptr_lib::shared_ptr<RegexTopMatcher>
35 fromName(const Name& name, bool hasAnchor=false);
36
37protected:
38 virtual void
39 compile();
40
41private:
42 std::string
43 getItemFromExpand(const std::string & expand, int & offset);
44
45 static std::string
46 convertSpecialChar(const std::string& str);
47
48private:
49 const std::string m_expand;
50 ptr_lib::shared_ptr<RegexPatternListMatcher> m_primaryMatcher;
51 ptr_lib::shared_ptr<RegexPatternListMatcher> m_secondaryMatcher;
52 ptr_lib::shared_ptr<RegexBackrefManager> m_primaryBackRefManager;
53 ptr_lib::shared_ptr<RegexBackrefManager> m_secondaryBackRefManager;
54 bool m_secondaryUsed;
55};
56
57}
58
59#endif
60