Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_COMMON_STRING_INDEX_H_ | |
| 6 #define CHROME_COMMON_STRING_INDEX_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
|
akalin
2011/10/14 10:16:29
what is this for?
if this is for size_t, #include
| |
| 12 | |
| 13 class StringIndex { | |
|
akalin
2011/10/14 10:16:29
add comment explaining what the class is for
| |
| 14 public: | |
| 15 // Create a valid StringIndex if the str matches [A-Z]*[B-Z], | |
|
akalin
2011/10/14 10:16:29
str -> string
| |
| 16 // otherwise create an invalid StringIndex | |
|
akalin
2011/10/14 10:16:29
end with period
| |
| 17 explicit StringIndex(const std::string& str); | |
| 18 | |
| 19 // Create an invalid StringIndex | |
|
akalin
2011/10/14 10:16:29
end with period
| |
| 20 StringIndex(); | |
| 21 | |
| 22 // Check to see if this matches [A-Z]*[B-Z] | |
|
akalin
2011/10/14 10:16:29
Returns true iff this was initialized with a strin
| |
| 23 bool IsValid() const; | |
| 24 | |
| 25 bool LessThan(const StringIndex& other) const; | |
|
akalin
2011/10/14 10:16:29
probably should include an Equals() mem-fn for con
akalin
2011/10/14 10:16:29
add comment
| |
| 26 | |
| 27 // LessThan(other) must hold. Returns a StringIndex x s.t. LessThan(x) | |
|
akalin
2011/10/14 10:16:29
clean up this comment (e.g., s.t. -> such that)
| |
| 28 // holds, and x.LessThan(other) holds. | |
| 29 StringIndex CreateBetween(const StringIndex& other) const; | |
| 30 | |
| 31 // Returns a StringIndex x s.t. x.LessThan(*this) holds. | |
|
akalin
2011/10/14 10:16:29
clean up
| |
| 32 StringIndex CreateBefore() const; | |
| 33 | |
| 34 // Returns a StringIndex x s.t. LessThan(x) holds. | |
|
akalin
2011/10/14 10:16:29
clean up
| |
| 35 StringIndex CreateAfter() const; | |
| 36 | |
| 37 std::string ToString() const; | |
|
akalin
2011/10/14 10:16:29
add a comment like copy constructor and default as
| |
| 38 | |
| 39 private: | |
| 40 // Return the digit value at position i, padding with kZeroDigit if required. | |
| 41 int GetPositionValue(size_t i) const; | |
| 42 | |
| 43 // Create a StringIndex that is lexigraphically greater than start and | |
| 44 // lexigraphically less than end, ideally the StringIndex will be a | |
| 45 // middle value between the two StringIndexs. | |
| 46 static StringIndex CreateStringIndexBetween(const StringIndex& start, | |
|
akalin
2011/10/14 10:16:29
is there are a reason why these functions are expo
| |
| 47 const StringIndex& end); | |
| 48 | |
| 49 // Compute the midpoint string that is between start and end. | |
| 50 static std::string ComputeMidpoint(const StringIndex& start, | |
| 51 const StringIndex& end); | |
| 52 | |
| 53 // Check if two strings have the same value. | |
| 54 static bool EqualValueIndexs(const std::string& rhs, const std::string& lhs); | |
| 55 | |
| 56 // Add kMidDigitValue to the value at position index because | |
| 57 // the previous index values had an odd difference, so their correct | |
| 58 // middle value is x and a half, so the half is now inserted. | |
| 59 static void AddHalf(size_t position, std::string& value); | |
| 60 | |
| 61 // Remove all trailing zeros from a value as they provide no value. | |
| 62 static std::string RemoveTrailingZeros(const std::string& value); | |
| 63 | |
| 64 std::string string_index_; | |
|
akalin
2011/10/14 10:16:29
const
| |
| 65 }; | |
| 66 #endif // CHROME_COMMON_STRING_INDEX_H_ | |
| OLD | NEW |