33#include <unordered_map>
39 class shell_node_evaluable;
65 const auto pIter = this->m_mFunctions.find(sVar);
66 return pIter != this->m_mFunctions.end() ? pIter->second :
nullptr;
75 this->m_mFunctions[sName] = pFunction;
83 [[nodiscard]]
bool has_func(
const std::string &sName)
const noexcept {
84 return this->m_mFunctions.contains(sName);
92 return this->m_mFunctions.size();
99 [[nodiscard]]
const std::unordered_map<std::string, const func_type*, shell_hash> &
get_env() const noexcept {
100 return this->m_mFunctions;
105 std::unordered_map<std::string, const func_type*, shell_hash> m_mFunctions;
Base interface for nodes that can be evaluated (executed).
Definition shell_node.h:164
Represents an environment for shell commands.
Definition shell_vtable.h:49
std::size_t get_vtable_size() const noexcept
Gets the number of functions in the vtable.
Definition shell_vtable.h:91
bool has_func(const std::string &sName) const noexcept
Checks if a function exists.
Definition shell_vtable.h:83
shell_vtable()=default
Default constructor (empty environment).
const func_type * get_func(const std::string &sVar) const
Gets a function.
Definition shell_vtable.h:64
void set_func(const std::string &sName, const func_type *pFunction)
Sets the a function.
Definition shell_vtable.h:74
const std::unordered_map< std::string, const func_type *, shell_hash > & get_env() const noexcept
Retrieves all environment variables.
Definition shell_vtable.h:99
BashSpark main namespace.
Definition command.h:39
Defines the bs::shell_hash functor implementing a 64-bit FNV-1a hash.
Defines the shell node hierarchy used by the parser.