ofstd/include/dcmtk/ofstd/ofconapp.h

00001 /*
00002  *
00003  *  Copyright (C) 1999-2010, OFFIS e.V.
00004  *  All rights reserved.  See COPYRIGHT file for details.
00005  *
00006  *  This software and supporting documentation were developed by
00007  *
00008  *    OFFIS e.V.
00009  *    R&D Division Health
00010  *    Escherweg 2
00011  *    D-26121 Oldenburg, Germany
00012  *
00013  *
00014  *  Module:  ofstd
00015  *
00016  *  Author:  Joerg Riesmeier
00017  *
00018  *  Purpose: Handle console applications (Header)
00019  *
00020  *  Last Update:      $Author: joergr $
00021  *  Update Date:      $Date: 2010-10-14 13:15:50 $
00022  *  CVS/RCS Revision: $Revision: 1.25 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 
00030 #ifndef OFCONAPP_H
00031 #define OFCONAPP_H
00032 
00033 #include "dcmtk/config/osconfig.h"
00034 
00035 #include "dcmtk/ofstd/oftypes.h"
00036 #include "dcmtk/ofstd/ofcmdln.h"
00037 #include "dcmtk/ofstd/ofstring.h" /* for class OFString */
00038 
00039 
00040 /*---------------------*
00041  *  class declaration  *
00042  *---------------------*/
00043 
00049 class OFConsoleApplication
00050 {
00051 
00052  public:
00053 
00060     OFConsoleApplication(const char *app,
00061                          const char *desc = NULL,
00062                          const char *rcsid = NULL);
00063 
00066     ~OFConsoleApplication();
00067 
00081     OFBool parseCommandLine(OFCommandLine &cmd,
00082                             int argCount,
00083                             char *argValue[],
00084                             const int flags = 0,
00085                             const int startPos = 1);
00086 
00092     void printHeader(const OFBool hostInfo = OFFalse,
00093                      const OFBool stdError = OFFalse);
00094 
00099     void printUsage(const OFCommandLine *cmd = NULL);
00100 
00105     void printArguments(OFCommandLine *cmd = NULL);
00106 
00109     void printIdentifier();
00110 
00116     void printError(const char *str,
00117                     const int code = 1);
00118 
00124     void printWarning(const char *str,
00125                       const char *prefix = "warning");
00126 
00131     void printMessage(const char *str);
00132 
00137     OFBool quietMode() const;
00138 
00143     void setQuietMode(const OFBool mode = OFTrue);
00144 
00150     void checkValue(const OFCommandLine::E_ValueStatus status,
00151                     OFCommandLine *cmd = NULL);
00152 
00158     void checkParam(const OFCommandLine::E_ParamValueStatus status,
00159                     OFCommandLine *cmd = NULL);
00160 
00168     void checkDependence(const char *subOpt,
00169                          const char *baseOpt,
00170                          OFBool condition);
00171 
00179     void checkConflict(const char *firstOpt,
00180                        const char *secondOpt,
00181                        OFBool condition);
00182 
00183 
00184  private:
00185 
00187     OFString Name;
00189     OFString Description;
00191     OFString Identification;
00192 
00194     OFBool QuietMode;
00195 
00197     OFCommandLine *CmdLine;
00198 
00199 
00200  // --- declarations to avoid compiler warnings
00201 
00202     OFConsoleApplication(const OFConsoleApplication &);
00203     OFConsoleApplication &operator=(const OFConsoleApplication &);
00204 };
00205 
00206 
00207 #endif
00208 
00209 
00210 /*
00211  *
00212  * CVS/RCS Log:
00213  * $Log: ofconapp.h,v $
00214  * Revision 1.25  2010-10-14 13:15:50  joergr
00215  * Updated copyright header. Added reference to COPYRIGHT file.
00216  *
00217  * Revision 1.24  2008-09-25 11:14:54  joergr
00218  * Added method for printing the resource identifier of an application.
00219  *
00220  * Revision 1.23  2008-09-25 10:10:16  joergr
00221  * Print expanded command line arguments to stderr and not to stdout.
00222  *
00223  * Revision 1.22  2008-09-24 13:24:00  joergr
00224  * Added support for printing the expanded command line arguments to standard
00225  * output stream.
00226  *
00227  * Revision 1.21  2006/07/27 13:17:23  joergr
00228  * Prepended prefix "PF_" to parseLine() flags.
00229  *
00230  * Revision 1.20  2005/12/08 16:05:49  meichel
00231  * Changed include path schema for all DCMTK header files
00232  *
00233  * Revision 1.19  2004/01/16 10:30:12  joergr
00234  * Removed acknowledgements with e-mail addresses from CVS log.
00235  *
00236  * Revision 1.18  2003/12/05 10:37:41  joergr
00237  * Removed leading underscore characters from preprocessor symbols (reserved
00238  * symbols). Updated copyright date where appropriate.
00239  *
00240  * Revision 1.17  2003/07/04 13:29:51  meichel
00241  * Replaced forward declarations for OFString with explicit includes,
00242  *   needed when compiling with HAVE_STD_STRING
00243  *
00244  * Revision 1.16  2003/06/12 13:17:51  joergr
00245  * Enhanced method printWarning(). Added method quietMode().
00246  *
00247  * Revision 1.15  2002/11/26 12:55:02  joergr
00248  * Changed syntax usage output for command line applications from stderr to
00249  * stdout.
00250  *
00251  * Revision 1.14  2002/09/23 14:56:55  joergr
00252  * Prepared code for future support of 'config.guess' host identifiers.
00253  *
00254  * Revision 1.13  2002/04/16 13:36:02  joergr
00255  * Added configurable support for C++ ANSI standard includes (e.g. streams).
00256  *
00257  * Revision 1.12  2001/06/01 15:51:33  meichel
00258  * Updated copyright header
00259  *
00260  * Revision 1.11  2000/10/10 12:01:20  meichel
00261  * Created/updated doc++ comments
00262  *
00263  * Revision 1.10  2000/04/14 15:17:12  meichel
00264  * Adapted all ofstd library classes to consistently use ofConsole for output.
00265  *
00266  * Revision 1.9  2000/03/08 16:36:01  meichel
00267  * Updated copyright header.
00268  *
00269  * Revision 1.8  2000/03/07 15:38:50  joergr
00270  * Changed behaviour of class OFConsoleApplication to support automatic
00271  * evaluation of "--help" option for command line application with no
00272  * mandatory parameter.
00273  *
00274  * Revision 1.7  1999/09/13 16:37:15  joergr
00275  * Added methods for output of warning and other messages.
00276  * Added method to switch on/off all output messages (quiet mode).
00277  *
00278  * Revision 1.6  1999/08/17 10:23:10  joergr
00279  * Corrected Doc++ comment.
00280  *
00281  * Revision 1.5  1999/04/27 16:24:53  joergr
00282  * Introduced list of valid parameters used for syntax output and error
00283  * checking.
00284  * Added method to check conflicts between two options (incl. error output).
00285  *
00286  * Revision 1.4  1999/04/26 16:34:34  joergr
00287  * Added support to check dependences between different options and report
00288  * error messages if necessary.
00289  *
00290  * Revision 1.3  1999/04/21 12:41:03  meichel
00291  * Added method OFConsoleApplication::checkParam()
00292  *
00293  * Revision 1.2  1999/03/22 09:00:49  joergr
00294  * Added/Changed comments.
00295  *
00296  * Revision 1.1  1999/02/08 12:00:41  joergr
00297  * Added class to handle console applications (with or w/o command line
00298  * arguments).
00299  *
00300  *
00301  */


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1