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

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

Issue 8198003: Convert app_launch_index and page_index from int to StringOrdinal. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixing clang compile 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
177 bool StringOrdinal::IsValid() const { 181 bool StringOrdinal::IsValid() const {
178 return is_valid_; 182 return is_valid_;
179 } 183 }
180 184
181 bool StringOrdinal::LessThan(const StringOrdinal& other) const { 185 bool StringOrdinal::LessThan(const StringOrdinal& other) const {
182 CHECK(IsValid()); 186 CHECK(IsValid());
183 CHECK(other.IsValid()); 187 CHECK(other.IsValid());
184 return string_ordinal_ < other.string_ordinal_; 188 return string_ordinal_ < other.string_ordinal_;
185 } 189 }
186 190
191 bool StringOrdinal::GreaterThan(const StringOrdinal& other) const {
192 CHECK(IsValid());
193 CHECK(other.IsValid());
194 return string_ordinal_ > other.string_ordinal_;
195 }
196
187 bool StringOrdinal::Equal(const StringOrdinal& other) const { 197 bool StringOrdinal::Equal(const StringOrdinal& other) const {
188 CHECK(IsValid()); 198 CHECK(IsValid());
189 CHECK(other.IsValid()); 199 CHECK(other.IsValid());
190 return string_ordinal_ == other.string_ordinal_; 200 return string_ordinal_ == other.string_ordinal_;
191 } 201 }
192 202
193 StringOrdinal StringOrdinal::CreateBetween(const StringOrdinal& other) const { 203 StringOrdinal StringOrdinal::CreateBetween(const StringOrdinal& other) const {
194 CHECK(IsValid()); 204 CHECK(IsValid());
195 CHECK(other.IsValid()); 205 CHECK(other.IsValid());
196 CHECK(!Equal(other)); 206 CHECK(!Equal(other));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // Even though |end| is already a valid StringOrdinal that is greater than 241 // Even though |end| is already a valid StringOrdinal that is greater than
232 // |*this|, we don't return it because we wouldn't have much space after 242 // |*this|, we don't return it because we wouldn't have much space after
233 // it to insert potential future values. 243 // it to insert potential future values.
234 return CreateBetween(StringOrdinal(end)); 244 return CreateBetween(StringOrdinal(end));
235 } 245 }
236 246
237 std::string StringOrdinal::ToString() const { 247 std::string StringOrdinal::ToString() const {
238 CHECK(IsValid()); 248 CHECK(IsValid());
239 return string_ordinal_; 249 return string_ordinal_;
240 } 250 }
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