1 // Copyright 2014 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.
5 #ifndef COMPONENTS_ENHANCED_BOOKMARKS_ITEM_POSITION_H_
6 #define COMPONENTS_ENHANCED_BOOKMARKS_ITEM_POSITION_H_
11 namespace enhanced_bookmarks
{
13 // Convenience class for generating string based relative ordering between
19 // Creates a position suitable to use as a starting point.
20 static ItemPosition
CreateInitialPosition();
22 // Creates positions relative to other positions.
23 static ItemPosition
CreateBefore(const ItemPosition
& other
);
24 static ItemPosition
CreateBetween(const ItemPosition
& before
,
25 const ItemPosition
& after
);
26 static ItemPosition
CreateAfter(const ItemPosition
& other
);
30 // Returns a string representation of the position. The string representations
31 // of two position have the same ordering as the positions themselves when
32 // compared using ASCII order.
33 std::string
ToString() const;
35 // Comparison functions.
36 bool Equals(const ItemPosition
& other
) const;
37 bool LessThan(const ItemPosition
& other
) const;
40 typedef std::vector
<unsigned char> PositionVector
;
43 explicit ItemPosition(const PositionVector
& position
);
45 static PositionVector
CreateBeforeImpl(const PositionVector
& before
,
47 static PositionVector
CreateBetweenImpl(const PositionVector
& before
,
48 const PositionVector
& after
);
49 static PositionVector
CreateAfterImpl(const PositionVector
& after
,
52 PositionVector position_
;
55 } // namespace enhanced_bookmarks
57 #endif // COMPONENTS_ENHANCED_BOOKMARKS_ITEM_POSITION_H_