Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Command.cpp

Go to the documentation of this file.
00001 #include "Command.h"
00002 
00006 Command::Command() {
00007     m_numArgs = 0;
00008     m_ul = false;
00009     m_newlines = true;
00010 } // ctor
00011 
00012 
00016 void 
00017 Command::setArg(int index, string value) {
00018     if ((index >= 0) && (index < MAX_COMMAND_ARGS) && (!value.empty())) {
00019         if (m_args[index].empty()) {
00020             m_numArgs++;
00021         }
00022         m_args[index] = value;     
00023     }
00024 } // fn setArg
00025 
00026 
00030 string
00031 Command::getArg(int index) {
00032     return m_args[index];
00033 } // fn getArg
00034 
00035 
00039 void 
00040 Command::clear() {
00041     for (int i = 0; i < MAX_COMMAND_ARGS; i++ ) {
00042         m_args[i].erase();
00043     }
00044 } // fn clear
00045 
00046 
00050 void 
00051 Command::getHelp(std::ostream& s) {
00052     s << "No help provided for this command";
00053 } // fn getHelp
00054 
00055 
00056 void
00057 Command::beginUl(std::ostream& out) {
00058     out << "<ul>";
00059     m_ul = true;
00060 }
00061 
00062 
00063 void
00064 Command::endUl(std::ostream& out) {
00065     out << "</ul>";
00066     m_ul = false;
00067 }
00068 
00069 
00070 void 
00071 Command::preformatting(std::ostream& out) {
00072     if (m_ul) {
00073         out << "<li>";
00074     }
00075 }
00076 
00077 
00078 void
00079 Command::setNewlines(bool value) {
00080     m_newlines = value;
00081 }
00082 
00083 
00084 void
00085 Command::postformatting(std::ostream& out) {
00086     if (m_newlines) {
00087         out << "\n";
00088     }
00089 }
00090 
00091 
00095 void
00096 Command::getHtmlInterface(std::ostream& s) {
00097     s << "<h2>" << getCommandString() << "</h2> (HTML interface not defined for this command)\n";
00098 } // fn getHtmlInterface
00099 
00100 
00101 void
00102 Command::generateHtmlCmd(std::ostream& out, string command, string description) {
00103     preformatting(out);
00104     out << "<a href=\"/?cmd=" << command << "\">" << description << "</a>";
00105     postformatting(out);
00106 } // fn generateHtmlCmd
00107 
00108 
00112 void
00113 Command::generateHtmlCmd(std::ostream& out, string description) {
00114     generateHtmlCmd(out, getCommandString(), description);
00115 } // fn generateHtmlCmd
00116 
00117 
00121 void
00122 Command::generateHtmlSubcmd(std::ostream& out, string subcmd, string description) {
00123     preformatting(out);
00124     out << "<a href=/?cmd=" << getCommandString() << "&subcmd=" << subcmd << ">" << description << "</a>";
00125     postformatting(out);
00126 } // fn generateHtmlSubcmd
00127 
00128 
00132 void 
00133 Command::generateHtmlSubcmdArg1(std::ostream& out, string subcmd, string description, string buttonString) {
00134     generateHtmlSubcmdArg1(out, subcmd, description, buttonString, "");
00135 } // fn generateHtmlSubcmdArg1
00136 
00137 
00141 void 
00142 Command::generateHtmlSubcmdArg1(std::ostream& out, string subcmd, string description, string buttonString, string value) {
00143     preformatting(out);
00144     beginForm(out);
00145     formInput(out, "hidden", "cmd", getCommandString());
00146     formInput(out, "hidden", "subcmd", subcmd);
00147     out << " " << description;
00148     formInput(out, "text", "arg1", value);
00149     out << " ";
00150     formInput(out, "submit", "", buttonString);
00151     endForm(out);
00152     postformatting(out);
00153 } // fn generateHtmlSubcmdArg1
00154 
00155 
00159 void 
00160 Command::generateHtmlSubcmdArg2(std::ostream& out, string subcmd, string description1, string description2, string buttonString) {
00161     preformatting(out);
00162     beginForm(out);
00163     formInput(out, "hidden", "cmd", getCommandString());
00164     formInput(out, "hidden", "subcmd", subcmd);
00165     out << " " << description1;
00166     formInput(out, "text", "arg1", "");
00167     out << " " << description2;
00168     formInput(out, "text", "arg2", "");
00169     out << " ";
00170     formInput(out, "submit", "", buttonString);
00171     endForm(out);
00172     postformatting(out);
00173 } // generateHtmlSubcmdArg2
00174 
00175 
00179 void 
00180 Command::generateHtmlSubcmdArg3(std::ostream& out, 
00181                                 string subcmd, 
00182                                 string description1, 
00183                                 string description2, 
00184                                 string description3,
00185                                 string buttonString) {
00186     preformatting(out);
00187     beginForm(out);
00188     formInput(out, "hidden", "cmd", getCommandString());
00189     formInput(out, "hidden", "subcmd", subcmd);
00190     out << " " << description1;
00191     formInput(out, "text", "arg1", "");
00192     out << " " << description2;
00193     formInput(out, "text", "arg2", "");
00194     out << " " << description3;
00195     formInput(out, "text", "arg3", "");
00196     out << " ";
00197     formInput(out, "submit", "", buttonString);
00198     endForm(out);
00199     postformatting(out);
00200 } // fn generateHtmlSubcmdArg3
00201 
00202 
00206 void 
00207 Command::generateHtmlSubcmdArg4(std::ostream& out, 
00208                                 string subcmd, 
00209                                 string description1, 
00210                                 string description2, 
00211                                 string description3,
00212                                 string description4,
00213                                 string buttonString) {
00214     preformatting(out);
00215     beginForm(out);
00216     formInput(out, "hidden", "cmd", getCommandString());
00217     formInput(out, "hidden", "subcmd", subcmd);
00218     out << " " << description1;
00219     formInput(out, "text", "arg1", "");
00220     out << " " << description2;
00221     formInput(out, "text", "arg2", "");
00222     out << " " << description3;
00223     formInput(out, "text", "arg3", "");
00224     out << " " << description4;
00225     formInput(out, "text", "arg4", "");
00226     out << " ";
00227     formInput(out, "submit", "", buttonString);
00228     endForm(out);
00229     postformatting(out);
00230 } // fn generateHtmlSubcmdArg4
00231 
00232 
00240 void
00241 Command::generateHtmlCheckbox(std::ostream& out, string description, string value, bool isChecked) {
00242     preformatting(out);
00243     out <<  description << " <input type=checkbox name=arg value=" << value << " " 
00244         <<  (isChecked ? "CHECKED" : "" ) << ">";
00245     postformatting(out);
00246 } // fn generateHtmlCheckbox
00247 
00248 
00249 void 
00250 Command::beginForm(std::ostream& out) {
00251     beginForm(out, "/", "get");
00252 } // fn beginForm
00253 
00254 
00255 void 
00256 Command::beginForm(std::ostream& out, string action, string method) {
00257     out << "<form action=\"" << action << "\" method=" << method << ">";
00258 }// fn beginForm
00259 
00260 
00261 void
00262 Command::endForm(std::ostream& out) {
00263     out << "</form>";
00264 }
00265 
00266 
00267 void 
00268 Command::formInput(std::ostream& out, string type, string name, string value) {
00269     out << "<input type=" << type << " name=\"" << name << "\" value=\"" << value << "\">";
00270 } // fn formInput
00271 

Generated at Thu Jul 11 13:31:49 2002 for Peekabooty by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001