This class is an interface to the console interpreter. More...
#include "ConsoleInterpreter.hpp"
Public Member Functions | |
virtual | ~ConsoleInterpreterI () |
Virtual dtor so that derived classes properly destroy. More... | |
virtual void | Register (ConVarT *ConVar)=0 |
Registers a convar with the console interpreter. More... | |
virtual void | Register (ConFuncT *ConFunc)=0 |
Registers a confunc with the console interpreter. More... | |
virtual void | Unregister (ConVarT *ConVar)=0 |
Unregisters the given convar from the interpreter again. More... | |
virtual void | Unregister (ConFuncT *ConFunc)=0 |
Unregisters the given confunc from the interpreter again. More... | |
virtual ConFuncT * | FindFunc (const std::string &Name)=0 |
Finds the confunc with the given name. More... | |
virtual ConVarT * | FindVar (const std::string &Name)=0 |
Finds the convar with the given name. More... | |
virtual std::string | LineCompletion (const std::string &LineBegin, ArrayT< std::string > &Completions)=0 |
This method provides command-line completion for this interpreter. More... | |
virtual bool | RunCommand (const std::string &Input)=0 |
Compiles and runs the given Lua statements. More... | |
Static Public Member Functions | |
static void | RegisterLua (lua_State *LuaState) |
Registers the methods of this interface with LuaState as a Lua module as described in the PiL2 book, chapter 26.2. More... | |
This class is an interface to the console interpreter.
User code can register its convars and confuncs with it so that they can be used in the context of the interpreter. For each application, there is only one, global, application-wide, unique implementation of the console interpreter, typically in the main exe, and the exe and all dlls each have a pointer to it.
|
inlinevirtual |
Virtual dtor so that derived classes properly destroy.
|
pure virtual |
Finds the confunc with the given name.
Name | The name of the confunc to find. |
Implemented in ConsoleInterpreterImplT.
|
pure virtual |
Finds the convar with the given name.
Name | The name of the convar to find. |
Implemented in ConsoleInterpreterImplT.
|
pure virtual |
This method provides command-line completion for this interpreter.
It returns all available completions for the last token in the given string LineBegin in the Completions array. Note that the completions not only cover the registered ConFuncTs and ConVarTs, but also any other user- and implementation-defined symbols.
LineBegin | The incomplete command-line string for whose last token the method is supposed to provide completions for. For example, if LineBegin is "a=GetValueX()*Get", the method is supposed to look for completions for "Get". |
Completions | The found completions are returned here as complete tokens. For example, if LineBegin is "a=GetValueX()*Get", Completions may contain the strings "GetValueX" and "GetValueY". The caller can therefore not do much (i.e. concat to input string) with the returned strings but print them out. |
Implemented in ConsoleInterpreterImplT.
|
pure virtual |
Registers a convar with the console interpreter.
This method is normally not called by user code, but by the implementation of the ConVarT ctors and ConVarT::RegisterStaticList().
ConVar | The console variable to register with this interpreter. |
Implemented in ConsoleInterpreterImplT.
|
pure virtual |
Registers a confunc with the console interpreter.
This method is normally not called by user code, but by the implementation of the ConFuncT ctors and ConFuncT::RegisterStaticList().
ConFunc | The console function to register with this interpreter. |
Implemented in ConsoleInterpreterImplT.
|
static |
Registers the methods of this interface with LuaState as a Lua module as described in the PiL2 book, chapter 26.2.
The key idea is that all methods are called via the global ConsoleInterpreter variable defined below, and therefore we may consider them as a collection of C-style functions (no OO involved), so that putting them in a Lua table as described in chapter 26 of the PiL2 book is straightforward.
|
pure virtual |
Compiles and runs the given Lua statements.
Input | The string with the Lua statements that is to be compiled and run within this console state. |
Implemented in ConsoleInterpreterImplT.
|
pure virtual |
Unregisters the given convar from the interpreter again.
ConVar | The console variable to unregister from this interpreter. |
Implemented in ConsoleInterpreterImplT.
|
pure virtual |
Unregisters the given confunc from the interpreter again.
ConFunc | The console function to unregister from this interpreter. |
Implemented in ConsoleInterpreterImplT.