// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_SYNC_MODEL_STRING_ORDINAL_H_ #define COMPONENTS_SYNC_MODEL_STRING_ORDINAL_H_ #include <cstddef> #include <cstdint> #include <string> namespace mojo { template <typename DataViewType, typename T> struct StructTraits; } namespace syncer { namespace mojom { class StringOrdinalDataView; } // WARNING, DO NOT USE! Use UniquePosition instead. // // // A StringOrdinal is an object that can be used for ordering. The // StringOrdinal class has an unbounded dense strict total order, which // mean for any StringOrdinals a, b and c: // // - a < b and b < c implies a < c (transitivity); // - exactly one of a < b, b < a and a = b holds (trichotomy); // - if a < b, there is a StringOrdinal x such that a < x < b (density); // - there are Ordinals<T> x and y such that x < a < y (unboundedness). // // This means that when StringOrdinal is used for sorting a list, if any // item changes its position in the list, only its StringOrdinal value // has to change to represent the new order, and all the other values // can stay the same. // // A StringOrdinal is internally represented as an array of bytes, so it // can be serialized to and deserialized from disk. // // A StringOrdinal is valid iff its corresponding string has at least // kMinLength characters, does not contain any characters less than // kZeroDigit or greater than kMaxDigit, is not all zero digits, and // does not have any unnecessary trailing zero digits. // // Since StringOrdinals contain only printable characters, it is safe // to store as a string in a protobuf. class StringOrdinal { … }; bool operator==(const StringOrdinal& lhs, const StringOrdinal& rhs); static_assert …; static_assert …; static_assert …; static_assert …; static_assert …; static_assert …; static_assert …; } // namespace syncer #endif // COMPONENTS_SYNC_MODEL_STRING_ORDINAL_H_