Public Member Functions
|command (rutz::shared_ptr< tcl::function > callback, const char *usage, const arg_spec &spec)|
|Build a tcl::command object. |
|~command () throw ()|
|Non-virtual destructor since this class is not for use as a base class. |
|rutz::fstring||usage_string () const|
|Returns a string describing the arguments expected by this command. |
|bool||allows_argc (unsigned int objc) const|
|Check if the given argument count is acceptable. |
|bool||rejects_argc (unsigned int objc) const|
|Check if the given argument count is unacceptable. |
|void||call (tcl::interpreter &interp, unsigned int objc, Tcl_Obj *const objv)|
|Send arguments to its tcl::function via its tcl::arg_dispatcher. |
|rutz::shared_ptr< arg_dispatcher >||get_dispatcher () const|
|Get the current tcl::arg_dispatcher for this command. |
|void||set_dispatcher (rutz::shared_ptr< arg_dispatcher > dpx)|
|Change the tcl::arg_dispatcher for this command. |
tcl::commandprovides a way to wrap Tcl commands in C++ classes. The
tcl::commandclass itself takes care of such things as checking the argument count, and issuing an error message if the argument count is incorrect.
If more than one tcl::command is created with the same name, an overloading sequence is created. Overloading is done by argument counts. The first tcl::command in an overload sequence to match the argument count of the context will be used.
Most clients of tcl::command will be able to simply use tcl::make_command() or tcl::make_vec_command(), which detect the types of C++ functions and build generic tcl::command's that call the functions appropriately, or use tcl::pkg::def() and related functions, which call tcl::make_command() but in addition help to relate the commands to a particular package.
|tcl::command::command||(||rutz::shared_ptr< tcl::function >||callback,|
|const char *||usage,|
|const arg_spec &||spec|
Build a tcl::command object.
BUT, you almost certainly don't want to use this function directly, but should instead call tcl::command_group::make(). If you just create a tcl::command on its own, it won't do anything (it won't be registered with the tcl interpreter). The tcl::command needs to be hooked into a tcl::command_group, and the way to do that is by creating it through tcl::command_group::make().