The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
replay_recorder_base.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 - 2025
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 <boost/ptr_container/ptr_vector.hpp>
17
18#include "config.hpp"
19
20class config_writer;
22{
23public:
26
27 void swap(replay_recorder_base& other) noexcept;
28 void swap(replay_recorder_base&& other) noexcept { swap(other); }
29 int get_pos() const;
30
31 int size() const;
32
33 config& get_command_at(int pos);
34
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. */
50
51 void write(config_writer& out) const;
52
53 void write(config& out) const;
54
56
57 /// checks whether the parameter is an earlier state in the
58 /// same "savegame gamestate branch"
59 bool is_ancestor(const config& other_replay) const;
60protected:
62 boost::ptr_vector<config> commands_;
63 int pos_;
64};
65
66/** Implement non-member swap function for std::swap (calls @ref replay_recorder_base::swap). */
67void swap(replay_recorder_base& lhs, replay_recorder_base& rhs) noexcept;
Class for writing a config out to a file in pieces.
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
void write(config_writer &out) const
void append_config(const config &data)
void swap(replay_recorder_base &&other) noexcept
bool is_ancestor(const config &other_replay) const
checks whether the parameter is an earlier state in the same "savegame gamestate branch"
void swap(replay_recorder_base &other) noexcept
config & get_command_at(int pos)
config & insert_command(int index)
boost::ptr_vector< config > commands_
Definitions for the interface to Wesnoth Markup Language (WML).
std::string_view data
Definition picture.cpp:188
void swap(replay_recorder_base &lhs, replay_recorder_base &rhs) noexcept
Implement non-member swap function for std::swap (calls replay_recorder_base::swap).