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" | |
| 12 | |
| 13 class StringIndex { | |
| 14 public: | |
| 15 StringIndex(); | |
| 16 ~StringIndex() {} | |
| 17 | |
| 18 // Create a string that is lexigraphically greater than start and | |
| 19 // lexigraphically less than end, ideally the string will be a | |
| 20 // middle value between the two strings. | |
| 21 // Use an empty string to signify no ending or starting limit. | |
| 22 // The range of values returns from here are (A..K*). | |
| 23 std::string CreateStringBetween(const std::string& start, | |
|
akalin
2011/10/11 19:34:39
since kmaxDigitvalue and kMidDigitValue are consta
csharp1
2011/10/12 15:31:12
Ok, I've changed it to just be a namespace.
On 20
| |
| 24 const std::string& end); | |
| 25 private: | |
| 26 // Used to add kMidDigitValue to the value at position index because | |
| 27 // the previous index values had an odd difference, so their correct | |
| 28 // middle value is x and a half, so we are inserting the half here. | |
| 29 void AddHalf(int position, std::string& value); | |
| 30 | |
| 31 // Remove all trailing zeros from a value as they provide no value. | |
| 32 std::string RemoveTrailingZeros(const std::string& value); | |
| 33 | |
| 34 // Get the value of the string index, padding with 0s if the | |
| 35 // string isn't long enough. | |
| 36 int GetPositionValue(const std::string& value, size_t index); | |
| 37 | |
| 38 static const char kZeroDigit = 'A'; | |
| 39 static const char kMinDigit = 'B'; | |
| 40 static const char kMidDigit = 'M'; | |
| 41 static const char kMaxDigit = 'Z'; | |
| 42 | |
| 43 const int kMaxDigitValue; | |
| 44 const int kMidDigitValue; | |
| 45 | |
| 46 | |
| 47 DISALLOW_COPY_AND_ASSIGN(StringIndex); | |
| 48 }; | |
| 49 #endif // CHROME_COMMON_STRING_INDEX_H_ | |
| OLD | NEW |