Changeset 2598 in Sophya for trunk/SophyaLib/SysTools/commander.cc
- Timestamp:
- Aug 11, 2004, 3:10:25 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SysTools/commander.cc
r2532 r2598 25 25 // ------------------------------------------------------------ 26 26 /*! 27 \internal 27 28 \class SOPHYA::CommanderBloc 28 29 \ingroup SysTools 29 Class for internal use by SOPHYA::Commander to handle loops30 Class for internal use by class Commander to handle loops 30 31 */ 31 32 class CommanderBloc { … … 253 254 254 255 /*! 256 \internal 255 257 \class SOPHYA::CommanderScript 256 258 \ingroup SysTools 257 Class for internal use by SOPHYA::Commander to handle functions259 Class for internal use by class Commander to handle functions 258 260 or scripts 259 261 */ … … 334 336 335 337 /*! 336 \class SOPHYA::Commander338 \class Commander 337 339 \ingroup SysTools 338 Simple command interpreter with c-shell like syntax and dynamic 339 load capabilities. Can be used to add scripting capabilities 340 to applications 340 \brief Simple command interpreter 341 342 This Simple command interpreter with c-shell like syntax 343 can be used to add scripting capabilities 344 to applications. 345 346 Although the insterpreter has many limitations compared to 347 c-shell, or Tcl , it provides some interesting possibilities: 348 349 - Extended arithmetic operations (c-like and RPN) 350 - Simple and vector variables 351 - Script definition 352 - Dynamic Load 353 354 \sa CmdExecutor CExpressionEvaluator RPNExpressionEvaluator 355 356 Usage example: 357 \code 358 #include "commander.h" 359 ... 360 Commander cmd; 361 char* ss[3] = {"foreach f ( AA bbb CCCC ddddd )", "echo $f" , "end"}; 362 for(int k=0; k<3; k++) { 363 string line = ss[k]; 364 cmd.Interpret(line); 365 } 366 \endcode 341 367 */ 342 368 … … 345 371 static Commander* cur_commander = NULL; 346 372 /* --Methode-- */ 373 //! Default constructor. Initializes variable list and copies \c history.pic to \c hisold.pic 347 374 Commander::Commander() 348 375 { … … 488 515 489 516 /* --Methode-- */ 517 //! Returns the string \c Commander as the interpreter's name. 490 518 string Commander::Name() 491 519 { … … 494 522 495 523 /* --Methode-- */ 524 //! Add the \b grp help group with description \b desc. 496 525 void Commander::AddHelpGroup(string& grp, string& desc) 497 526 { … … 501 530 502 531 /* --Methode-- */ 532 /*! 533 \brief Register a command executor associated with a given keyword. 534 \param keyw : keyword identifying the command 535 \param usage : the command help and usage information 536 \param ce : CmdExecutor pointer for this a command. The same object can be registered 537 multiple time for different commands. 538 \param grp : The help group corresponding to this command. 539 */ 503 540 void Commander::RegisterCommand(string& keyw, string& usage, CmdExecutor * ce, string& grp) 504 541 { … … 517 554 518 555 /* --Methode-- */ 556 /*! 557 \brief Register a help text. 558 \param keyw : help keyword 559 \param usage : help text 560 \param grp : help group 561 */ 519 562 void Commander::RegisterHelp(string& keyw, string& usage, string& grp) 520 563 { … … 548 591 549 592 /* --Methode-- */ 593 /*! 594 \brief Dynamic loader for modules 595 596 A module is a shared library extending the application functionalities. 597 Typically, a module adds new commands to the interpreter. Once loaded, 598 the module is activated (initialized) by calling a function with the 599 name \b modulename_init . This function should be declared extern C 600 to avoid C++ name mangling. A cleanup function \b modulename_end 601 is called by the Commander destructor. 602 603 \param fnameso : Shared library name containing the module functions 604 and classes. 605 \param name : Module name. This string is used to form module 606 initializer and cleanup function name \c name_init \c name_end 607 */ 550 608 void Commander::LoadModule(string& fnameso, string& name) 551 609 { … … 569 627 570 628 /* --Methode-- */ 629 //! Declare a new interpreter 571 630 void Commander::AddInterpreter(CmdInterpreter * cl) 572 631 { … … 575 634 576 635 /* --Methode-- */ 636 //! Select an interpreter by its name. The corresponding Interpret method is then called 577 637 void Commander::SelInterpreter(string& name) 578 638 { … … 594 654 595 655 /* --Methode-- */ 656 /*! 657 \brief Method which has to be invoked to interpret a giev command line or string. 658 */ 596 659 int Commander::Interpret(string& s) 597 660 { … … 1894 1957 1895 1958 /* --Methode-- */ 1959 //! Produces a LaTeX file containing the registered command helps 1896 1960 void Commander::HelptoLaTeX(string const & fname) 1897 1961 {
Note:
See TracChangeset
for help on using the changeset viewer.