BashSpark
Loading...
Searching...
No Matches
bs::shell_node_session_extractor Class Referenceabstract

Base for nodes that extract values from the session (args/vars/etc.). More...

#include <shell_node.h>

Inheritance diagram for bs::shell_node_session_extractor:
Collaboration diagram for bs::shell_node_session_extractor:

Public Member Functions

 shell_node_session_extractor (const shell_node_type nType, const std::size_t nPos)
 Construct a session extractor node.
 
void expand (std::vector< std::string > &vTokens, shell_session &oSession, bool bSplit) const override
 Expand by retrieving the value via get_value() and appending it.
 
virtual std::string get_value (const shell_session &oSession) const =0
 Retrieve the textual value from the given session.
 
- Public Member Functions inherited from bs::shell_node_expandable
 shell_node_expandable (const shell_node_type nType, const std::size_t nPos)
 Construct an expandable 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

Base for nodes that extract values from the session (args/vars/etc.).

Derived classes implement get_value() to read a value from the provided session. During expand(), the extracted value is appended to the token list.

Constructor & Destructor Documentation

◆ shell_node_session_extractor()

bs::shell_node_session_extractor::shell_node_session_extractor ( const shell_node_type  nType,
const std::size_t  nPos 
)
inline

Construct a session extractor node.

Parameters
nTypeSpecific node type.
nPosPosition in input.

Member Function Documentation

◆ expand()

void bs::shell_node_session_extractor::expand ( std::vector< std::string > &  vTokens,
shell_session oSession,
bool  bSplit 
) const
overridevirtual

Expand by retrieving the value via get_value() and appending it.

Parameters
vTokensToken vector to update.
oSessionActive shell session.
bSplitWhether to apply word-splitting rules.

Implements bs::shell_node_expandable.

◆ get_value()

virtual std::string bs::shell_node_session_extractor::get_value ( const shell_session oSession) const
pure virtual

Retrieve the textual value from the given session.

Parameters
oSessionThe session to query.
Returns
std::string The extracted string value.

Implemented in bs::shell_node_arg, bs::shell_node_variable, bs::shell_node_dollar_variable, bs::shell_node_dollar_arg, bs::shell_node_dollar_arg_dhop, bs::shell_node_dollar_variable_dhop, and bs::shell_node_dollar_special.


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