1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
//-----------------------------------------------------------------------------
/** @file libboardgame_base/TreeWriter.h
@author Markus Enzenberger
@copyright GNU General Public License version 3 or later */
//-----------------------------------------------------------------------------
#ifndef LIBBOARDGAME_BASE_TREE_WRITER_H
#define LIBBOARDGAME_BASE_TREE_WRITER_H
#include "SgfNode.h"
#include "Writer.h"
namespace libboardgame_base {
//-----------------------------------------------------------------------------
class TreeWriter
{
public:
TreeWriter(ostream& out, const SgfNode& root);
virtual ~TreeWriter() = default;
/** Overridable function to write a property.
Can be used in subclasses, for example, to replace or remove obsolete
properties or do other sanitizing. */
virtual void write_property(const string& id,
const vector<string>& values);
/** @name Formatting options.
Should be set before starting to write. */
/** @{ */
void set_indent(int indent) { m_writer.set_indent(indent); }
/** @} */ // @name
void write();
private:
const SgfNode& m_root;
Writer m_writer;
void write_node(const SgfNode& node);
};
//-----------------------------------------------------------------------------
} // namespace libboardgame_base
#endif // LIBBOARDGAME_BASE_TREE_WRITER_H
|