39 static RtclNameSet optset(
"-lname|-ltext|-lvalue|-lpair|-lall|"
40 "-atext|-avalue|-print|-reset");
48 if (args.
NextOpt(opt, optset)) {
49 if (opt ==
"-atext" || opt ==
"-avalue") {
50 if (!args.
GetArg(
"varName", varname))
return false;
51 }
else if (opt ==
"-print") {
52 if (!args.
GetArg(
"?format", format))
return false;
53 if (!args.
GetArg(
"?width", width, 0, 32))
return false;
54 if (!args.
GetArg(
"?prec", prec, 0, 32))
return false;
61 if (!args.
AllDone())
return false;
77 Tcl_Interp* interp = args.
Interp();
78 Tcl_Obj* plist = Tcl_GetObjResult(interp);
80 if (cntx.
opt ==
"-lname") {
81 for (
size_t i=0; i<stats.
Size(); i++) {
82 const string& name(stats.
Name(i));
83 RtclOPtr pobj(Tcl_NewStringObj(name.data(), name.length()));
84 if (Tcl_ListObjAppendElement(interp, plist, pobj) != TCL_OK)
return false;
87 }
else if (cntx.
opt ==
"-ltext") {
88 for (
size_t i=0; i<stats.
Size(); i++) {
89 const string& text(stats.
Text(i));
90 RtclOPtr pobj(Tcl_NewStringObj(text.data(), text.length()));
91 if (Tcl_ListObjAppendElement(interp, plist, pobj) != TCL_OK)
return false;
94 }
else if (cntx.
opt ==
"-lvalue") {
95 for (
size_t i=0; i<stats.
Size(); i++) {
97 if (Tcl_ListObjAppendElement(interp, plist, pobj) != TCL_OK)
return false;
100 }
else if (cntx.
opt ==
"-lpair" || cntx.
opt ==
"-lall") {
101 for (
size_t i=0; i<stats.
Size(); i++) {
102 const string& name(stats.
Name(i));
103 RtclOPtr ptup(Tcl_NewListObj(0,
nullptr));
104 Tcl_ListObjAppendElement(
nullptr, ptup,
105 Tcl_NewDoubleObj(stats.
Value(i)));
106 Tcl_ListObjAppendElement(
nullptr, ptup,
107 Tcl_NewStringObj(name.data(), name.length()));
108 if (cntx.
opt ==
"-lall") {
109 const string& text(stats.
Text(i));
110 Tcl_ListObjAppendElement(
nullptr, ptup,
111 Tcl_NewStringObj(text.data(), text.length()));
113 if (Tcl_ListObjAppendElement(interp, plist, ptup) != TCL_OK)
return false;
116 }
else if (cntx.
opt ==
"-atext") {
117 for (
size_t i=0; i<stats.
Size(); i++) {
118 const string& text(stats.
Text(i));
119 RtclOPtr pobj(Tcl_NewStringObj(text.data(), text.length()));
120 if (!Tcl_SetVar2Ex(interp, cntx.
varname.c_str(), stats.
Name(i).c_str(),
121 pobj, TCL_LEAVE_ERR_MSG))
return false;
124 }
else if (cntx.
opt ==
"-avalue") {
125 for (
size_t i=0; i<stats.
Size(); i++) {
127 if (!Tcl_SetVar2Ex(interp, cntx.
varname.c_str(), stats.
Name(i).c_str(),
128 pobj, TCL_LEAVE_ERR_MSG))
return false;
131 }
else if (cntx.
opt ==
"-print") {
136 }
else if (cntx.
opt ==
"-reset") {
140 args.
AppendResult(
"-E: BUG! RtclStats::Collect: bad option '",
141 cntx.
opt.c_str(),
"'",
nullptr);
size_t Size() const
FIXME_docs.
void Print(std::ostream &os, const char *format=0, int width=0, int prec=0) const
FIXME_docs.
const std::string & Name(size_t ind) const
FIXME_docs.
double Value(size_t ind) const
FIXME_docs.
const std::string & Text(size_t ind) const
FIXME_docs.
bool NextOpt(std::string &val)
FIXME_docs.
void AppendResultLines(const std::string &str)
FIXME_docs.
bool GetArg(const char *name, Tcl_Obj *&pval)
FIXME_docs.
void AppendResult(const char *str,...)
FIXME_docs.
Tcl_Interp * Interp() const
FIXME_docs.
bool AllDone()
FIXME_docs.
Implemenation (inline) of RtclOPtr.
static bool Exec(RtclArgs &args, const Context &cntx, Rstats &stats)
FIXME_docs.
static bool GetArgs(RtclArgs &args, Context &cntx)
FIXME_docs.
Declaration of class ReventLoop.