Add abhijeet.k@samsung.com to AUTHORS list.
[chromium-blink-merge.git] / components / enhanced_bookmarks / item_position.h
blobea04be59355ffa7f1ff09d267b51ca6804d39644
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_
8 #include <string>
9 #include <vector>
11 namespace enhanced_bookmarks {
13 // Convenience class for generating string based relative ordering between
14 // bookmark nodes.
15 class ItemPosition {
16 public:
17 ~ItemPosition();
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);
28 bool IsValid() const;
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;
39 private:
40 typedef std::vector<unsigned char> PositionVector;
42 ItemPosition();
43 explicit ItemPosition(const PositionVector& position);
45 static PositionVector CreateBeforeImpl(const PositionVector& before,
46 size_t from_index);
47 static PositionVector CreateBetweenImpl(const PositionVector& before,
48 const PositionVector& after);
49 static PositionVector CreateAfterImpl(const PositionVector& after,
50 size_t from_index);
52 PositionVector position_;
55 } // namespace enhanced_bookmarks
57 #endif // COMPONENTS_ENHANCED_BOOKMARKS_ITEM_POSITION_H_