Commander-API
V2.0.0
Commander-API is a C++ API, that parses character based commands.
|
#include <Commander-API.hpp>
Classes | |
struct | API_t |
Structure for command data. More... | |
Public Types | |
typedef struct Commander::API_t | API_t |
Structure for command data. More... | |
Public Member Functions | |
void | attachTreeFunction (API_t *API_tree_p, uint32_t API_tree_size_p) |
Attach API-tree to the object. More... | |
void | init () |
Initializer. More... | |
API_t * | operator[] (int i) |
Array index operator overload for int type. More... | |
API_t * | operator[] (char *name) |
Array index operator overload for char array( string ). More... | |
API_t * | operator[] (const char *name) |
Array index operator overload for const char array( string ). More... | |
void | execute (char *cmd) |
Default execution function. More... | |
void | execute (const char *cmd) |
Default execution function. More... | |
void | enableDebug () |
Enables debug messages. More... | |
void | disableDebug () |
Disables debug messages. More... | |
Static Public Attributes | |
static const char * | version = COMMANDER_API_VERSION |
Library version string. More... | |
Commander class.
This class can be used to create a command parser. Its job is to parse a command from a character array( string ) and find the matching function for that command from a database. This database consists an array of API_t-type elements, and these elements are store the relevant information for that specific command.
typedef struct Commander::API_t Commander::API_t |
Structure for command data.
Every command will get a structure like this. This structure is used to store your commands in a balanced binary tree.
void Commander::attachTreeFunction | ( | API_t * | API_tree_p, |
uint32_t | API_tree_size_p | ||
) |
Attach API-tree to the object.
With this function you can attach the API-tree structure array to the object. This array contains the data for each command.
void Commander::disableDebug | ( | ) |
Disables debug messages.
void Commander::enableDebug | ( | ) |
Enables debug messages.
void Commander::execute | ( | char * | cmd | ) |
Default execution function.
This function tries to execute a command. It uses the default response channel, so the messages from the command handler wont be visible.
void Commander::execute | ( | const char * | cmd | ) |
Default execution function.
This function tries to execute a command. It uses the default response channel, so the messages from the command handler wont be visible.
void Commander::init | ( | ) |
Initializer.
This function initializes the object and its internal parts. Firstly it makes the API-tree alphabetically ordered, then creates a balanced binary tree from it. It is necessary to speed up the search process.
Commander::API_t * Commander::operator[] | ( | char * | name | ) |
Array index operator overload for char array( string ).
With this function you can get a pointer to an element from the API-tree by it's name. If the name is not found the return value will be NULL.
Commander::API_t * Commander::operator[] | ( | const char * | name | ) |
Array index operator overload for const char array( string ).
With this function you can get a pointer to an element from the API-tree by it's name. If the name is not found the return value will be NULL.
Commander::API_t * Commander::operator[] | ( | int | i | ) |
Array index operator overload for int type.
With this function you can get a pointer to an element from the API-tree by it's index. If the index is invalid, the return value will be NULL.
|
static |
Library version string.