175a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org// Copyright (C) 2014 Google Inc. 275a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org// 375a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org// Licensed under the Apache License, Version 2.0 (the "License"); 475a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org// you may not use this file except in compliance with the License. 575a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org// You may obtain a copy of the License at 675a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org// 775a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org// http://www.apache.org/licenses/LICENSE-2.0 875a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org// 975a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org// Unless required by applicable law or agreed to in writing, software 1075a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org// distributed under the License is distributed on an "AS IS" BASIS, 1175a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1275a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org// See the License for the specific language governing permissions and 1375a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org// limitations under the License. 1475a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org 1575a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org#ifndef I18N_ADDRESSINPUT_UTIL_STRING_COMPARE_H_ 1675a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org#define I18N_ADDRESSINPUT_UTIL_STRING_COMPARE_H_ 1775a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org 1875a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org#include <libaddressinput/util/basictypes.h> 1975a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org#include <libaddressinput/util/scoped_ptr.h> 2075a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org 2175a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org#include <string> 2275a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org 2375a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.orgnamespace i18n { 2475a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.orgnamespace addressinput { 2575a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org 2675a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.orgclass StringCompare { 2775a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org public: 2875a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org StringCompare(); 2975a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org ~StringCompare(); 3075a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org 3175a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org // Returns true if a human reader would consider |a| and |b| to be "the same". 3275a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org // Libaddressinput itself isn't really concerned about how this is done. This 3375a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org // default implementation just does case insensitive string matching. 3475a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org bool NaturalEquals(const std::string& a, const std::string& b) const; 3575a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org 3690e624a56973856b6b81112fc1cd815a4224aa96roubert@google.com // Comparison function for use with the STL analogous to NaturalEquals(). 3790e624a56973856b6b81112fc1cd815a4224aa96roubert@google.com // Libaddressinput itself isn't really concerned about how this is done, as 3890e624a56973856b6b81112fc1cd815a4224aa96roubert@google.com // long as it conforms to the STL requirements on less<> predicates. This 3990e624a56973856b6b81112fc1cd815a4224aa96roubert@google.com // default implementation is VERY SLOW! Must be replaced if you need speed. 4090e624a56973856b6b81112fc1cd815a4224aa96roubert@google.com bool NaturalLess(const std::string& a, const std::string& b) const; 4190e624a56973856b6b81112fc1cd815a4224aa96roubert@google.com 4275a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org private: 4375a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org class Impl; 4475a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org scoped_ptr<Impl> impl_; 4575a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org 4675a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org DISALLOW_COPY_AND_ASSIGN(StringCompare); 4775a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org}; 4875a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org 4975a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org} // namespace addressinput 5075a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org} // namespace i18n 5175a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org 5275a0cfdaa6edd47c9917172fa57701b5d22e83efrouslan@chromium.org#endif // I18N_ADDRESSINPUT_UTIL_STRING_COMPARE_H_ 53