gdcmArgMgr.h

Go to the documentation of this file.
00001 /*=========================================================================
00002   
00003   Program:   gdcm
00004   Module:    $RCSfile: gdcmArgMgr.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/05/23 14:18:07 $
00007   Version:   $Revision: 1.13 $
00008   
00009   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
00010   l'Image). All rights reserved. See Doc/License.txt or
00011   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
00012   
00013      This software is distributed WITHOUT ANY WARRANTY; without even
00014      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00015      PURPOSE.  See the above copyright notices for more information.
00016   
00017 =========================================================================*/
00018 
00019 #ifndef  ___ARG_MGR__
00020 #define  ___ARG_MGR__
00021 
00022 #include "gdcmCommon.h"
00023 #include <stdio.h>  // for FILE
00024 #include <stdlib.h> // For atof
00025 
00026 namespace GDCM_NAME_SPACE
00027 {
00028 
00029 #define ID_RFILE_TEXT        "rt"
00030 #define ARGMAXCOUNT          100   // Maximum number of arguments
00031 #define ARG_LONG_MAX         1000
00032 
00033 // default file name
00034 #define ARG_DEFAULT_PARAMOUT "fileout.par"
00035 #define ARG_DEFAULT_LOGFILE  "gdcm.log"
00036 
00037 #define ARG_LABEL_LOGFILE    "LOG"
00038 #define ARG_LABEL_PARAMOUT   "paramout"
00039 
00040 #define START_USAGE(usage)   const char *usage[] = {
00041 #define FINISH_USAGE         0};
00042 
00043 //-----------------------------------------------------------------------------
00051 class GDCM_EXPORT ArgMgr
00052 {
00053 public:
00054    ArgMgr(int argc, char **argv);
00055    ~ArgMgr();
00056 
00057    int    ArgMgrDefined           (const char *param);  // Checks if Param is defined
00058    char  *ArgMgrValue             (const char *param);  // Returns Param value 
00059    const char  *ArgMgrUnused      (void);               // Returns a never used arg.
00060    int    ArgMgrSave              (const char *);       // Save of parameters out
00061    int    ArgMgrUsage             (const char **usage); // Display program usage 
00062    int    ArgMgrPrintUnusedLabels (void);               // Prints unused labels
00063 
00064    int    ArgMgrGetInt   (const char *param, int);  // Gets an int   (with default value)
00065    float  ArgMgrGetFloat (const char *param, float);// Gets a float  (with default value)
00066    const char  *ArgMgrGetString(const char *param, const char* ext = 0);// Gets a string (with default value)
00067    int    ArgMgrGetLabel (const char *param, const char *, int);
00068   
00069    int    ArgMgrWantInt   (const char *param, const char **usage);  // Demands an int 
00070    float  ArgMgrWantFloat (const char *param, const char **usage);  // Demands a float
00071    char  *ArgMgrWantString(const char *param, const char **usage);  // Demands a string
00072    int    ArgMgrWantLabel (const char *param, char *, const char **usage);
00073 
00074    int   *ArgMgrGetListOfInt   (const char *param, int *);   // Gets a list of int 
00075    float *ArgMgrGetListOfFloat (const char *param, int *);   // Gets a list of float
00076    char **ArgMgrGetListOfString(const char *param, int *);   // Gets a list of string
00077 
00078    int        *ArgMgrGetIntEnum     (const char *param, int *); // Gets a list of int pairs
00079    uint16_t   *ArgMgrGetXInt16Enum  (const char *param, int *); // Gets a list of int16 pairs
00080    float      *ArgMgrGetFloatEnum   (const char *param, int *); // Gets a list of float pairs
00081 
00082 private :
00083 
00084    int    FiltreLong       (const char *);
00085    const char  *LoadedParam(const char *, FILE *);
00086    int    ArgLoadFromFile  (const char *);
00087    void   ArgStdArgs       (void);
00088 
00089    // These ones are 'general purpose methods'
00090    char  *maj       (char *);
00091    char  *Majuscule (const char *);
00092 
00093    int       IdStrCountChar  (char *chaine,int caract);
00094    int      *IdStrIntEnum    (char *value, int *number);
00095    uint16_t *IdStrXInt16Enum (char *value, int *number);
00096    float    *IdStrFloatEnum  (char *value, int *number);
00097 
00098 // --------------- Attributes ------------------------------
00099 
00100 private :
00101 
00102    const char *ArgParamOut;    // Output File Name for param
00103 
00104    char *ArgUsed;              // Used Arguments 
00105    char *ArgLab[ARGMAXCOUNT];  // Arguments Labels
00106    char *ArgStr[ARGMAXCOUNT];  // Arguments 'strings'
00107    int   ArgCount;             // Number of arguments passed 
00108    char *Appel;                
00109 };
00110 } // end namespace gdcm
00111 
00112 #endif

Generated on Fri Aug 24 12:53:08 2007 for gdcm by  doxygen 1.4.6