Bash++
Bash++ compiler internal documentation
Public Member Functions | Private Attributes | List of all members
bpp::bash_while_loop Class Reference

A while loop in Bash++. More...

#include <bpp.h>

Inheritance diagram for bpp::bash_while_loop:
Inheritance graph
[legend]
Collaboration diagram for bpp::bash_while_loop:
Collaboration graph
[legend]

Public Member Functions

 bash_while_loop ()
 
void set_while_condition (std::shared_ptr< bpp::bash_while_condition > while_condition)
 
std::shared_ptr< bpp::bash_while_conditionget_while_condition () const
 
std::string get_code () const override
 Return the contents of the main code buffer as a string. More...
 
std::string get_pre_code () const override
 Return the contents of the pre-code buffer as a string. More...
 
std::string get_post_code () const override
 Return the contents of the post-code buffer as a string. More...
 
- Public Member Functions inherited from bpp::bpp_code_entity
 bpp_code_entity ()
 
virtual ~bpp_code_entity ()=default
 
virtual void add_code (const std::string &code, bool add_newline=true)
 Add code to the code entity. More...
 
virtual void add_code_to_previous_line (const std::string &code)
 Add code to the code entity's pre-code buffer. More...
 
virtual void add_code_to_next_line (const std::string &code)
 Add code to the code entity's post-code buffer. More...
 
bool add_object (std::shared_ptr< bpp_object > object) override
 Add an object to the code entity. More...
 
virtual void flush_nextline_buffer ()
 
virtual void flush_postline_buffer ()
 
virtual void flush_code_buffers ()
 
virtual void clear_all_buffers ()
 
- Public Member Functions inherited from bpp::bpp_entity
virtual ~bpp_entity ()=default
 
virtual bool add_class (std::shared_ptr< bpp_class > class_)
 Add a class to this entity's list of classes. More...
 
virtual std::shared_ptr< bpp_classget_class () const
 
virtual std::string get_address () const
 
virtual std::string get_name () const
 
virtual std::weak_ptr< bpp::bpp_classget_containing_class () const
 Get the class which contains this entity. More...
 
virtual bool set_containing_class (std::weak_ptr< bpp::bpp_class > containing_class)
 
virtual void inherit (std::shared_ptr< bpp_entity > parent)
 Inherit from a parent entity. More...
 
virtual void inherit (std::shared_ptr< bpp_class > parent)
 
virtual std::unordered_map< std::string, std::shared_ptr< bpp_class > > get_classes () const
 
virtual std::unordered_map< std::string, std::shared_ptr< bpp_object > > get_objects () const
 
virtual std::shared_ptr< bpp_classget_class (const std::string &name)
 
virtual std::shared_ptr< bpp_objectget_object (const std::string &name)
 

Private Attributes

std::shared_ptr< bpp::bash_while_conditionwhile_condition
 

Additional Inherited Members

- Protected Attributes inherited from bpp::bpp_code_entity
std::shared_ptr< std::ostream > code = std::make_shared<std::ostringstream>()
 
std::string nextline_buffer = ""
 
std::string postline_buffer = ""
 
bool buffers_flushed = false
 
- Protected Attributes inherited from bpp::bpp_entity
std::unordered_map< std::string, std::shared_ptr< bpp_class > > classes
 A map of class names to class objects within this entity. More...
 
std::unordered_map< std::string, std::shared_ptr< bpp_object > > objects
 A map of object names to bpp_objects within this entity. More...
 
std::unordered_map< std::string, std::shared_ptr< bpp_object > > local_objects
 Like objects, but only for objects whose scope is local to this entity. More...
 
std::shared_ptr< bpp_classtype = nullptr
 
std::weak_ptr< bpp_classcontaining_class
 
std::vector< std::shared_ptr< bpp_class > > parents
 

Detailed Description

A while loop in Bash++.

This entity gets pushed onto the entity stack when a while loop is encountered in Bash++ code. It contains a bash_while_condition object which holds the condition for the while loop

The reason for this is that the condition for the while loop may contain references which need to be resolved And the pre- and post-code for those references need to be added in specific places in the compiled code. E.g., supershells must be re-evaluated for each iteration of the loop

The 'bash_' prefix signifies that this is used to parse ordinary Bash code, not anything specific to Bash++

Constructor & Destructor Documentation

◆ bash_while_loop()

bpp::bash_while_loop::bash_while_loop ( )

Member Function Documentation

◆ get_code()

std::string bpp::bash_while_loop::get_code ( ) const
overridevirtual

Return the contents of the main code buffer as a string.

Reimplemented from bpp::bpp_code_entity.

◆ get_post_code()

std::string bpp::bash_while_loop::get_post_code ( ) const
overridevirtual

Return the contents of the post-code buffer as a string.

Reimplemented from bpp::bpp_code_entity.

◆ get_pre_code()

std::string bpp::bash_while_loop::get_pre_code ( ) const
overridevirtual

Return the contents of the pre-code buffer as a string.

Reimplemented from bpp::bpp_code_entity.

◆ get_while_condition()

std::shared_ptr< bpp::bash_while_condition > bpp::bash_while_loop::get_while_condition ( ) const

◆ set_while_condition()

void bpp::bash_while_loop::set_while_condition ( std::shared_ptr< bpp::bash_while_condition while_condition)

Member Data Documentation

◆ while_condition

std::shared_ptr<bpp::bash_while_condition> bpp::bash_while_loop::while_condition
private

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