]> Creatis software - gdcm.git/blob - src/gdcmArgMgr.h
COMP: Trying to get this /thing/ to compile correctly... I thought gdcm was written...
[gdcm.git] / src / gdcmArgMgr.h
1 /*=========================================================================
2   
3   Program:   gdcm
4   Module:    $RCSfile: gdcmArgMgr.h,v $
5   Language:  C++
6   Date:      $Date: 2005/06/08 15:21:58 $
7   Version:   $Revision: 1.6 $
8   
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12   
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16   
17 =========================================================================*/
18
19 #ifndef  ___ARG_MGR__
20 #define  ___ARG_MGR__
21
22 #include "gdcmCommon.h"
23 #include <stdio.h> // for FILE
24 #include <stdlib.h> // For atof
25
26 namespace gdcm
27 {
28
29 #define ID_RFILE_TEXT        "rt"
30 #define ARGMAXCOUNT          100   // Maximum number of arguments
31 #define ARG_LONG_MAX         1000
32
33 // default file name
34 #define ARG_DEFAULT_PARAMOUT "fileout.par"
35 #define ARG_DEFAULT_LOGFILE  "gdcm.log"
36
37 #define ARG_LABEL_LOGFILE    "LOG"
38 #define ARG_LABEL_PARAMOUT   "paramout"
39
40 #define START_USAGE(usage)   const char *usage[] = {
41 #define FINISH_USAGE         0};
42
43 //-----------------------------------------------------------------------------
44 /**
45  * \brief   class designed for command line arguments management
46  *          (to make programmer's live easier) 
47  *          NOT Dicom dependant (could be used for any kind 
48  *                              of 'command line program')        
49  */
50  
51 class GDCM_EXPORT ArgMgr
52 {
53 public:
54    ArgMgr(int argc, char **argv);
55    ~ArgMgr();
56
57    int    ArgMgrDefined           (char *);      /* Checks if Param is defined*/
58    char  *ArgMgrValue             (char *);      /* Returns Param value       */
59    char  *ArgMgrUnused            (void);        /* Returns a never used arg. */
60    int    ArgMgrSave              (char *);      /* Save of parameters out    */
61    int    ArgMgrUsage             (const char **);/* Display program usage     */
62    int    ArgMgrPrintUnusedLabels (void);        /* Prints unused labels      */
63
64    int    ArgMgrGetInt   (char*, int);  /* Gets an int   (with default value)  */
65    float  ArgMgrGetFloat (char*, float);/* Gets a float  (with default value)  */
66    char  *ArgMgrGetString(char*, char*);/* Gets a string (with default value)  */
67    int    ArgMgrGetLabel (char *, char *, int);
68   
69    int   ArgMgrWantInt   (char*, const char**);  /* Demands an int                   */
70    float ArgMgrWantFloat (char*, const char**);  /* Demands a float                  */
71    char *ArgMgrWantString(char*, const char**);  /* Demands a string                 */
72    int   ArgMgrWantLabel (char*, char *, const char **);
73
74    int   *ArgMgrGetListOfInt   (char *, int *);   /* Gets a list of int        */
75    float *ArgMgrGetListOfFloat (char *, int *);   /* Gets a list of float      */
76    char **ArgMgrGetListOfString(char *, int *);   /* Gets a list of string     */
77
78    int   * ArgMgrGetIntEnum     (char *, int *); /* Gets a list of int intervals  */
79    float * ArgMgrGetFloatEnum   (char *, int *); /* Gets a list of float intervals*/
80
81 private :
82
83    int    FiltreLong      (char *);
84    char  *LoadedParam     (char *, FILE *);
85    int    ArgLoadFromFile (char *);
86    void   ArgStdArgs      (void);
87
88    // These ones are 'general purpose methods'
89    char  *maj             (char *);
90    char  *Majuscule       (char *);
91    int IdStrCountChar     (char *chaine, int caract);
92    int *IdStrIntEnum      (char* value, int *number);
93    float *IdStrFloatEnum  (char* value, int *number);
94
95 // --------------- Attributes ------------------------------
96
97 private :
98
99    const char *ArgParamOut;          /* Output File Name for param */
100
101    char *ArgUsed;              /* Used Arguments             */
102    char *ArgLab[ARGMAXCOUNT];  /* Arguments Labels           */
103    char *ArgStr[ARGMAXCOUNT];  /* Arguments 'strings'        */
104    int   ArgCount;             /* Number of arguments passed */
105    char *Appel;                
106 };
107 } // end namespace gdcm
108
109 #endif