YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
ReadingList.cpp
浏览该文件的文档.
1 /*
2  Copyright by FrankHB 2012 - 2013.
3 
4  This file is part of the YSLib project, and may only be used,
5  modified, and distributed under the terms of the YSLib project
6  license, LICENSE.TXT. By continuing to use, modify, or distribute
7  this file you indicate that you have read the license and
8  understand and accept it fully.
9 */
10 
28 #include "ReadingList.h"
29 
30 YSL_BEGIN_NAMESPACE(YReader)
31 
32 Bookmark::operator ValueNode::Container() const
33 {
34  return {MakeNode("Path", Path.GetNativeString()),
35  StringifyToNode("Position", Position)};
36 }
37 
38 
40  : reading_list(), now_reading(reading_list.end())
41 {}
42 
43 ReadingList::operator ValueNode::Container() const
44 {
46 
47  for(const auto& bm : reading_list)
48  con.insert(MakeNode("bm" + to_string(con.size()),
50  return std::move(con);
51 }
52 
53 pair<bool, bool>
55 {
56  return make_pair(now_reading != reading_list.begin(),
57  now_reading != reading_list.end());
58 }
59 
60 void
61 ReadingList::DropSubsequent()
62 {
63  reading_list.erase(now_reading, reading_list.end());
64  now_reading = reading_list.end();
65 }
66 
67 void
68 ReadingList::Insert(const IO::Path& pth, size_t pos)
69 {
70  reading_list.emplace(now_reading, pth, pos);
71 }
72 
74 ReadingList::Switch(bool is_prev)
75 {
76  if(is_prev)
77  {
78  --now_reading;
79  --now_reading;
80  }
81 
82  auto ret(std::move(*now_reading));
83 
84  reading_list.erase(now_reading++);
85  return ret;
86 }
87 
88 YSL_END_NAMESPACE(YReader)
89