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

Extract a named shell variable from the session environment. More...

#include <shell_node.h>

Inheritance diagram for bs::shell_node_variable:
Collaboration diagram for bs::shell_node_variable:

Public Member Functions

 shell_node_variable (const std::size_t nPos, std::string sVariable)
 Construct a variable extractor.
 
std::string get_value (const shell_session &oSession) const override
 Get the variable's value from the session.
 
std::string get_variable () const noexcept
 Name of the referenced variable.
 
- Public Member Functions inherited from bs::shell_node_session_extractor
 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.
 
- 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

Extract a named shell variable from the session environment.

This node reads a variable by name when expanded.

Constructor & Destructor Documentation

◆ shell_node_variable()

bs::shell_node_variable::shell_node_variable ( const std::size_t  nPos,
std::string  sVariable 
)
inline

Construct a variable extractor.

Parameters
nPosPosition in stream.
sVariableName of the variable (moved in).

Member Function Documentation

◆ get_value()

std::string bs::shell_node_variable::get_value ( const shell_session oSession) const
overridevirtual

Get the variable's value from the session.

Parameters
oSessionSession providing environment variables.
Returns
std::string Value (empty if not present).

Implements bs::shell_node_session_extractor.

◆ get_variable()

std::string bs::shell_node_variable::get_variable ( ) const
inlinenoexcept

Name of the referenced variable.

Returns
std::string Variable name.

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