A class that manages a collection of shell tokens for processing.
More...
#include <token_holder.h>
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.
◆ token_holder()
Constructs a token_holder instance.
- Parameters
-
| oIstream | Reference to an ifakestream for input handling. |
| vTokens | Vector containing shell tokens to manage. |
◆ 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()
Retrieves and advances to the next token.
- Returns
- A pointer to the new current shell_token, or nullptr if out of bounds.
◆ is()
Checks if the current token is of a specified type.
- Parameters
-
| nType | The type to check against. |
- Returns
- True if the current token matches the type; otherwise, false.
◆ is_next()
Checks if the next token is of a specified type.
- Parameters
-
| nType | The type to check against. |
- Returns
- True if the next token matches the type; otherwise, false.
◆ keyword() [1/2]
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
-
| nKeyword | The keyword to compare against. |
- Returns
- True if the current token matches the keyword; otherwise, false.
◆ next()
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:
- /home/runner/work/bashspark/bashspark/src/BashSpark/shell/token_holder.h