ArkScript
A small, fast, functional and scripting language for video games
Ark::internal::MacroScope Class Reference

#include <MacroScope.hpp>

+ Collaboration diagram for Ark::internal::MacroScope:

Public Member Functions

 MacroScope ()
 
 MacroScope (unsigned int depth)
 Construct a new MacroScope object given a depth in the scope hierarchy.
 
const Nodehas (const std::string &name) const
 Check if the current scope holds a value for a given symbol, and returns it as a pointer.
 
void add (const std::string &name, const Node &node)
 Add a new entry in the scope.
 
bool remove (const std::string &name)
 Remove a macro in the scope, if it exists.
 
bool empty () const
 Return true if the current scope is empty.
 
unsigned int depth () const
 

Private Attributes

std::unordered_map< std::string, Nodem_macros
 
unsigned int m_depth
 

Detailed Description

Definition at line 22 of file MacroScope.hpp.

Constructor & Destructor Documentation

◆ MacroScope() [1/2]

Ark::internal::MacroScope::MacroScope ( )

Definition at line 5 of file MacroScope.cpp.

◆ MacroScope() [2/2]

Ark::internal::MacroScope::MacroScope ( unsigned int  depth)
explicit

Construct a new MacroScope object given a depth in the scope hierarchy.

Parameters
depth

Definition at line 9 of file MacroScope.cpp.

Member Function Documentation

◆ add()

void Ark::internal::MacroScope::add ( const std::string &  name,
const Node node 
)

Add a new entry in the scope.

Parameters
name
node

Definition at line 20 of file MacroScope.cpp.

References m_macros.

◆ depth()

unsigned int Ark::internal::MacroScope::depth ( ) const
inline

Definition at line 70 of file MacroScope.hpp.

References m_depth.

◆ empty()

bool Ark::internal::MacroScope::empty ( ) const
inline

Return true if the current scope is empty.

Returns
true
false

Definition at line 65 of file MacroScope.hpp.

References m_macros.

◆ has()

const Node * Ark::internal::MacroScope::has ( const std::string &  name) const

Check if the current scope holds a value for a given symbol, and returns it as a pointer.

Parameters
name
Returns
Node* pointer to the value if found, nullptr otherwise

Definition at line 13 of file MacroScope.cpp.

References m_macros.

◆ remove()

bool Ark::internal::MacroScope::remove ( const std::string &  name)

Remove a macro in the scope, if it exists.

Parameters
name
Returns
true if the value was found and removed
false otherwise

Definition at line 25 of file MacroScope.cpp.

References m_macros.

Member Data Documentation

◆ m_depth

unsigned int Ark::internal::MacroScope::m_depth
private

Definition at line 77 of file MacroScope.hpp.

Referenced by depth().

◆ m_macros

std::unordered_map<std::string, Node> Ark::internal::MacroScope::m_macros
private

Definition at line 76 of file MacroScope.hpp.

Referenced by add(), empty(), has(), and remove().


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