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

Node that evaluates an expandable expression as a test/condition. More...

#include <shell_node.h>

Inheritance diagram for bs::shell_node_test:
Collaboration diagram for bs::shell_node_test:

Public Member Functions

 shell_node_test (std::size_t nPos, std::unique_ptr< shell_node_expandable > &&pTest)
 Construct a test node.
 
shell_status evaluate (shell_session &oSession) const override
 Evaluate the test.
 
const shell_node_expandableget_test () const noexcept
 Get the underlying expandable test node.
 
- 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

Node that evaluates an expandable expression as a test/condition.

This node wraps an expandable node used as a boolean-style test. The wrapped expandable will be expanded to tokens and then interpreted according to the shell's test semantics during evaluation.

Constructor & Destructor Documentation

◆ shell_node_test()

bs::shell_node_test::shell_node_test ( std::size_t  nPos,
std::unique_ptr< shell_node_expandable > &&  pTest 
)

Construct a test node.

Exceptions
shell_node_invalid_argumentIf pTest is null.
Parameters
nPosPosition in the input stream where the test begins.
pTestOwned expandable node representing the test expression.

Member Function Documentation

◆ evaluate()

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

Evaluate the test.

The implementation expands the internal expandable and evaluates the resulting tokens as a test/condition. The command test is used to evaluate the condition, and in case of absence, a new instance of bs::command_test will be used.

Parameters
oSessionSession context used for expansion and evaluation.
Returns
shell_status Resulting status of the test evaluation.

Implements bs::shell_node_evaluable.

◆ get_test()

const shell_node_expandable * bs::shell_node_test::get_test ( ) const
inlinenoexcept

Get the underlying expandable test node.

Returns
const The underlying expandable test node.

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