The Battle for Wesnoth  1.15.1+dev
replay_recorder_base.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017-2018 by the Battle for Wesnoth Project https://www.wesnoth.org/
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY.
10 
11  See the COPYING file for more details.
12 */
13 
14 #pragma once
15 #include <cassert>
16 #include <boost/ptr_container/ptr_vector.hpp>
17 
18 #include "config.hpp"
19 
20 class config_writer;
22 {
23 public:
26 
27  void swap(replay_recorder_base& other);
28  void swap(replay_recorder_base&& other) {swap(other);}
29  int get_pos() const;
30 
31  int size() const;
32 
33  config& get_command_at(int pos);
34 
35  config& add_child();
36 
38 
39  void remove_command(int index);
40 
41  config& insert_command(int index);
42 
43  void set_to_end();
44 
45  void set_pos(int pos);
46 
47  void append_config(const config& data);
48  /// Clears the passed config.
49  void append_config(config& data);
50 
51  void write(config_writer& out) const;
52 
53  void write(config& out) const;
54 
56 protected:
58  boost::ptr_vector<config> commands_;
59  int pos_;
60 };
61 
62 /** Implement non-member swap function for std::swap (calls @ref replay_recorder_base::swap). */
config & insert_command(int index)
Definitions for the interface to Wesnoth Markup Language (WML).
boost::ptr_vector< config > commands_
void remove_command(int index)
Class for writing a config out to a file in pieces.
void swap(replay_recorder_base &&other)
void write(config_writer &out) const
config & get_command_at(int pos)
void append_config(const config &data)
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:71
void swap(replay_recorder_base &other)
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68