tcl::command Class Reference

#include <tcl/command.h>

Collaboration diagram for tcl::command:

Collaboration graph

List of all members.

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_dispatcherget_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.


class  impl

Detailed Description

tcl::command provides a way to wrap Tcl commands in C++ classes. The tcl::command class itself takes care of such things as checking the argument count, and issuing an error message if the argument count is incorrect.

tcl::command uses class tcl::call_context to represent the set of Tcl command arguments and the interpreter's result.

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.

Definition at line 102 of file command.h.

Constructor & Destructor Documentation

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().

Definition at line 128 of file

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

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:56:47 2008 by Doxygen version 1.5.5.