BashSpark
Loading...
Searching...
No Matches
bs::token_holder Class Reference

A class that manages a collection of shell tokens for processing. More...

#include <token_holder.h>

Public Member Functions

 token_holder (ifakestream &oIstream, std::vector< shell_token > vTokens)
 Constructs a token_holder instance.
 
const shell_tokencurrent () const noexcept
 Retrieves the current token.
 
const shell_tokennext () const noexcept
 Retrieves the next token.
 
const shell_tokenprevious () const noexcept
 Retrieves the previous token.
 
const shell_tokenget () noexcept
 Retrieves and advances to the next token.
 
void put_back () noexcept
 Moves the position back by one token.
 
std::size_t pos () const noexcept
 Retrieves the current position of the token holder.
 
bool is (const shell_token_type nType) const noexcept
 Checks if the current token is of a specified type.
 
bool is_next (const shell_token_type nType) const noexcept
 Checks if the next token is of a specified type.
 
shell_keyword keyword () const noexcept
 Retrieves the current shell keyword.
 
bool keyword (const shell_keyword nKeyword) const noexcept
 Checks if the current token is a specific keyword.
 

Detailed Description

A class that manages a collection of shell tokens for processing.

The bs::token_holder class stores a list of shell tokens and provides functionalities to navigate through them, including retrieving the current, next, and previous tokens, as well as checking their types and positions. It utilizes an bs::ifakestream for string representation and size.

Constructor & Destructor Documentation

◆ token_holder()

bs::token_holder::token_holder ( ifakestream oIstream,
std::vector< shell_token vTokens 
)
inline

Constructs a token_holder instance.

Parameters
oIstreamReference to an ifakestream for input handling.
vTokensVector containing shell tokens to manage.

Member Function Documentation

◆ current()

const shell_token * bs::token_holder::current ( ) const
inlinenoexcept

Retrieves the current token.

Returns
A pointer to the current shell_token, or nullptr if out of bounds.

◆ get()

const shell_token * bs::token_holder::get ( )
inlinenoexcept

Retrieves and advances to the next token.

Returns
A pointer to the new current shell_token, or nullptr if out of bounds.

◆ is()

bool bs::token_holder::is ( const shell_token_type  nType) const
inlinenoexcept

Checks if the current token is of a specified type.

Parameters
nTypeThe type to check against.
Returns
True if the current token matches the type; otherwise, false.

◆ is_next()

bool bs::token_holder::is_next ( const shell_token_type  nType) const
inlinenoexcept

Checks if the next token is of a specified type.

Parameters
nTypeThe type to check against.
Returns
True if the next token matches the type; otherwise, false.

◆ keyword() [1/2]

shell_keyword bs::token_holder::keyword ( ) const
inlinenoexcept

Retrieves the current shell keyword.

Returns
The shell keyword associated with the current token.

◆ keyword() [2/2]

bool bs::token_holder::keyword ( const shell_keyword  nKeyword) const
inlinenoexcept

Checks if the current token is a specific keyword.

Parameters
nKeywordThe keyword to compare against.
Returns
True if the current token matches the keyword; otherwise, false.

◆ next()

const shell_token * bs::token_holder::next ( ) const
inlinenoexcept

Retrieves the next token.

Returns
A pointer to the next shell_token, or nullptr if out of bounds.

◆ pos()

std::size_t bs::token_holder::pos ( ) const
inlinenoexcept

Retrieves the current position of the token holder.

Returns
The current position as an std::size_t. If out of bounds, returns the size of the input stream.

◆ previous()

const shell_token * bs::token_holder::previous ( ) const
inlinenoexcept

Retrieves the previous token.

Returns
A pointer to the previous shell_token, or nullptr if out of bounds.

◆ put_back()

void bs::token_holder::put_back ( )
inlinenoexcept

Moves the position back by one token.

This function allows for retroactive examination of the last token retrieved.


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