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

Side by Side Diff: components/enhanced_bookmarks/item_position.h

Issue 510543002: Introduce ItemPosition class for enhanced bookmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Rename to ItemPosition Created 6 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 unified diff | Download patch
« no previous file with comments | « components/enhanced_bookmarks.gypi ('k') | components/enhanced_bookmarks/item_position.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef COMPONENTS_ENHANCED_BOOKMARKS_ITEM_POSITION_H_
6 #define COMPONENTS_ENHANCED_BOOKMARKS_ITEM_POSITION_H_
7
8 #include <string>
9 #include <vector>
10
11 namespace enhanced_bookmarks {
12
13 // Convenience class for generating string based relative ordering between
14 // bookmark nodes.
15 class ItemPosition {
16 public:
17 ~ItemPosition();
18
19 // Creates a position suitable to use as a starting point.
20 static ItemPosition CreateInitialPosition();
21
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);
27
28 bool IsValid() const;
29
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;
34
35 // Comparison functions.
36 bool Equals(const ItemPosition& other) const;
37 bool LessThan(const ItemPosition& other) const;
38
39 private:
40 typedef std::vector<unsigned char> PositionVector;
41
42 ItemPosition();
43 explicit ItemPosition(const PositionVector& position);
44
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);
51
52 PositionVector position_;
53 };
54
55 } // namespace enhanced_bookmarks
56
57 #endif // COMPONENTS_ENHANCED_BOOKMARKS_ITEM_POSITION_H_
OLDNEW
« no previous file with comments | « components/enhanced_bookmarks.gypi ('k') | components/enhanced_bookmarks/item_position.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698