The Battle for Wesnoth  1.19.23+dev
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
preprocessor_streambuf Class Reference

Target for sending preprocessed output. More...

Inheritance diagram for preprocessor_streambuf:

Public Member Functions

 preprocessor_streambuf (preproc_map &def)
 
std::string get_current_file ()
 Decodes the filenames placed in a location. More...
 
void error (const std::string &, int)
 
void warning (const std::string &, int)
 
template<typename T , typename... A>
void add_preprocessor (A &&... args)
 
void drop_preprocessor ()
 
int depth () const
 
preprocessorcurrent () const
 

Private Member Functions

 preprocessor_streambuf (const preprocessor_streambuf &t)
 
virtual int underflow () override
 Inherited from basic_streambuf. More...
 

Private Attributes

std::string out_buffer_
 Buffer read by the STL stream. More...
 
std::stringstream buffer_
 Buffer filled by the current preprocessor. More...
 
preproc_mapdefines_
 
std::string textdomain_ {PACKAGE}
 
std::string location_
 
int linenum_ {0}
 
std::vector< std::unique_ptr< preprocessor > > preprocessor_queue_
 Input preprocessor queue. More...
 
bool quoted_ {false}
 Set to true if one preprocessor for this target started to read a string. More...
 

Friends

class preprocessor
 
class preprocessor_file
 
class preprocessor_data
 
class preprocessor_istream
 

Detailed Description

Target for sending preprocessed output.

Objects of this class can be plugged into an STL stream.

Definition at line 309 of file preprocessor.cpp.

Constructor & Destructor Documentation

◆ preprocessor_streambuf() [1/2]

preprocessor_streambuf::preprocessor_streambuf ( preproc_map def)
inline

Definition at line 312 of file preprocessor.cpp.

◆ preprocessor_streambuf() [2/2]

preprocessor_streambuf::preprocessor_streambuf ( const preprocessor_streambuf t)
inlineprivate

Definition at line 347 of file preprocessor.cpp.

Member Function Documentation

◆ add_preprocessor()

template<typename T , typename... A>
void preprocessor_streambuf::add_preprocessor ( A &&...  args)
inline

◆ current()

preprocessor* preprocessor_streambuf::current ( ) const
inline

Definition at line 341 of file preprocessor.cpp.

References preprocessor_queue_.

Referenced by underflow().

◆ depth()

int preprocessor_streambuf::depth ( ) const
inline

Definition at line 336 of file preprocessor.cpp.

References preprocessor_queue_.

Referenced by preprocessor_data::get_chunk().

◆ drop_preprocessor()

void preprocessor_streambuf::drop_preprocessor ( )
inline

Definition at line 331 of file preprocessor.cpp.

References preprocessor_queue_.

Referenced by underflow().

◆ error()

void preprocessor_streambuf::error ( const std::string &  error_type,
int  l 
)

◆ get_current_file()

std::string preprocessor_streambuf::get_current_file ( )

◆ underflow()

int preprocessor_streambuf::underflow ( )
overrideprivatevirtual

Inherited from basic_streambuf.

Called by an STL stream whenever it has reached the end of out_buffer_.

Fills buffer_ by calling the current preprocessor, then copies its content into out_buffer_.

Returns
the first character of out_buffer_ if any, EOF otherwise.

Definition at line 420 of file preprocessor.cpp.

References buffer_, current(), drop_preprocessor(), and out_buffer_.

◆ warning()

void preprocessor_streambuf::warning ( const std::string &  warning_type,
int  l 
)

Definition at line 548 of file preprocessor.cpp.

References lineno_string(), location_, and WRN_PREPROC.

Referenced by preprocessor_data::get_chunk().

Friends And Related Function Documentation

◆ preprocessor

friend class preprocessor
friend

Definition at line 384 of file preprocessor.cpp.

◆ preprocessor_data

friend class preprocessor_data
friend

Definition at line 386 of file preprocessor.cpp.

◆ preprocessor_file

friend class preprocessor_file
friend

Definition at line 385 of file preprocessor.cpp.

◆ preprocessor_istream

friend class preprocessor_istream
friend

Definition at line 387 of file preprocessor.cpp.

Member Data Documentation

◆ buffer_

std::stringstream preprocessor_streambuf::buffer_
private

Buffer filled by the current preprocessor.

Definition at line 361 of file preprocessor.cpp.

Referenced by preprocessor_data::put(), underflow(), and preprocessor::~preprocessor().

◆ defines_

preproc_map& preprocessor_streambuf::defines_
private

Definition at line 363 of file preprocessor.cpp.

Referenced by preprocessor_data::get_chunk().

◆ linenum_

int preprocessor_streambuf::linenum_ {0}
private

Definition at line 368 of file preprocessor.cpp.

Referenced by preprocessor_data::put(), and preprocessor::~preprocessor().

◆ location_

std::string preprocessor_streambuf::location_
private

◆ out_buffer_

std::string preprocessor_streambuf::out_buffer_
private

Buffer read by the STL stream.

Definition at line 358 of file preprocessor.cpp.

Referenced by underflow().

◆ preprocessor_queue_

std::vector<std::unique_ptr<preprocessor> > preprocessor_streambuf::preprocessor_queue_
private

Input preprocessor queue.

NOTE: This must be after textdomain_/location_/linenum_ because otherwise it causes a memory corruption error which causes Wesnoth to abort upon launch in some devices.

Definition at line 376 of file preprocessor.cpp.

Referenced by add_preprocessor(), current(), depth(), drop_preprocessor(), and get_current_file().

◆ quoted_

bool preprocessor_streambuf::quoted_ {false}
private

Set to true if one preprocessor for this target started to read a string.

Deeper-nested preprocessors are then forbidden to.

Definition at line 382 of file preprocessor.cpp.

Referenced by preprocessor_data::get_chunk().

◆ textdomain_

std::string preprocessor_streambuf::textdomain_ {PACKAGE}
private

The documentation for this class was generated from the following file: