PLearn 0.1
|
00001 // -*- C++ -*- 00002 00003 // HelpSystem.h 00004 // Copyright (c) 2006 Pascal Vincent 00005 // Copyright (C) 2007 Xavier Saint-Mleux, ApSTAT Technologies, inc. 00006 00007 // Redistribution and use in source and binary forms, with or without 00008 // modification, are permitted provided that the following conditions are met: 00009 // 00010 // 1. Redistributions of source code must retain the above copyright 00011 // notice, this list of conditions and the following disclaimer. 00012 // 00013 // 2. Redistributions in binary form must reproduce the above copyright 00014 // notice, this list of conditions and the following disclaimer in the 00015 // documentation and/or other materials provided with the distribution. 00016 // 00017 // 3. The name of the authors may not be used to endorse or promote 00018 // products derived from this software without specific prior written 00019 // permission. 00020 // 00021 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 00022 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00023 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00024 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00025 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00026 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00027 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00028 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00029 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 // 00032 // This file is part of the PLearn library. For more information on the PLearn 00033 // library, go to the PLearn Web site at www.plearn.org 00034 00037 #ifndef HelpSystem_INC 00038 #define HelpSystem_INC 00039 00040 #include <string> 00041 #include <vector> 00042 #include <utility> 00043 #include <map> 00044 #include <plearn/base/OptionBase.h> 00045 00046 namespace PLearn { 00047 using std::string; 00048 using std::vector; 00049 using std::pair; 00050 using std::map; 00051 00052 00053 struct HelpSystem // more or less a namespace 00054 { 00055 00060 00061 static vector<string> listCommands(); 00062 00064 static string helpCommands(); 00065 00067 static string helpOnCommand(const string& commandname); 00068 00070 static string helpCommandsHTML(); 00071 00073 static string helpOnCommandHTML(const string& commandname); 00074 00079 00080 static vector<pair<string, int> > listFunctions(); 00081 00083 static vector<string> listFunctionPrototypes(); 00084 00086 static string helpFunctions(); 00087 00089 static string helpOnFunction(const string& functionname, int arity); 00090 00092 static string helpFunctionsHTML(); 00093 00096 static string helpOnFunctionHTML(const string& functionname, int arity); 00097 00098 00103 00104 static vector<string> listClasses(); 00105 00107 static map<string, string> getClassTree(); 00108 00110 static string helpClasses(); 00111 00115 static string helpOnClass(const string& classname); 00116 00118 static string helpClassesHTML(); 00119 00121 static string helpOnClassHTML(const string& classname); 00122 00123 /* Class Parents */ 00124 00127 static vector<string> listClassParents(const string& classname); 00128 00131 static string helpClassParents(const string& classname); 00132 00135 static string helpClassParentsHTML(const string& classname); 00136 00137 /* Derived Classes */ 00138 00140 static vector<string> listDerivedClasses(const string& classname); 00141 00143 static string helpDerivedClasses(const string& classname); 00144 00146 static string helpDerivedClassesHTML(const string& classname); 00147 00149 static pair<string, vector<string> > precisOnClass(const string& classname); 00150 00155 00156 static vector<string> listClassOptions(const string& classname); 00157 00159 static vector<string> listBuildOptions(const string& classname); 00160 00162 static vector<pair<OptionBase::OptionLevel, string> > 00163 listClassOptionsWithLevels(const string& classname, 00164 const OptionBase::flag_t& flags= 00165 OptionBase::getCurrentFlags()); 00166 00168 static vector<pair<OptionBase::OptionLevel, string> > 00169 listBuildOptionsWithLevels(const string& classname); 00170 00172 static string helpClassOptions(const string& classname); 00173 00175 static string helpOnOption(const string& classname, const string& optionname); 00176 00178 static string helpClassOptionsHTML(const string& classname); 00179 00182 static string helpOnOptionHTML(const string& classname, 00183 const string& optionname); 00184 00187 static string getOptionDefaultVal(const string& classname, 00188 const string& optionname); 00189 00191 static string getOptionDefiningClass(const string& classname, 00192 const string& optionname); 00193 00198 00199 00200 static vector<pair<string, int> > listMethods(const string& classname); 00201 00203 static vector<string> listMethodPrototypes(const string& classname); 00204 00207 static string helpMethods(const string& classname); 00208 00211 static string helpOnMethod(const string& classname, 00212 const string& methodname, int arity= -1); 00213 00216 static string helpMethodsHTML(const string& classname); 00217 00220 static string helpOnMethodHTML(const string& classname, 00221 const string& methodname, int arity= -1); 00222 00227 private: 00234 static string html_resources_path; 00235 00236 public: 00238 static void setResourcesPathHTML(const string& path) 00239 { html_resources_path= path; } 00240 00242 static string getResourcesPathHTML() 00243 { return html_resources_path; } 00244 00246 static string helpIndexHTML(); 00247 00249 static string helpPrologueHTML(const string& title= 00250 "PLearn User-Level Documentation"); 00251 00253 static string helpEpilogueHTML(); 00254 00255 00256 00257 private: 00258 static PP<OptionBase> getOptionByName(const string& classname, 00259 const string& optionname); 00260 00261 00262 }; 00263 00264 00265 } // end of namespace PLearn 00266 00267 #endif //!< HelpSystem_INC_ 00268 00269 00270 /* 00271 Local Variables: 00272 mode:c++ 00273 c-basic-offset:4 00274 c-file-style:"stroustrup" 00275 c-file-offsets:((innamespace . 0)(inline-open . 0)) 00276 indent-tabs-mode:nil 00277 fill-column:79 00278 End: 00279 */ 00280 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :