1// Copyright (C) 2014 Google Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef I18N_ADDRESSINPUT_UTIL_STRING_COMPARE_H_
16#define I18N_ADDRESSINPUT_UTIL_STRING_COMPARE_H_
17
18#include <libaddressinput/util/basictypes.h>
19#include <libaddressinput/util/scoped_ptr.h>
20
21#include <string>
22
23namespace i18n {
24namespace addressinput {
25
26class StringCompare {
27 public:
28  StringCompare();
29  ~StringCompare();
30
31  // Returns true if a human reader would consider |a| and |b| to be "the same".
32  // Libaddressinput itself isn't really concerned about how this is done. This
33  // default implementation just does case insensitive string matching.
34  bool NaturalEquals(const std::string& a, const std::string& b) const;
35
36  // Comparison function for use with the STL analogous to NaturalEquals().
37  // Libaddressinput itself isn't really concerned about how this is done, as
38  // long as it conforms to the STL requirements on less<> predicates. This
39  // default implementation is VERY SLOW! Must be replaced if you need speed.
40  bool NaturalLess(const std::string& a, const std::string& b) const;
41
42 private:
43  class Impl;
44  scoped_ptr<Impl> impl_;
45
46  DISALLOW_COPY_AND_ASSIGN(StringCompare);
47};
48
49}  // namespace addressinput
50}  // namespace i18n
51
52#endif  // I18N_ADDRESSINPUT_UTIL_STRING_COMPARE_H_
53