1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_URL_MATCHER_STRING_PATTERN_H_ 6 #define COMPONENTS_URL_MATCHER_STRING_PATTERN_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "base/basictypes.h" 12 #include "components/url_matcher/url_matcher_export.h" 13 14 namespace url_matcher { 15 16 // An individual pattern of a substring or regex matcher. A pattern consists of 17 // a string (interpreted as individual bytes, no character encoding) and an 18 // identifier. 19 // IDs are returned to the caller of SubstringSetMatcher::Match() or 20 // RegexMatcher::MatchURL() to help the caller to figure out what 21 // patterns matched a string. All patterns registered to a matcher 22 // need to contain unique IDs. 23 class URL_MATCHER_EXPORT StringPattern { 24 public: 25 typedef int ID; 26 27 StringPattern(const std::string& pattern, ID id); 28 ~StringPattern(); pattern()29 const std::string& pattern() const { return pattern_; } id()30 ID id() const { return id_; } 31 32 bool operator<(const StringPattern& rhs) const; 33 34 private: 35 std::string pattern_; 36 ID id_; 37 38 DISALLOW_COPY_AND_ASSIGN(StringPattern); 39 }; 40 41 } // namespace url_matcher 42 43 #endif // COMPONENTS_URL_MATCHER_STRING_PATTERN_H_ 44