Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

#define phARG_FUNC   6
 

Call a function of type ph_argtable_funcptr when parsing. This maps a switch to a function. The function is invoked when the switch is present. There should be no parameters passed to the function. It is generally used to call a usage function. For example, supposing the function “void usage()” exists and one would like to call it when the “--help” switch is supplied. The following code would take care of providing for this functionality:

Parameter pointer type: ph_argtable_funcptr

 void usage()
 {
     printf(“Help!\n”);
     exit(1);
 }
 int main (int argc, char *argv[] )
 {
     phArgTable table;
     
     rc = table.add(“--help”, (void *)&usage,phARG_FUNC);
     CHECK_RC(rc,NULL,”table.add failed to add –help switch”);

     rc = table.parse(argc,argv);
     //We should never get this far if “--help” is passed on the command line
     //     because usage will be called and it exists the program
     CHECK_RC(rc,NULL,”table.parsed failed”);

     return phSUCCESS;
 error:
     return phFAIL;
 }

Definition at line 133 of file phArgTable.h.





Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:45:27 2007 for phission by  doxygen 1.4.4