![]() |
|
Container and execution tools for commands derived from Command. More...
#include <CommandBank.h>


Public Types | |
| typedef data_t | command_t |
Public Types inherited from BankSuper< Command > | |
| typedef Bank< Command, std::string > | bank_t |
| typedef bank_t::key_t | key_t |
| typedef bank_t::bank_id | bank_id |
| typedef Command | data_t |
Public Types inherited from Bank< T, K > | |
| typedef K | key_t |
| Public key type. (Key type used in the public interface.) | |
| typedef T | value_t |
| Base type of cloned objects. | |
| typedef ClonerBase< T > | cloner_t |
| typedef std::map< K, cloner_t * > | map_t |
| Base class. | |
| typedef std::set< K > | key_set_t |
| For enumerating keys. | |
Public Member Functions | |
| CommandBank (const CommandBank &bank) | |
| template<class D , char PREFIX = 0> | |
| D & | addExternal (const D &entry, char alias=0) |
| template<class D > | |
| D & | addExternal (char PREFIX, const D &entry, char alias=0) |
| template<class D , char PREFIX = 0> | |
| D & | addExternal (const D &entry, const std::string &key, char alias=0) |
| void | readFileTXT (const std::string &filename, Script &script) const |
| Include commands from file, inserting them before iterator. | |
| void | readFile (const std::string &filename, Program &prog) const |
| void | scriptify (int argc, const char **argv, Script &script) const |
| Convert program arguments a script. Like in main(), actual command arguments start from 1. | |
| void | scriptify (const std::string &cmdLine, Script &script) const |
| Splits a command line to a list of commands, that is, a script. | |
| bool | scriptify (const std::string &arg, const std::string &argNext, Script &script) const |
| Converts a Unix/Linux command line to pairs (cmd,params) of strings. | |
| void | append (const Script &script, Program &prog) const |
| Converts command strings to executable command objects, appending them to a program. | |
| void | flushRoutine (Script &script, Context &ctx, Program &prog) |
| Append routine to program, and clear routine. | |
| void | remove (Program &prog) const |
| void | run (const std::string &cmd, const std::string ¶ms, Context &ctx) |
| Run a single command. | |
| void | run (Program &prog, ClonerBase< Context > &contextCloner) |
| Unlike compile, "interprets" script by running it command by command. | |
| void | help (std::ostream &ostr=std::cout) |
| Basic help dump, displays help commands to proceed. | |
| void | help (FlagResolver::ivalue_t sectionFilter, std::ostream &ostr=std::cout) |
| Basic help dump, displays help commands to proceed. | |
| void | help (const std::string &key, std::ostream &ostr=std::cout) |
| Help on a specific command or section. | |
| void | info (const std::string &key, const command_t &cmd, std::ostream &ostr=std::cout, bool detailed=true) const |
| Checked key and respective command. | |
| const std::string & | resolveFull (const key_t &key) const |
| Given an alias or a long key, possibly prefixed by hyphens, return the long key if a command exists. | |
| template<class T > | |
| void | exportStatus (std::map< std::string, T > &statusMap) const |
| void | setScriptTriggerFlag (bank_section_t sectionFlag) |
| void | setDefaultCmdKey (const std::string &s) |
| Set command - key, not getName() - that is used if a plain argument is given. | |
| void | setNotFoundHandlerCmdKey (const std::string &s) |
| Set command to be executed when a command - argument with leading hyphen(s) - is not found. | |
| void | setScriptCmd (const std::string &s) |
| Set command for storing a routine. | |
| void | setScriptFileCmd (const std::string &s) |
| Set command for reading and executing commands from a file in the current (running) context. | |
| template<class ... TT> | |
| void | linkRelatedCommands (const TT &... cmds) |
| void | linkRelatedCommandList (const std::set< std::string > &cmdList) |
| Adds command keys, intelinking all the commands in the list. | |
Public Member Functions inherited from BankSuper< Command > | |
| BankSuper (const BankSuper &bank) | |
| D & | add (const std::string &key, char brief=0) |
| D & | add (char brief=0) |
| Add something that has getName() | |
| D & | addExternal (const D &entry, const std::string &key, char brief=0) |
| void | setBriefKey (char brief, const std::string &value) |
| Now, D::getName() is required. | |
| bool | hasAlias (const std::string &value) const |
| bool | hasAlias (char brief) const |
| char | getAlias (const std::string &value) const |
| const drain::Dictionary< char, key_t > & | getAliases () const |
| virtual const std::string & | resolve (const key_t &value) const |
| Given brief or long key, returns the long key . | |
| void | setTitle (const std::string &title) |
| Set name and brief description of a program, to appear in help dumps. | |
| FlagResolver::ivalue_t | addSection (const FlagResolver::dict_t::key_t &title, const FlagResolver::dict_t::value_t index=0) |
Public Member Functions inherited from Bank< T, K > | |
| template<class D > | |
| D & | add (const K &key) |
| Adds class D as an internal instance. | |
| template<class D > | |
| D & | add () |
| template<class D > | |
| D & | addExternal (const D &entry, const K &key) |
| Adds class D using a copy constructor on an external instance. | |
| bool | has (const K &key) const |
| Check if a cloner is defined for this key. | |
| T & | clone (const K &key) const |
| Return a copy of the base instance. | |
| const T & | get (const K &key) const |
| Returns the base instance. | |
| T & | get (const K &key) |
| Returns the base instance. | |
| template<class D > | |
| map_t::const_iterator | get () const |
| Returns a map entry: pair<Key,D *>() | |
| cloner_t & | getCloner (const K &key) const |
| Return the internal static entry. | |
| const map_t & | getMap () const |
| virtual const std::string & | resolve (const K &key) const |
| void | toStream (std::ostream &ostr=std::cout) const |
| key_set_t & | getKeys () |
Static Public Member Functions | |
| static std::set< std::string > & | trimWords () |
| Words that are moved from class name prior to composing a command name. | |
| static void | deriveCmdName (std::string &name, char prefix=0) |
| Given a command class name like MyFileReadCommand, derives a respective command line option ("myFileRead") | |
Static Public Member Functions inherited from Bank< T, K > | |
| template<class D > | |
| static Cloner< T, D > & | getCloner () |
Public Attributes | |
| drain::StringMapper | logFileSyntax |
| bank_section_t | scriptTriggerFlag |
| Member and methods for special commands. | |
| std::string | defaultCmdKey |
| Command that is used, if a plain argument is given. | |
| std::string | notFoundHandlerCmdKey |
| If defined, the command - key not getName() - to which all unresolved commands are directed. | |
| std::string | scriptCmd |
| Command for storing a routine. | |
| std::string | execFileCmd |
| Command for reading and executing commands from a file in the current (running) context. | |
Public Attributes inherited from BankSuper< Command > | |
| FlagResolver::dict_t | sections |
Protected Member Functions | |
| void | append (const Script &script, Context &ctx, Program &prog) const |
| Appends program with commands of the script. | |
| template<class ... TT> | |
| void | linkRelatedCommandList (std::set< std::string > &cmdList, const std::string &cmd, const TT &... cmds) |
| template<class ... TT> | |
| void | linkRelatedCommandList (std::set< std::string > &cmdList, const char *cmd, const TT &... cmds) |
Protected Member Functions inherited from Bank< T, K > | |
| drain::ClonerBase< T > & | set (const std::string &key, drain::ClonerBase< T > &cloner) |
Static Protected Member Functions | |
| static void | tokenize (const std::string &cmdLine, std::list< std::string > &args) |
Additional Inherited Members | |
Protected Attributes inherited from BankSuper< Command > | |
| drain::Dictionary< char, std::string > | briefKeys |
| std::string | title |
| For example, name of the program, to appear in help dumps etc. | |
Protected Attributes inherited from Bank< T, K > | |
| key_set_t | keys |
Container and execution tools for commands derived from Command.
Converts command strings to executable command objects, appending them to a program.
Note: appends commands to the end of the program, use prog.clear() if needed.
| void info | ( | const std::string & | key, |
| const command_t & | cmd, | ||
| std::ostream & | ostr = std::cout, |
||
| bool | detailed = true |
||
| ) | const |
Checked key and respective command.
Adds a section key (without checking it).
Checked key and respective command
| void readFile | ( | const std::string & | filename, |
| Program & | prog | ||
| ) | const |
Copy to list, and assign once to get full lastParameters
| void readFileTXT | ( | const std::string & | filename, |
| Script & | script | ||
| ) | const |
Include commands from file, inserting them before iterator.
A mini program executed after each cmd until ']' or ')' is encountered Read commands from a text file and insert them into a string. Non-static – CommandBank is needed for checking if a command has arguments.
| const std::string & resolveFull | ( | const key_t & | key | ) | const |
Given an alias or a long key, possibly prefixed by hyphens, return the long key if a command exists.
Given alias or long key, possibly prefixed by hyphens, return the long key if a command exists.
| void run | ( | Program & | prog, |
| ClonerBase< Context > & | contextCloner | ||
| ) |
Unlike compile, "interprets" script by running it command by command.
MAIN
| bool scriptify | ( | const std::string & | arg, |
| const std::string & | argNext, | ||
| Script & | script | ||
| ) | const |
Converts a Unix/Linux command line to pairs (cmd,params) of strings.
Non-static – CommandBank is needed for checking if a command has arguments.
| void scriptify | ( | const std::string & | cmdLine, |
| Script & | script | ||
| ) | const |
Splits a command line to a list of commands, that is, a script.
Non-static – CommandBank is needed for checking if a command has arguments.
| void scriptify | ( | int | argc, |
| const char ** | argv, | ||
| Script & | script | ||
| ) | const |
Convert program arguments a script. Like in main(), actual command arguments start from 1.
Converts linux command line to pairs of strings: (<cmd>, [params])
Non-static – CommandBank is needed for checking if a command has arguments.
Starts from argument 1 instead of 0.
|
inline |
Set command - key, not getName() - that is used if a plain argument is given.
|
inline |
Set command to be executed when a command - argument with leading hyphen(s) - is not found.
The argument will be passed to the command.
|
inline |
Set command for reading and executing commands from a file in the current (running) context.
Set command for reading and executing commands from a file in the current (running) context
| std::string defaultCmdKey |
Command that is used, if a plain argument is given.
Technically, plain <argument> is replaced by defaultCmd <argument>
1.9.8