Index: chrome/common/string_index.h |
diff --git a/chrome/common/string_index.h b/chrome/common/string_index.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3fb4f8e080d249319146e00ca3103e76565ee2ee |
--- /dev/null |
+++ b/chrome/common/string_index.h |
@@ -0,0 +1,49 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_COMMON_STRING_INDEX_H_ |
+#define CHROME_COMMON_STRING_INDEX_H_ |
+#pragma once |
+ |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+ |
+class StringIndex { |
+ public: |
+ StringIndex(); |
+ ~StringIndex() {} |
+ |
+ // Create a string that is lexigraphically greater than start and |
+ // lexigraphically less than end, ideally the string will be a |
+ // middle value between the two strings. |
+ // Use an empty string to signify no ending or starting limit. |
+ // The range of values returns from here are (A..K*). |
+ 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
|
+ const std::string& end); |
+ private: |
+ // Used to add kMidDigitValue to the value at position index because |
+ // the previous index values had an odd difference, so their correct |
+ // middle value is x and a half, so we are inserting the half here. |
+ void AddHalf(int position, std::string& value); |
+ |
+ // Remove all trailing zeros from a value as they provide no value. |
+ std::string RemoveTrailingZeros(const std::string& value); |
+ |
+ // Get the value of the string index, padding with 0s if the |
+ // string isn't long enough. |
+ int GetPositionValue(const std::string& value, size_t index); |
+ |
+ static const char kZeroDigit = 'A'; |
+ static const char kMinDigit = 'B'; |
+ static const char kMidDigit = 'M'; |
+ static const char kMaxDigit = 'Z'; |
+ |
+ const int kMaxDigitValue; |
+ const int kMidDigitValue; |
+ |
+ |
+ DISALLOW_COPY_AND_ASSIGN(StringIndex); |
+}; |
+#endif // CHROME_COMMON_STRING_INDEX_H_ |