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

Unified Diff: chrome/common/string_index.h

Issue 8236002: Create StringOrdinal to allow placement of strings in sorted lists (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Adjusting code to comply with code review requests Created 9 years, 2 months 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 side-by-side diff with in-line comments
Download patch
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..c1823957532c089e913ecdb636b4aa2fc8f6855d
--- /dev/null
+++ b/chrome/common/string_index.h
@@ -0,0 +1,44 @@
+// 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"
+
+namespace StringIndex {
akalin 2011/10/12 18:50:14 static functions in a namespace isn't a great inte
+
+// 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,
+ const std::string& end);
+
+// 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.
akalin 2011/10/12 18:50:14 why is this public?
+void AddHalf(size_t position, std::string& value);
+
+// Remove all trailing zeros from a value as they provide no value.
+std::string RemoveTrailingZeros(const std::string& value);
akalin 2011/10/12 18:50:14 why is this public?
+
+// Ensure that given string matches the format with asserts.
+// The format is [A-Z][B-Z]*
+void ValidateString(const std::string& value);
+
+static const char kZeroDigit = 'A';
akalin 2011/10/12 18:50:14 why are these in the header?
+static const char kMinDigit = 'B';
+static const char kMidDigit = 'N';
+static const char kMaxDigit = 'Z';
+
+static const int kMaxDigitValue = kMaxDigit - kZeroDigit;
+static const int kMidDigitValue = kMidDigit - kZeroDigit;
+static const int kFullDigitValue = (kMaxDigit + 1) - kZeroDigit;
+}
+#endif // CHROME_COMMON_STRING_INDEX_H_

Powered by Google App Engine
This is Rietveld 408576698