The Battle for Wesnoth  1.17.0-dev
replay_recorder_base.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 - 2021
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 #include <cassert>
17 #include <boost/ptr_container/ptr_vector.hpp>
18 
19 #include "config.hpp"
20 
21 class config_writer;
23 {
24 public:
27 
28  void swap(replay_recorder_base& other);
29  void swap(replay_recorder_base&& other) {swap(other);}
30  int get_pos() const;
31 
32  int size() const;
33 
34  config& get_command_at(int pos);
35 
36  config& add_child();
37 
39 
40  void remove_command(int index);
41 
42  config& insert_command(int index);
43 
44  void set_to_end();
45 
46  void set_pos(int pos);
47 
48  void append_config(const config& data);
49  /** Clears the passed config. */
50  void append_config(config& data);
51 
52  void write(config_writer& out) const;
53 
54  void write(config& out) const;
55 
57 protected:
59  boost::ptr_vector<config> commands_;
60  int pos_;
61 };
62 
63 /** 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:72
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:61