Chromium Code Reviews| Index: components/enhanced_bookmarks/stars_position.h |
| diff --git a/components/enhanced_bookmarks/stars_position.h b/components/enhanced_bookmarks/stars_position.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0645c09f8da9a59be65b49ec4beea2b0b63a8bb4 |
| --- /dev/null |
| +++ b/components/enhanced_bookmarks/stars_position.h |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_ENHANCED_BOOKMARKS_STARS_POSITION_H_ |
| +#define COMPONENTS_ENHANCED_BOOKMARKS_STARS_POSITION_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +namespace enhanced_bookmarks { |
| + |
| +// Convenience class for generating string based relative ordering between |
| +// bookmark nodes. |
| +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.
|
| + public: |
| + ~StarsPosition(); |
| + |
| + // Creates a position suitable to use as a starting point. |
| + static StarsPosition CreateInitialPosition(); |
| + |
| + // Creates positions relative to other positions. |
| + static StarsPosition CreateBefore(const StarsPosition& other); |
| + static StarsPosition CreateBetween(const StarsPosition& before, |
| + const StarsPosition& after); |
| + static StarsPosition CreateAfter(const StarsPosition& other); |
| + |
| + bool IsValid() const; |
| + |
| + // Returns a string representation of the position. The string representations |
| + // of two position have the same ordering as the positions themselves when |
| + // compared using ASCII order. |
| + std::string ToString() const; |
| + |
| + // Comparison functions. |
| + bool Equals(const StarsPosition& other); |
| + bool LessThan(const StarsPosition& other); |
| + |
| + private: |
| + typedef std::vector<char> PositionVector; |
| + |
| + StarsPosition(); |
| + explicit StarsPosition(const PositionVector& position); |
| + |
| + static PositionVector CreateBeforeImpl(const PositionVector& before, |
| + size_t from_index); |
| + static PositionVector CreateBetweenImpl(const PositionVector& before, |
| + const PositionVector& after); |
| + static PositionVector CreateAfterImpl(const PositionVector& after, |
| + size_t from_index); |
| + |
| + PositionVector position_; |
| +}; |
| + |
| +} // namespace enhanced_bookmarks |
| + |
| +#endif // COMPONENTS_ENHANCED_BOOKMARKS_STARS_POSITION_H_ |