The Battle for Wesnoth  1.19.5+dev
Macros | Functions | Variables
parser.cpp File Reference

Read/Write & analyze WML- and config-files. More...

#include "serialization/parser.hpp"
#include "config.hpp"
#include "gettext.hpp"
#include "log.hpp"
#include "serialization/preprocessor.hpp"
#include "serialization/string_utils.hpp"
#include "serialization/validator.hpp"
#include "wesconfig.h"
#include <boost/algorithm/string/replace.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <stack>
Include dependency graph for parser.cpp:

Go to the source code of this file.

Macros

#define ERR_CF   LOG_STREAM(err, log_config)
 
#define WRN_CF   LOG_STREAM(warn, log_config)
 
#define LOG_CF   LOG_STREAM(info, log_config)
 

Functions

void read (config &cfg, std::istream &in, abstract_validator *validator)
 
void read (config &cfg, const std::string &in, abstract_validator *validator)
 
template<typename decompressor >
void read_compressed (config &cfg, std::istream &file, abstract_validator *validator)
 
void read_gz (config &cfg, std::istream &file, abstract_validator *validator)
 Might throw a std::ios_base::failure especially a gzip_error. More...
 
void read_bz2 (config &cfg, std::istream &file, abstract_validator *validator)
 Might throw a std::ios_base::failure especially bzip2_error. More...
 
void write_key_val (std::ostream &out, const std::string &key, const config::attribute_value &value, unsigned level, std::string &textdomain)
 
void write_open_child (std::ostream &out, const std::string &child, unsigned int level)
 
void write_close_child (std::ostream &out, const std::string &child, unsigned int level)
 
static void write_internal (const config &cfg, std::ostream &out, std::string &textdomain, std::size_t tab=0)
 
static void write_internal (const configr_of &cfg, std::ostream &out, std::string &textdomain, std::size_t tab=0)
 
void write (std::ostream &out, const configr_of &cfg, unsigned int level)
 
template<typename compressor >
void write_compressed (std::ostream &out, const configr_of &cfg)
 
void write_gz (std::ostream &out, const configr_of &cfg)
 
void write_bz2 (std::ostream &out, const configr_of &cfg)
 

Variables

static lg::log_domain log_config ("config")
 
static const std::size_t max_recursion_levels = 1000
 

Detailed Description

Read/Write & analyze WML- and config-files.

Definition in file parser.cpp.

Macro Definition Documentation

◆ ERR_CF

#define ERR_CF   LOG_STREAM(err, log_config)

Definition at line 52 of file parser.cpp.

◆ LOG_CF

#define LOG_CF   LOG_STREAM(info, log_config)

Definition at line 54 of file parser.cpp.

◆ WRN_CF

#define WRN_CF   LOG_STREAM(warn, log_config)

Definition at line 53 of file parser.cpp.

Function Documentation

◆ read() [1/2]

void read ( config cfg,
const std::string &  in,
abstract_validator validator 
)

Definition at line 627 of file parser.cpp.

References in, and validator.

◆ read() [2/2]

void read ( config cfg,
std::istream &  in,
abstract_validator validator 
)

◆ read_bz2()

void read_bz2 ( config cfg,
std::istream &  file,
abstract_validator validator 
)

Might throw a std::ios_base::failure especially bzip2_error.

Definition at line 684 of file parser.cpp.

References validator.

Referenced by savegame::read_save_file().

◆ read_compressed()

template<typename decompressor >
void read_compressed ( config cfg,
std::istream &  file,
abstract_validator validator 
)

Definition at line 634 of file parser.cpp.

References LOG_CF, and validator.

◆ read_gz()

void read_gz ( config cfg,
std::istream &  file,
abstract_validator validator 
)

◆ write()

void write ( std::ostream &  out,
const configr_of cfg,
unsigned int  level 
)

◆ write_bz2()

void write_bz2 ( std::ostream &  out,
const configr_of cfg 
)

Definition at line 783 of file parser.cpp.

◆ write_close_child()

void write_close_child ( std::ostream &  out,
const std::string &  child,
unsigned int  level 
)

Definition at line 703 of file parser.cpp.

References game_config::images::level.

Referenced by config_writer::close_child(), and write_internal().

◆ write_compressed()

template<typename compressor >
void write_compressed ( std::ostream &  out,
const configr_of cfg 
)

Definition at line 766 of file parser.cpp.

References write().

◆ write_gz()

void write_gz ( std::ostream &  out,
const configr_of cfg 
)

◆ write_internal() [1/2]

static void write_internal ( const config cfg,
std::ostream &  out,
std::string &  textdomain,
std::size_t  tab = 0 
)
static

◆ write_internal() [2/2]

static void write_internal ( const configr_of cfg,
std::ostream &  out,
std::string &  textdomain,
std::size_t  tab = 0 
)
static

◆ write_key_val()

void write_key_val ( std::ostream &  out,
const std::string &  key,
const config::attribute_value value,
unsigned  level,
std::string &  textdomain 
)

◆ write_open_child()

void write_open_child ( std::ostream &  out,
const std::string &  child,
unsigned int  level 
)

Definition at line 698 of file parser.cpp.

References game_config::images::level.

Referenced by config_writer::open_child(), and write_internal().

Variable Documentation

◆ log_config

lg::log_domain log_config("config") ( "config"  )
static

◆ max_recursion_levels

const std::size_t max_recursion_levels = 1000
static

Definition at line 56 of file parser.cpp.

Referenced by write_internal().