00001 /* 00002 * 00003 * Copyright (C) 1997-2004, OFFIS 00004 * 00005 * This software and supporting documentation were developed by 00006 * 00007 * Kuratorium OFFIS e.V. 00008 * Healthcare Information and Communication Systems 00009 * Escherweg 2 00010 * D-26121 Oldenburg, Germany 00011 * 00012 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 00013 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 00014 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 00015 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 00016 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 00017 * 00018 * Module: ofstd 00019 * 00020 * Author: Joerg Riesmeier 00021 * 00022 * Purpose: Handle console applications (Header) 00023 * 00024 * Last Update: $Author: joergr $ 00025 * Update Date: $Date: 2004/01/16 10:30:12 $ 00026 * CVS/RCS Revision: $Revision: 1.19 $ 00027 * Status: $State: Exp $ 00028 * 00029 * CVS/RCS Log at end of file 00030 * 00031 */ 00032 00033 00034 #ifndef OFCONAPP_H 00035 #define OFCONAPP_H 00036 00037 #include "osconfig.h" 00038 00039 #include "oftypes.h" 00040 #include "ofcmdln.h" 00041 #include "ofstring.h" /* for class OFString */ 00042 00043 00044 /*---------------------* 00045 * class declaration * 00046 *---------------------*/ 00047 00053 class OFConsoleApplication 00054 { 00055 00056 public: 00057 00064 OFConsoleApplication(const char *app, 00065 const char *desc = NULL, 00066 const char *rcsid = NULL); 00067 00070 ~OFConsoleApplication(); 00071 00085 OFBool parseCommandLine(OFCommandLine &cmd, 00086 int argCount, 00087 char *argValue[], 00088 const int flags = 0, 00089 const int startPos = 1); 00090 00096 void printHeader(const OFBool hostInfo = OFFalse, 00097 const OFBool stdError = OFFalse); 00098 00103 void printUsage(const OFCommandLine *cmd = NULL); 00104 00110 void printError(const char *str, 00111 const int code = 1); 00112 00118 void printWarning(const char *str, 00119 const char *prefix = "warning"); 00120 00125 void printMessage(const char *str); 00126 00131 OFBool quietMode() const; 00132 00137 void setQuietMode(const OFBool mode = OFTrue); 00138 00144 void checkValue(const OFCommandLine::E_ValueStatus status, 00145 OFCommandLine *cmd = NULL); 00146 00152 void checkParam(const OFCommandLine::E_ParamValueStatus status, 00153 OFCommandLine *cmd = NULL); 00154 00162 void checkDependence(const char *subOpt, 00163 const char *baseOpt, 00164 OFBool condition); 00165 00173 void checkConflict(const char *firstOpt, 00174 const char *secondOpt, 00175 OFBool condition); 00176 00177 00178 private: 00179 00181 OFString Name; 00183 OFString Description; 00185 OFString Identification; 00186 00188 OFBool QuietMode; 00189 00191 OFCommandLine *CmdLine; 00192 00193 00194 // --- declarations to avoid compiler warnings 00195 00196 OFConsoleApplication(const OFConsoleApplication &); 00197 OFConsoleApplication &operator=(const OFConsoleApplication &); 00198 }; 00199 00200 00201 #endif 00202 00203 00204 /* 00205 * 00206 * CVS/RCS Log: 00207 * $Log: ofconapp.h,v $ 00208 * Revision 1.19 2004/01/16 10:30:12 joergr 00209 * Removed acknowledgements with e-mail addresses from CVS log. 00210 * 00211 * Revision 1.18 2003/12/05 10:37:41 joergr 00212 * Removed leading underscore characters from preprocessor symbols (reserved 00213 * symbols). Updated copyright date where appropriate. 00214 * 00215 * Revision 1.17 2003/07/04 13:29:51 meichel 00216 * Replaced forward declarations for OFString with explicit includes, 00217 * needed when compiling with HAVE_STD_STRING 00218 * 00219 * Revision 1.16 2003/06/12 13:17:51 joergr 00220 * Enhanced method printWarning(). Added method quietMode(). 00221 * 00222 * Revision 1.15 2002/11/26 12:55:02 joergr 00223 * Changed syntax usage output for command line applications from stderr to 00224 * stdout. 00225 * 00226 * Revision 1.14 2002/09/23 14:56:55 joergr 00227 * Prepared code for future support of 'config.guess' host identifiers. 00228 * 00229 * Revision 1.13 2002/04/16 13:36:02 joergr 00230 * Added configurable support for C++ ANSI standard includes (e.g. streams). 00231 * 00232 * Revision 1.12 2001/06/01 15:51:33 meichel 00233 * Updated copyright header 00234 * 00235 * Revision 1.11 2000/10/10 12:01:20 meichel 00236 * Created/updated doc++ comments 00237 * 00238 * Revision 1.10 2000/04/14 15:17:12 meichel 00239 * Adapted all ofstd library classes to consistently use ofConsole for output. 00240 * 00241 * Revision 1.9 2000/03/08 16:36:01 meichel 00242 * Updated copyright header. 00243 * 00244 * Revision 1.8 2000/03/07 15:38:50 joergr 00245 * Changed behaviour of class OFConsoleApplication to support automatic 00246 * evaluation of "--help" option for command line application with no 00247 * mandatory parameter. 00248 * 00249 * Revision 1.7 1999/09/13 16:37:15 joergr 00250 * Added methods for output of warning and other messages. 00251 * Added method to switch on/off all output messages (quiet mode). 00252 * 00253 * Revision 1.6 1999/08/17 10:23:10 joergr 00254 * Corrected Doc++ comment. 00255 * 00256 * Revision 1.5 1999/04/27 16:24:53 joergr 00257 * Introduced list of valid parameters used for syntax output and error 00258 * checking. 00259 * Added method to check conflicts between two options (incl. error output). 00260 * 00261 * Revision 1.4 1999/04/26 16:34:34 joergr 00262 * Added support to check dependences between different options and report 00263 * error messages if necessary. 00264 * 00265 * Revision 1.3 1999/04/21 12:41:03 meichel 00266 * Added method OFConsoleApplication::checkParam() 00267 * 00268 * Revision 1.2 1999/03/22 09:00:49 joergr 00269 * Added/Changed comments. 00270 * 00271 * Revision 1.1 1999/02/08 12:00:41 joergr 00272 * Added class to handle console applications (with or w/o command line 00273 * arguments). 00274 * 00275 * 00276 */