BashSpark
Loading...
Searching...
No Matches
bs::shell_node_until Class Referencefinal

'Until' loop node that executes the iterative block until the condition succeeds. More...

#include <shell_node.h>

Inheritance diagram for bs::shell_node_until:
Collaboration diagram for bs::shell_node_until:

Public Member Functions

 shell_node_until (std::size_t nPos, std::unique_ptr< shell_node_evaluable > &&pCondition, std::unique_ptr< shell_node_evaluable > &&pIterative)
 Construct an until-loop node.
 
shell_status evaluate (shell_session &oSession) const override
 Evaluate the until-loop.
 
const shell_node_evaluableget_condition () const noexcept
 Get the stopping condition node.
 
const shell_node_evaluableget_iterative () const noexcept
 Get the iterative block executed while the condition fails.
 
- Public Member Functions inherited from bs::shell_node_evaluable
 shell_node_evaluable (const shell_node_type nType, const std::size_t nPos)
 Construct an evaluable node.
 
- Public Member Functions inherited from bs::shell_node
virtual ~shell_node ()=default
 Virtual default destructor for polymorphic deletion.
 
shell_node_type get_type () const noexcept
 Get the node type.
 
std::size_t get_pos () const noexcept
 Get node position in the original input stream.
 

Additional Inherited Members

- Protected Member Functions inherited from bs::shell_node
 shell_node (const shell_node_type nType, const std::size_t nPos)
 Protected constructor used by derived classes.
 
- Protected Attributes inherited from bs::shell_node
const shell_node_type m_nType
 Node type.
 
const std::size_t m_nPos
 Position in the input stream.
 

Detailed Description

'Until' loop node that executes the iterative block until the condition succeeds.

Semantically inverted from a while loop: the loop continues while the condition fails and stops when the condition returns success. Ownership rules match the while node.

Constructor & Destructor Documentation

◆ shell_node_until()

bs::shell_node_until::shell_node_until ( std::size_t  nPos,
std::unique_ptr< shell_node_evaluable > &&  pCondition,
std::unique_ptr< shell_node_evaluable > &&  pIterative 
)

Construct an until-loop node.

Exceptions
shell_node_invalid_argumentIf pCondition or pIterative is null.
Parameters
nPosPosition in the input stream where the until loop starts.
pConditionOwned evaluable node representing the stopping condition.
pIterativeOwned evaluable block executed while the condition indicates failure.

Member Function Documentation

◆ evaluate()

shell_status bs::shell_node_until::evaluate ( shell_session oSession) const
overridevirtual

Evaluate the until-loop.

Repeatedly evaluates m_pCondition and executes m_pIterative while the condition returns a non-success status. The loop ends when the condition returns success. The returned status follows shell semantics (last iteration or control).

Parameters
oSessionSession context used for evaluation.
Returns
shell_status Status from the loop execution or the stopping condition.

Implements bs::shell_node_evaluable.

◆ get_condition()

const shell_node_evaluable * bs::shell_node_until::get_condition ( ) const
inlinenoexcept

Get the stopping condition node.

Returns
const Non-owning pointer to the condition.

◆ get_iterative()

const shell_node_evaluable * bs::shell_node_until::get_iterative ( ) const
inlinenoexcept

Get the iterative block executed while the condition fails.

Returns
Non-owning pointer to the iterative block.

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