The Battle for Wesnoth  1.19.0-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...
 
void restore_old_preprocessor ()
 Restores the old preprocessing context. More...
 

Private Attributes

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

Friends

class preprocessor
 
class preprocessor_file
 
class preprocessor_data
 
struct preprocessor_scope_helper
 

Detailed Description

Target for sending preprocessed output.

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

Definition at line 313 of file preprocessor.cpp.

Constructor & Destructor Documentation

◆ preprocessor_streambuf() [1/2]

preprocessor_streambuf::preprocessor_streambuf ( preproc_map def)
inline

Definition at line 316 of file preprocessor.cpp.

◆ preprocessor_streambuf() [2/2]

preprocessor_streambuf::preprocessor_streambuf ( const preprocessor_streambuf t)
inlineprivate

Definition at line 359 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 353 of file preprocessor.cpp.

References preprocessor_queue_.

Referenced by restore_old_preprocessor(), and underflow().

◆ depth()

int preprocessor_streambuf::depth ( ) const
inline

Definition at line 348 of file preprocessor.cpp.

References preprocessor_queue_.

Referenced by preprocessor_data::get_chunk().

◆ drop_preprocessor()

void preprocessor_streambuf::drop_preprocessor ( )
inline

Definition at line 343 of file preprocessor.cpp.

References preprocessor_queue_.

Referenced by restore_old_preprocessor().

◆ error()

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

◆ get_current_file()

std::string preprocessor_streambuf::get_current_file ( )

◆ restore_old_preprocessor()

void preprocessor_streambuf::restore_old_preprocessor ( )
private

Restores the old preprocessing context.

Appends location and domain directives to the buffer, so that the parser notices these changes.

Definition at line 480 of file preprocessor.cpp.

References buffer_, current(), drop_preprocessor(), linenum_, location_, preprocessor::old_linenum_, preprocessor::old_location_, preprocessor::old_textdomain_, OUTPUT_SEPARATOR, and textdomain_.

Referenced by underflow().

◆ 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 422 of file preprocessor.cpp.

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

◆ warning()

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

Definition at line 575 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 401 of file preprocessor.cpp.

◆ preprocessor_data

friend class preprocessor_data
friend

Definition at line 403 of file preprocessor.cpp.

◆ preprocessor_file

friend class preprocessor_file
friend

Definition at line 402 of file preprocessor.cpp.

◆ preprocessor_scope_helper

friend struct preprocessor_scope_helper
friend

Definition at line 404 of file preprocessor.cpp.

Member Data Documentation

◆ buffer_

std::stringstream preprocessor_streambuf::buffer_
private

Buffer filled by the current preprocessor.

Definition at line 382 of file preprocessor.cpp.

Referenced by preprocessor_data::put(), restore_old_preprocessor(), and underflow().

◆ default_defines_

preproc_map preprocessor_streambuf::default_defines_
private

Definition at line 388 of file preprocessor.cpp.

◆ defines_

preproc_map* preprocessor_streambuf::defines_
private

Definition at line 387 of file preprocessor.cpp.

Referenced by preprocessor_data::get_chunk().

◆ linenum_

int preprocessor_streambuf::linenum_
private

Definition at line 393 of file preprocessor.cpp.

Referenced by preprocessor_data::put(), and restore_old_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 379 of file preprocessor.cpp.

Referenced by underflow().

◆ preprocessor_queue_

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

Input preprocessor queue.

Definition at line 385 of file preprocessor.cpp.

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

◆ quoted_

bool preprocessor_streambuf::quoted_
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 399 of file preprocessor.cpp.

Referenced by preprocessor_data::get_chunk().

◆ textdomain_

std::string preprocessor_streambuf::textdomain_
private

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