The Battle for Wesnoth  1.19.0-dev
parser.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2005 - 2024
3  by Philippe Plantier <ayin@anathas.org>
4  Copyright (C) 2005 by Guillaume Melquiond <guillaume.melquiond@gmail.com>
5  Copyright (C) 2003 by David White <dave@whitevine.net>
6  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY.
14 
15  See the COPYING file for more details.
16 */
17 
18 #pragma once
19 
20 #include "config.hpp"
21 #include "configr_assign.hpp"
22 
23 class abstract_validator;
24 
25 // Read data in, clobbering existing data.
26 void read(config& cfg, std::istream& in, abstract_validator* validator = nullptr); // Throws config::error
27 void read(config& cfg, const std::string& in, abstract_validator* validator = nullptr); // Throws config::error
28 void read_gz(config& cfg, std::istream& in, abstract_validator* validator = nullptr);
29 void read_bz2(config& cfg, std::istream& in, abstract_validator* validator = nullptr);
30 
31 void write(std::ostream& out, const configr_of& cfg, unsigned int level = 0);
32 void write_gz(std::ostream& out, const configr_of& cfg);
33 void write_bz2(std::ostream& out, const configr_of& cfg);
34 void write_key_val(std::ostream& out,
35  const std::string& key,
36  const config::attribute_value& value,
37  unsigned level,
38  std::string& textdomain);
39 void write_open_child(std::ostream& out, const std::string& child, unsigned int level);
40 void write_close_child(std::ostream& out, const std::string& child, unsigned int level);
Used in parsing config file.
Definition: validator.hpp:38
Variant for storing WML attributes.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
unsigned in
If equal to search_counter, the node is off the list.
void write_gz(std::ostream &out, const configr_of &cfg)
Definition: parser.cpp:783
void read(config &cfg, std::istream &in, abstract_validator *validator=nullptr)
Definition: parser.cpp:627
void read_bz2(config &cfg, std::istream &in, abstract_validator *validator=nullptr)
Might throw a std::ios_base::failure especially bzip2_error.
Definition: parser.cpp:689
void write_close_child(std::ostream &out, const std::string &child, unsigned int level)
Definition: parser.cpp:708
void write(std::ostream &out, const configr_of &cfg, unsigned int level=0)
Definition: parser.cpp:764
void read_gz(config &cfg, std::istream &in, abstract_validator *validator=nullptr)
Might throw a std::ios_base::failure especially a gzip_error.
Definition: parser.cpp:683
void write_key_val(std::ostream &out, const std::string &key, const config::attribute_value &value, unsigned level, std::string &textdomain)
Definition: parser.cpp:694
void write_bz2(std::ostream &out, const configr_of &cfg)
Definition: parser.cpp:788
void write_open_child(std::ostream &out, const std::string &child, unsigned int level)
Definition: parser.cpp:703