Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ArArgumentParser.h

00001 /*
00002 ActivMedia Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004,2005 ActivMedia Robotics, LLC
00004 
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 ActivMedia Robotics for information about a commercial version of ARIA at 
00022 robots@activmedia.com or 
00023 ActivMedia Robotics, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 
00025 */
00026 
00027 #ifndef ARARGUMENTPARSER_H
00028 #define ARARGUMENTPARSER_H
00029 
00030 #include "ariaTypedefs.h"
00031 #include "ArArgumentBuilder.h"
00032 
00034 
00043 class ArArgumentParser
00044 {
00045 public:
00047   ArArgumentParser(int *argc, char **argv);
00049   ArArgumentParser(ArArgumentBuilder *builder);
00051   ~ArArgumentParser();
00053   bool checkArgument(char *argument);
00055   char *checkParameterArgument(char *argument, 
00056                                         bool returnFirst = false);
00058   bool checkParameterArgumentString(char *argument, 
00059                                              const char **dest, 
00060                                              bool *wasReallySet = NULL,
00061                                              bool returnFirst = false);
00063   bool checkParameterArgumentInteger(char *argument, int *dest,
00064                                               bool *wasReallySet = NULL, 
00065                                               bool returnFirst = false);
00067   bool checkParameterArgumentBool(char *argument, bool *dest,
00068                                            bool *wasReallySet = NULL,
00069                                            bool returnFirst = false);
00071   void addDefaultArgument(const char *argument);
00073   void loadDefaultArguments(void);
00075   bool checkHelpAndWarnUnparsed(unsigned int numArgsOkay = 0);
00077   size_t getArgc(void) const;
00079   char** getArgv(void) const;
00081   const char* getArg(size_t whichArg) const;
00083   void log(void) const;
00085   void removeArg(size_t which);
00087   static void addDefaultArgumentFile(const char *file);
00089   static void addDefaultArgumentEnv(const char *env);
00091   static void logDefaultArgumentLocations(void);
00092 #ifndef SWIG
00093 
00094   bool checkArgumentVar(char *argument, ...);
00096   char *checkParameterArgumentVar(char *argument, ...);
00098   bool checkParameterArgumentStringVar(bool *wasReallySet, 
00099                                                 const char **dest, 
00100                                                 char *argument, ...);
00102   bool checkParameterArgumentBoolVar(bool *wasReallySet, bool *dest,
00103                                               char *argument, ...);
00105   bool checkParameterArgumentIntegerVar(bool *wasReallySet, int *dest,
00106                                                  char *argument, ...);
00107 #endif
00108 protected:
00109   static std::list<std::string> ourDefaultArgumentLocs;
00110   static std::list<bool> ourDefaultArgumentLocIsFile;
00111   bool myOwnBuilder;
00112   ArArgumentBuilder *myBuilder;
00113   bool myUsingBuilder;
00114   char **myArgv;
00115   int *myArgc;
00116   char myEmptyArg[1];
00117 };
00118 
00119 
00120 #endif // ARARGUMENTPARSER_H

Generated on Wed Oct 19 12:56:34 2005 for Aria by  doxygen 1.4.0