Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: chrome/common/string_ordinal.cc

Issue 8898027: Revert 114083 - Convert app_launch_index and page_index from int to StringOrdinal. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/string_ordinal.h ('k') | chrome/common/string_ordinal_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/common/string_ordinal.h" 5 #include "chrome/common/string_ordinal.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstddef> 8 #include <cstddef>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 StringOrdinal::StringOrdinal(const std::string& string_ordinal) 168 StringOrdinal::StringOrdinal(const std::string& string_ordinal)
169 : string_ordinal_(string_ordinal), 169 : string_ordinal_(string_ordinal),
170 is_valid_(IsValidStringOrdinal(string_ordinal_)) { 170 is_valid_(IsValidStringOrdinal(string_ordinal_)) {
171 } 171 }
172 172
173 StringOrdinal::StringOrdinal() : string_ordinal_(""), 173 StringOrdinal::StringOrdinal() : string_ordinal_(""),
174 is_valid_(false) { 174 is_valid_(false) {
175 } 175 }
176 176
177 StringOrdinal StringOrdinal::CreateInitialOrdinal() {
178 return StringOrdinal(std::string(1, kMidDigit));
179 }
180
181 bool StringOrdinal::IsValid() const { 177 bool StringOrdinal::IsValid() const {
182 return is_valid_; 178 return is_valid_;
183 } 179 }
184 180
185 bool StringOrdinal::LessThan(const StringOrdinal& other) const { 181 bool StringOrdinal::LessThan(const StringOrdinal& other) const {
186 CHECK(IsValid()); 182 CHECK(IsValid());
187 CHECK(other.IsValid()); 183 CHECK(other.IsValid());
188 return string_ordinal_ < other.string_ordinal_; 184 return string_ordinal_ < other.string_ordinal_;
189 } 185 }
190 186
191 bool StringOrdinal::GreaterThan(const StringOrdinal& other) const {
192 CHECK(IsValid());
193 CHECK(other.IsValid());
194 return string_ordinal_ > other.string_ordinal_;
195 }
196
197 bool StringOrdinal::Equal(const StringOrdinal& other) const { 187 bool StringOrdinal::Equal(const StringOrdinal& other) const {
198 CHECK(IsValid()); 188 CHECK(IsValid());
199 CHECK(other.IsValid()); 189 CHECK(other.IsValid());
200 return string_ordinal_ == other.string_ordinal_; 190 return string_ordinal_ == other.string_ordinal_;
201 } 191 }
202 192
203 StringOrdinal StringOrdinal::CreateBetween(const StringOrdinal& other) const { 193 StringOrdinal StringOrdinal::CreateBetween(const StringOrdinal& other) const {
204 CHECK(IsValid()); 194 CHECK(IsValid());
205 CHECK(other.IsValid()); 195 CHECK(other.IsValid());
206 CHECK(!Equal(other)); 196 CHECK(!Equal(other));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // Even though |end| is already a valid StringOrdinal that is greater than 231 // Even though |end| is already a valid StringOrdinal that is greater than
242 // |*this|, we don't return it because we wouldn't have much space after 232 // |*this|, we don't return it because we wouldn't have much space after
243 // it to insert potential future values. 233 // it to insert potential future values.
244 return CreateBetween(StringOrdinal(end)); 234 return CreateBetween(StringOrdinal(end));
245 } 235 }
246 236
247 std::string StringOrdinal::ToString() const { 237 std::string StringOrdinal::ToString() const {
248 CHECK(IsValid()); 238 CHECK(IsValid());
249 return string_ordinal_; 239 return string_ordinal_;
250 } 240 }
251
252 bool StringOrdinalLessThan::operator() (const StringOrdinal& lhs,
253 const StringOrdinal& rhs) const {
254 return lhs.LessThan(rhs);
255 }
OLDNEW
« no previous file with comments | « chrome/common/string_ordinal.h ('k') | chrome/common/string_ordinal_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698