68 Tcl_Interp* interp = args.
Interp();
70 if (
size_t(args.
Objc()) == args.
NDone()) {
71 it_match =
fMethMap.find(
"$default");
73 return (it_match->second)(args);
76 Tcl_WrongNumArgs(interp, args.
NDone(), args.
Objv(),
"option ?args?");
83 it_match =
fMethMap.lower_bound(name);
86 if (name ==
"?")
return M_info(args);
90 name!=it_match->first.substr(0,name.length())) {
92 auto it_un =
fMethMap.find(
"$unknown");
94 return (it_un->second)(args);
97 Tcl_AppendResult(interp,
"-E: bad option '", name.c_str(),
98 "': must be ",
nullptr);
99 const char* delim =
"";
101 if (kv.first.c_str()[0] !=
'$') {
102 Tcl_AppendResult(interp, delim, kv.first.c_str(),
nullptr);
110 if (name != it_match->first) {
113 if (it1!=
fMethMap.end() && name==it1->first.substr(0,name.length())) {
114 Tcl_AppendResult(interp,
"-E: ambiguous option '",
115 name.c_str(),
"': must be ",
nullptr);
116 const char* delim =
"";
117 for (it1=it_match; it1!=
fMethMap.end() &&
118 name==it1->first.substr(0,name.length()); it1++) {
119 Tcl_AppendResult(interp, delim, it1->first.c_str(),
nullptr);
126 return (it_match->second)(args);
134 auto ret =
fMethMap.emplace(name, move(methfo));
135 if (ret.second ==
false)
137 string(
"Bad args: duplicate name: '") + name +
"'");
148 string(
"Bad args: non-existing name: '") + name +
"'");
169 while (args.
NextOpt(opt, optset)) {
170 if (opt ==
"-brief") { detail = -1;}
171 else if (opt ==
"-v") { detail = +1;}
172 else if (opt ==
"-vv") { detail = +2;}
173 else if (opt ==
"-vvv") { detail = +3;}
185 Tcl_Interp* interp = args.
Interp();
187 if (!args.
GetArg(
"??cname", cname))
return TCL_ERROR;
188 if (!args.
AllDone())
return TCL_ERROR;
190 RtclOPtr rlist(Tcl_NewListObj(0,
nullptr));
193 if (kv.first[0] ==
'$')
continue;
194 RtclOPtr pele(Tcl_NewStringObj(kv.first.c_str(), -1));
195 Tcl_ListObjAppendElement(
nullptr, rlist, pele);
199 auto it_match =
fMethMap.lower_bound(cname);
200 for (
auto it=it_match; it!=
fMethMap.end() &&
201 cname==it->first.substr(0,cname.length()); it++) {
202 RtclOPtr pele(Tcl_NewStringObj(it->first.c_str(), -1));
203 Tcl_ListObjAppendElement(
nullptr, rlist, pele);
207 Tcl_SetObjResult(interp, rlist);
bool NextOpt(std::string &val)
FIXME_docs.
Tcl_Obj *const * Objv() const
FIXME_docs.
bool GetArg(const char *name, Tcl_Obj *&pval)
FIXME_docs.
bool OptValid() const
FIXME_docs.
int Objc() const
FIXME_docs.
size_t NDone() const
FIXME_docs.
Tcl_Interp * Interp() const
FIXME_docs.
bool AllDone()
FIXME_docs.
mmap_t::const_iterator mmap_cit_t
void AddMeth(const std::string &name, methfo_t &&methfo)
FIXME_docs.
int M_info(RtclArgs &args)
FIXME_docs.
virtual ~RtclCmdBase()
Destructor.
mmap_t fMethMap
map for named methods
std::function< int(RtclArgs &)> methfo_t
bool GetArgsDump(RtclArgs &args, int &detail)
FIXME_docs.
void DelMeth(const std::string &name)
FIXME_docs.
int DispatchCmd(RtclArgs &args)
FIXME_docs.
bool TstMeth(const std::string &name)
FIXME_docs.
Implemenation (inline) of RtclOPtr.
Declaration of class ReventLoop.