Changeset 2466 in Sophya for trunk/SophyaLib/SysTools
- Timestamp:
- Nov 27, 2003, 11:52:55 AM (22 years ago)
- Location:
- trunk/SophyaLib/SysTools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SysTools/commander.cc
r2464 r2466 321 321 322 322 // cmdhgrp["All"] = 0; 323 324 string grp = "Commander"; 325 string gdesc = "Basic (generic) interpreter (class SOPHYA::Commander) builtin commands"; 326 AddHelpGroup(grp, gdesc); 323 327 324 328 string kw = "Commander"; … … 354 358 usage += " > help <command_name> # <command_name> usage info \n"; 355 359 usage += " > timingon timingoff traceon traceoff \n"; 356 string grp = "Commander";357 360 RegisterHelp(kw, usage, grp); 358 361 … … 436 439 437 440 /* --Methode-- */ 438 void Commander::RegisterCommand(string& keyw, string& usage, CmdExecutor * ce, string grp) 441 void Commander::AddHelpGroup(string& grp, string& desc) 442 { 443 int gid; 444 CheckHelpGrp(grp, gid, desc); 445 } 446 447 /* --Methode-- */ 448 void Commander::RegisterCommand(string& keyw, string& usage, CmdExecutor * ce, string& grp) 439 449 { 440 450 if (!ce) { … … 442 452 return; 443 453 } 444 int gid = CheckHelpGrp(grp); 454 int gid; 455 CheckHelpGrp(grp,gid); 445 456 cmdex cme; 446 457 cme.group = gid; … … 453 464 void Commander::RegisterHelp(string& keyw, string& usage, string& grp) 454 465 { 455 int gid = CheckHelpGrp(grp); 466 int gid; 467 CheckHelpGrp(grp,gid); 456 468 cmdex cme; 457 469 cme.group = gid; … … 462 474 463 475 /* --Methode-- */ 464 int Commander::CheckHelpGrp(string& grp)465 { 466 int gid=0;476 bool Commander::CheckHelpGrp(string& grp, int& gid, string& desc) 477 { 478 gid = 0; 467 479 CmdHGroup::iterator it = cmdhgrp.find(grp); 468 480 if (it == cmdhgrp.end()) { 469 cmdgrpid++; gid = cmdgrpid; 470 cmdhgrp[grp] = gid; 471 // _helpmgr->AddHelpGroup(grp.c_str(), gid); 472 } 473 else gid = (*it).second; 474 return(gid); 481 cmdgrpid++; gid = cmdgrpid; 482 hgrpst hgs; hgs.gid = gid; hgs.desc = desc; 483 cmdhgrp[grp] = hgs; 484 return true; 485 } 486 else { 487 if (desc.length() > 0) (*it).second.desc = desc; 488 gid = (*it).second.gid; 489 return false; 490 } 475 491 } 476 492 … … 1736 1752 if (! isalnum(prl[k]) ) prl[k] = 'Z'; 1737 1753 } 1754 1738 1755 // Fonction qui remplace _ en \_ 1739 1756 static string check_latex_underscore(string const & mot) … … 1741 1758 string rs; 1742 1759 for(int k=0; k<mot.length(); k++) { 1743 if (mot[k] == '_') rs += "\\_";1760 if (mot[k] == '_') rs += "\\_"; 1744 1761 else rs += mot[k]; 1745 1762 } … … 1800 1817 int gid; 1801 1818 for(it = cmdhgrp.begin(); it != cmdhgrp.end(); it++) { 1802 gid = (*it).second ;1819 gid = (*it).second.gid; 1803 1820 if (gid == 0) continue; 1804 1821 // fputs("\\begin{table}[h!] \n",fip); 1805 1822 fputs("\\vspace{6mm} \n",fip); 1806 1823 fputs("\\begin{center} \n ", fip); 1807 fprintf(fip, "\\rule{2cm}{ 1mm} \\makebox[60mm]{{ \\bf %s } help group} \\rule{2cm}{1mm} \\\\ \n",1824 fprintf(fip, "\\rule{2cm}{0.5mm} \\makebox[60mm]{{ \\bf %s } help group} \\rule{2cm}{0.5mm} \\\\ \n", 1808 1825 (*it).first.c_str()); 1809 1826 fputs("\\vspace{3mm} \n",fip); … … 1841 1858 1842 1859 for(it = cmdhgrp.begin(); it != cmdhgrp.end(); it++) { 1843 gid = (*it).second ;1860 gid = (*it).second.gid; 1844 1861 if (gid == 0) continue; 1845 1862 prl = (*it).first; check_latex_reflabel(prl); 1846 1863 fprintf(fip,"\\subsection{%s} \\label{%s} \n", 1847 1864 (*it).first.c_str(), prl.c_str()); 1865 if ((*it).second.desc.length() > 0) 1866 fprintf(fip,"%s \n \\\\[2mm] ", (*it).second.desc.c_str()); 1848 1867 fprintf(fip,"\\noindent \n"); 1849 1868 for(ite = helpexmap.begin(); ite != helpexmap.end(); ite++) { … … 1870 1889 1871 1890 fclose(fip); 1891 cout << " Commander::HelptoLaTeX() - LaTeX format help written to file " << fname << endl; 1892 1872 1893 return; 1873 1894 } -
trunk/SophyaLib/SysTools/commander.h
r2446 r2466 73 73 virtual string Name(); 74 74 75 virtual void AddHelpGroup(string& grp, string& desc); 75 76 virtual void RegisterCommand(string& keyw, string& usage, CmdExecutor * ce, 76 string grp="Commands"); 77 string& grp); 78 inline void RegisterCommand(string& keyw, string& usage, CmdExecutor * ce, 79 char* grp) 80 { string sgrp = grp; RegisterCommand(keyw, usage, ce, sgrp); } 81 77 82 virtual void RegisterHelp(string& keyw, string& usage, string& grp); 78 83 … … 104 109 string& toks, bool uq=true); 105 110 protected: 106 virtual int CheckHelpGrp(string& grp); 111 virtual bool CheckHelpGrp(string& grp, int& gid, string& desc); 112 inline bool CheckHelpGrp(string& grp, int& gid) 113 { string desc=""; return CheckHelpGrp(grp, gid, desc); } 114 107 115 int ExecuteCommandLine(string & keyw, vector<string> & args, 108 116 string & toks); … … 135 143 // Pour enregistrer la liste de commandes et leurs executeurs et le help 136 144 struct cmdex {int group; string us; CmdExecutor * cex; } ; 137 typedef map<string, int, less<string> > CmdHGroup; // Liste des groupes de commandes 145 struct hgrpst {int gid; string desc; } ; // Identification+description d'un groupe de help 146 typedef map<string, hgrpst, less<string> > CmdHGroup; // Liste des groupes de commandes 138 147 CmdHGroup cmdhgrp; 139 int cmdgrpid; // Numero de groupe courant140 typedef map<string, cmdex, less<string> > CmdExmap; 141 CmdExmap cmdexmap; 142 CmdExmap helpexmap; // Pour les helps sans commande148 int cmdgrpid; // Numero de groupe courant 149 typedef map<string, cmdex, less<string> > CmdExmap; 150 CmdExmap cmdexmap; // Liste des commandes et leurs executeurs 151 CmdExmap helpexmap; // Pour les helps sans commande 143 152 144 153 // Pour garder la liste des modules
Note:
See TracChangeset
for help on using the changeset viewer.