OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sync/syncable/syncable_id.h" | 5 #include "sync/syncable/syncable_id.h" |
6 | 6 |
7 #include <iosfwd> | 7 #include <iosfwd> |
8 | 8 |
9 #include "base/string_util.h" | |
10 #include "base/values.h" | 9 #include "base/values.h" |
11 | 10 |
12 using std::ostream; | 11 using std::ostream; |
13 using std::string; | 12 using std::string; |
14 | 13 |
15 namespace syncable { | 14 namespace syncable { |
16 | 15 |
17 ostream& operator<<(ostream& out, const Id& id) { | 16 ostream& operator<<(ostream& out, const Id& id) { |
18 out << id.s_; | 17 out << id.s_; |
19 return out; | 18 return out; |
(...skipping 30 matching lines...) Expand all Loading... |
50 } | 49 } |
51 | 50 |
52 Id Id::GetLexicographicSuccessor() const { | 51 Id Id::GetLexicographicSuccessor() const { |
53 // The successor of a string is given by appending the least | 52 // The successor of a string is given by appending the least |
54 // character in the alphabet. | 53 // character in the alphabet. |
55 Id id = *this; | 54 Id id = *this; |
56 id.s_.push_back(0); | 55 id.s_.push_back(0); |
57 return id; | 56 return id; |
58 } | 57 } |
59 | 58 |
60 bool Id::ContainsStringCaseInsensitive( | |
61 const std::string& lowercase_query) const { | |
62 DCHECK_EQ(StringToLowerASCII(lowercase_query), lowercase_query); | |
63 return StringToLowerASCII(s_).find(lowercase_query) != std::string::npos; | |
64 } | |
65 | |
66 // static | 59 // static |
67 Id Id::GetLeastIdForLexicographicComparison() { | 60 Id Id::GetLeastIdForLexicographicComparison() { |
68 Id id; | 61 Id id; |
69 id.s_.clear(); | 62 id.s_.clear(); |
70 return id; | 63 return id; |
71 } | 64 } |
72 | 65 |
73 Id GetNullId() { | 66 Id GetNullId() { |
74 return Id(); // Currently == root. | 67 return Id(); // Currently == root. |
75 } | 68 } |
76 | 69 |
77 } // namespace syncable | 70 } // namespace syncable |
OLD | NEW |