The Battle for Wesnoth  1.15.1+dev
Classes | Macros | Functions | Variables
preprocessor.cpp File Reference

WML preprocessor. More...

#include "serialization/preprocessor.hpp"
#include "buffered_istream.hpp"
#include "config.hpp"
#include "filesystem.hpp"
#include "log.hpp"
#include "serialization/binary_or_text.hpp"
#include "serialization/parser.hpp"
#include "serialization/string_utils.hpp"
#include "game_version.hpp"
#include "wesconfig.h"
#include "deprecation.hpp"
#include <stdexcept>
#include <deque>
Include dependency graph for preprocessor.cpp:

Go to the source code of this file.

Classes

class  preprocessor
 Base class for preprocessing an input. More...
 
class  preprocessor_streambuf
 Target for sending preprocessed output. More...
 
class  preprocessor_file
 Specialized preprocessor for handling a file or a set of files. More...
 
class  preprocessor_data
 Specialized preprocessor for handling any kind of input stream. More...
 
struct  preprocessor_data::token_desc
 Description of a preprocessing chunk. More...
 
struct  preprocessor_scope_helper
 

Macros

#define ERR_PREPROC   LOG_STREAM(err, log_preprocessor)
 
#define WRN_PREPROC   LOG_STREAM(warn, log_preprocessor)
 
#define LOG_PREPROC   LOG_STREAM(info, log_preprocessor)
 
#define DBG_PREPROC   LOG_STREAM(debug, log_preprocessor)
 

Functions

static std::string get_filename (const std::string &file_code)
 
static std::string get_file_code (const std::string &filename)
 
static std::string get_location (const std::string &loc)
 
std::ostream & operator<< (std::ostream &stream, const preproc_define &def)
 
std::ostream & operator<< (std::ostream &stream, const preproc_map::value_type &def)
 
std::string lineno_string (const std::string &lineno)
 
bool operator== (preprocessor_data::token_desc::TOKEN_TYPE, char)
 
bool operator== (char lhs, preprocessor_data::token_desc::TOKEN_TYPE rhs)
 
bool operator!= (preprocessor_data::token_desc::TOKEN_TYPE rhs, char lhs)
 
bool operator!= (char lhs, preprocessor_data::token_desc::TOKEN_TYPE rhs)
 
filesystem::scoped_istream preprocess_file (const std::string &fname, preproc_map *defines)
 
void preprocess_resource (const std::string &res_name, preproc_map *defines_map, bool write_cfg, bool write_plain_cfg, const std::string &parent_directory)
 

Variables

static lg::log_domain log_preprocessor ("preprocessor")
 
static std::string current_file_str = "CURRENT_FILE"
 
static std::string current_dir_str = "CURRENT_DIRECTORY"
 
static std::map< std::string, int > file_number_map
 
static bool encode_filename = true
 
static std::string preprocessor_error_detail_prefix = "\n "
 
static const char OUTPUT_SEPARATOR = '\xFE'
 

Detailed Description

WML preprocessor.

Definition in file preprocessor.cpp.

Macro Definition Documentation

◆ DBG_PREPROC

#define DBG_PREPROC   LOG_STREAM(debug, log_preprocessor)

Definition at line 41 of file preprocessor.cpp.

Referenced by preprocessor_data::get_chunk().

◆ ERR_PREPROC

#define ERR_PREPROC   LOG_STREAM(err, log_preprocessor)

Definition at line 38 of file preprocessor.cpp.

Referenced by preprocessor_streambuf::error(), and preprocessor_file::init().

◆ LOG_PREPROC

#define LOG_PREPROC   LOG_STREAM(info, log_preprocessor)

Definition at line 40 of file preprocessor.cpp.

Referenced by preprocessor_data::get_chunk(), and preprocess_resource().

◆ WRN_PREPROC

#define WRN_PREPROC   LOG_STREAM(warn, log_preprocessor)

Function Documentation

◆ get_file_code()

static std::string get_file_code ( const std::string &  filename)
static

Definition at line 77 of file preprocessor.cpp.

References encode_filename, and utils::escape().

Referenced by preprocessor_data::preprocessor_data().

◆ get_filename()

static std::string get_filename ( const std::string &  file_code)
static

◆ get_location()

static std::string get_location ( const std::string &  loc)
static

Definition at line 98 of file preprocessor.cpp.

References get_filename(), i, and utils::quoted_split().

Referenced by preprocessor_data::get_chunk(), and preproc_define::write().

◆ lineno_string()

std::string lineno_string ( const std::string &  lineno)

◆ operator!=() [1/2]

bool operator!= ( preprocessor_data::token_desc::TOKEN_TYPE  rhs,
char  lhs 
)

Definition at line 730 of file preprocessor.cpp.

Referenced by preprocessor_data::parse_mode().

◆ operator!=() [2/2]

bool operator!= ( char  lhs,
preprocessor_data::token_desc::TOKEN_TYPE  rhs 
)

Definition at line 735 of file preprocessor.cpp.

◆ operator<<() [1/2]

std::ostream& operator<< ( std::ostream &  stream,
const preproc_define def 
)

◆ operator<<() [2/2]

std::ostream& operator<< ( std::ostream &  stream,
const preproc_map::value_type &  def 
)

Definition at line 209 of file preprocessor.cpp.

◆ operator==() [1/2]

bool operator== ( preprocessor_data::token_desc::TOKEN_TYPE  ,
char   
)

Definition at line 720 of file preprocessor.cpp.

Referenced by preprocessor_data::parse_mode().

◆ operator==() [2/2]

bool operator== ( char  lhs,
preprocessor_data::token_desc::TOKEN_TYPE  rhs 
)

Definition at line 725 of file preprocessor.cpp.

◆ preprocess_file()

filesystem::scoped_istream preprocess_file ( const std::string &  fname,
preproc_map defines 
)

◆ preprocess_resource()

void preprocess_resource ( const std::string &  res_name,
preproc_map defines_map,
bool  write_cfg,
bool  write_plain_cfg,
const std::string &  parent_directory 
)

Variable Documentation

◆ current_dir_str

std::string current_dir_str = "CURRENT_DIRECTORY"
static

Definition at line 44 of file preprocessor.cpp.

Referenced by preprocessor_data::get_chunk().

◆ current_file_str

std::string current_file_str = "CURRENT_FILE"
static

Definition at line 43 of file preprocessor.cpp.

Referenced by preprocessor_data::get_chunk().

◆ encode_filename

bool encode_filename = true
static

Definition at line 49 of file preprocessor.cpp.

Referenced by get_file_code(), get_filename(), and preprocess_resource().

◆ file_number_map

std::map<std::string, int> file_number_map
static

Definition at line 47 of file preprocessor.cpp.

◆ log_preprocessor

lg::log_domain log_preprocessor("preprocessor")
static

◆ OUTPUT_SEPARATOR

const char OUTPUT_SEPARATOR = '\xFE'
static

◆ preprocessor_error_detail_prefix

std::string preprocessor_error_detail_prefix = "\n "
static

Definition at line 51 of file preprocessor.cpp.

Referenced by lineno_string().