Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_STARS_POSITION_H_ | |
| 6 #define COMPONENTS_ENHANCED_BOOKMARKS_STARS_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 StarsPosition { | |
|
Yaron
2014/09/05 03:52:02
StarPosition/ItemPosition? Why is it plural?
Rune Fevang
2014/09/05 19:02:30
Because it refers to the Stars name, and is stored
Yaron
2014/09/05 19:52:13
It just reads weirdly to me and can be used withou
Rune Fevang
2014/09/05 20:47:08
Done.
| |
| 16 public: | |
| 17 ~StarsPosition(); | |
| 18 | |
| 19 // Creates a position suitable to use as a starting point. | |
| 20 static StarsPosition CreateInitialPosition(); | |
| 21 | |
| 22 // Creates positions relative to other positions. | |
| 23 static StarsPosition CreateBefore(const StarsPosition& other); | |
| 24 static StarsPosition CreateBetween(const StarsPosition& before, | |
| 25 const StarsPosition& after); | |
| 26 static StarsPosition CreateAfter(const StarsPosition& 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 StarsPosition& other); | |
| 37 bool LessThan(const StarsPosition& other); | |
| 38 | |
| 39 private: | |
| 40 typedef std::vector<char> PositionVector; | |
| 41 | |
| 42 StarsPosition(); | |
| 43 explicit StarsPosition(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_STARS_POSITION_H_ | |
| OLD | NEW |