The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
replay_recorder_base.cpp
Go to the documentation of this file.
1 
4 
6  : upload_log_()
7  , commands_()
8  , pos_(0)
9 {
10 
11 }
12 
13 
15 {
16 }
17 
18 
20 {
21  commands_.swap(other.commands_);
22  std::swap(pos_, other.pos_);
24 }
25 
27 {
28  return pos_;
29 }
30 
32 {
33  return commands_.size();
34 }
35 
37 {
38  assert(pos < size());
39  return commands_[pos];
40 }
41 
43 {
44  assert(pos_ <= size());
45  commands_.insert(commands_.begin() + pos_, new config());
46  ++pos_;
47  return commands_[pos_ - 1];
48 }
50 {
51  assert(pos <= size());
52  pos_ = pos;
53 }
55 {
56  pos_ = size();
57 }
59 {
60  return upload_log_;
61 }
62 
64 {
65  assert(index < size());
66  commands_.erase(commands_.begin() + index);
67  if(index < pos_)
68  {
69  --pos_;
70  }
71 }
72 
74 {
75  assert(index <= size());
76  if(index < pos_)
77  {
78  ++pos_;
79  }
80  return *commands_.insert(commands_.begin() + index, new config());
81 }
82 
83 
85 {
86  if(const config& upload_log = data.child("upload_log"))
87  {
88  upload_log_ = upload_log;
89  }
90  for(const config& command : data.child_range("command"))
91  {
92  commands_.push_back(new config(command));
93  }
94 }
95 
97 {
98  if(config& upload_log = data.child("upload_log"))
99  {
100  upload_log_.swap(upload_log);
101  }
102  for(config& command : data.child_range("command"))
103  {
104  config* new_config = new config();
105  new_config->swap(command);
106  commands_.push_back(new_config);
107  }
108 }
109 
111 {
112  out.write_child("upload_log", upload_log_);
113  for(int i = 0; i < pos_; ++i)
114  {
115  out.write_child("command", commands_[i]);
116  }
117 }
118 
120 {
121  out.add_child("upload_log", upload_log_);
122  for(int i = 0; i < pos_; ++i)
123  {
124  out.add_child("command", commands_[i]);
125  }
126 }
128 {
129  commands_.resize(pos_);
130 }
child_itors child_range(const std::string &key)
Definition: config.cpp:613
int pos
Definition: formula.cpp:800
config & insert_command(int index)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
Definition: glew.h:1347
boost::ptr_vector< config > commands_
void write_child(const std::string &key, const config &cfg)
void swap(config &cfg)
Definition: config.cpp:1518
void remove_command(int index)
Class for writing a config out to a file in pieces.
void write(config_writer &out) const
config & add_child(const std::string &key)
Definition: config.cpp:743
config & get_command_at(int pos)
GLuint index
Definition: glew.h:1782
void append_config(const config &data)
size_t i
Definition: function.cpp:1057
void swap(replay_recorder_base &other)
void swap(game_board &one, game_board &other)
Definition: game_board.cpp:56
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
Definition: config.cpp:658
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83