The Battle for Wesnoth  1.15.1+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:
Inheritance graph

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

Constructor & Destructor Documentation

◆ preprocessor_streambuf() [1/2]

preprocessor_streambuf::preprocessor_streambuf ( preproc_map def)
inline

Definition at line 281 of file preprocessor.cpp.

References error().

◆ preprocessor_streambuf() [2/2]

preprocessor_streambuf::preprocessor_streambuf ( const preprocessor_streambuf t)
inlineprivate

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

◆ depth()

int preprocessor_streambuf::depth ( ) const
inline

Definition at line 313 of file preprocessor.cpp.

Referenced by preprocessor_data::get_chunk().

◆ drop_preprocessor()

void preprocessor_streambuf::drop_preprocessor ( )
inline

Definition at line 308 of file preprocessor.cpp.

◆ error()

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

◆ get_current_file()

std::string preprocessor_streambuf::get_current_file ( )

Decodes the filenames placed in a location.

Definition at line 465 of file preprocessor.cpp.

References get_filename(), p, preprocessor::parse_mode(), preprocessor::PARSES_FILE, preprocessor::PARSES_MACRO, and utils::quoted_split().

Referenced by preprocessor_data::get_chunk().

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

References preprocessor::old_linenum_, preprocessor::old_location_, preprocessor::old_textdomain_, and OUTPUT_SEPARATOR.

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

◆ warning()

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

Definition at line 540 of file preprocessor.cpp.

References lineno_string(), and WRN_PREPROC.

Referenced by preprocessor_data::get_chunk().

Friends And Related Function Documentation

◆ preprocessor

friend class preprocessor
friend

Definition at line 366 of file preprocessor.cpp.

◆ preprocessor_data

friend class preprocessor_data
friend

Definition at line 368 of file preprocessor.cpp.

◆ preprocessor_file

friend class preprocessor_file
friend

Definition at line 367 of file preprocessor.cpp.

◆ preprocessor_scope_helper

friend struct preprocessor_scope_helper
friend

Definition at line 369 of file preprocessor.cpp.

Member Data Documentation

◆ buffer_

std::stringstream preprocessor_streambuf::buffer_
private

Buffer filled by the #current_ preprocessor.

Definition at line 347 of file preprocessor.cpp.

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

◆ default_defines_

preproc_map preprocessor_streambuf::default_defines_
private

Definition at line 353 of file preprocessor.cpp.

◆ defines_

preproc_map* preprocessor_streambuf::defines_
private

Definition at line 352 of file preprocessor.cpp.

Referenced by preprocessor_data::get_chunk().

◆ linenum_

int preprocessor_streambuf::linenum_
private

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

◆ preprocessor_queue_

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

Input preprocessor queue.

Definition at line 350 of file preprocessor.cpp.

◆ 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 364 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: