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

Unified Diff: sync/api/string_ordinal.h

Issue 10920017: [Sync] Generalize StringOrdinal to handle ordinal_in_parent field (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Relax tests Created 8 years, 3 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
« no previous file with comments | « chrome/common/string_ordinal_unittest.cc ('k') | sync/internal_api/public/base/node_ordinal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/api/string_ordinal.h
diff --git a/sync/api/string_ordinal.h b/sync/api/string_ordinal.h
new file mode 100644
index 0000000000000000000000000000000000000000..8952d47afec8d13aa6731d8fddf90e9e54007f92
--- /dev/null
+++ b/sync/api/string_ordinal.h
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 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 SYNC_API_STRING_ORDINAL_H_
+#define SYNC_API_STRING_ORDINAL_H_
+
+#include "base/basictypes.h"
+#include "sync/internal_api/public/base/ordinal.h"
+
+namespace syncer {
+
+// A StringOrdinal is an Ordinal with range 'a'-'z' for printability
+// of its internal byte string representation. (Think of
+// StringOrdinal as being short for PrintableStringOrdinal.) It
+// should be used for data types that want to maintain one or more
+// orderings for nodes.
+//
+// Since StringOrdinals contain only printable characters, it is safe
+// to store as a string in a protobuf.
+
+struct StringOrdinalTraits {
+ static const uint8 kZeroDigit = 'a';
+ static const uint8 kMaxDigit = 'z';
+ static const size_t kMinLength = 1;
+};
+
+typedef Ordinal<StringOrdinalTraits> StringOrdinal;
+
+COMPILE_ASSERT(StringOrdinal::kZeroDigit == 'a',
+ StringOrdinalHasCorrectZeroDigit);
+COMPILE_ASSERT(StringOrdinal::kOneDigit == 'b',
+ StringOrdinalHasCorrectOneDigit);
+COMPILE_ASSERT(StringOrdinal::kMidDigit == 'n',
+ StringOrdinalHasCorrectMidDigit);
+COMPILE_ASSERT(StringOrdinal::kMaxDigit == 'z',
+ StringOrdinalHasCorrectMaxDigit);
+COMPILE_ASSERT(StringOrdinal::kMidDigitValue == 13,
+ StringOrdinalHasCorrectMidDigitValue);
+COMPILE_ASSERT(StringOrdinal::kMaxDigitValue == 25,
+ StringOrdinalHasCorrectMaxDigitValue);
+COMPILE_ASSERT(StringOrdinal::kRadix == 26,
+ StringOrdinalHasCorrectRadix);
+
+} // namespace syncer
+
+#endif // SYNC_API_STRING_ORDINAL_H_
« no previous file with comments | « chrome/common/string_ordinal_unittest.cc ('k') | sync/internal_api/public/base/node_ordinal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698