]> Creatis software - gdcm.git/blob - src/gdcmArgMgr.h
Fix mistypings
[gdcm.git] / src / gdcmArgMgr.h
1 /*=========================================================================
2   
3   Program:   gdcm
4   Module:    $RCSfile: gdcmArgMgr.h,v $
5   Language:  C++
6   Date:      $Date: 2008/04/10 12:03:46 $
7   Version:   $Revision: 1.15 $
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_NAME_SPACE
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           (const char *param);  // Checks if Param is defined
58    char  *ArgMgrValue             (const char *param);  // Returns Param value 
59    const char  *ArgMgrUnused      (void);               // Returns a never used arg.
60    int    ArgMgrSave              (const char *);       // Save of parameters out
61    int    ArgMgrUsage             (const char **usage); // Display program usage 
62    int    ArgMgrPrintUnusedLabels (void);               // Prints unused labels
63
64    int    ArgMgrGetInt   (const char *param, int);  // Gets an int   (with default value)
65    float  ArgMgrGetFloat (const char *param, float);// Gets a float  (with default value)
66    const char  *ArgMgrGetString(const char *param, const char* ext = 0);// Gets a string (with default value)
67    int    ArgMgrGetLabel (const char *param, const char *, int);
68   
69    int    ArgMgrWantInt   (const char *param, const char **usage);  // Demands an int 
70    float  ArgMgrWantFloat (const char *param, const char **usage);  // Demands a float
71    char  *ArgMgrWantString(const char *param, const char **usage);  // Demands a string
72    int    ArgMgrWantLabel (const char *param, char *, const char **usage);
73
74    int   *ArgMgrGetListOfInt   (const char *param, int *);   // Gets a list of int 
75    float *ArgMgrGetListOfFloat (const char *param, int *);   // Gets a list of float
76    char **ArgMgrGetListOfString(const char *param, int *);   // Gets a list of string
77
78    int        *ArgMgrGetIntEnum     (const char *param, int *); // Gets a list of int pairs
79    uint16_t   *ArgMgrGetXInt16Enum  (const char *param, int *); // Gets a list of int16 pairs
80    float      *ArgMgrGetFloatEnum   (const char *param, int *); // Gets a list of float pairs
81
82 private :
83
84    int    FiltreLong       (const char *);
85    const char  *LoadedParam(const char *, FILE *);
86    int    ArgLoadFromFile  (const char *);
87    void   ArgStdArgs       (void);
88
89    // These ones are 'general purpose methods'
90    char  *maj       (char *);
91    char  *Majuscule (const char *);
92
93    int       IdStrCountChar  (char *chaine,int caract);
94    int      *IdStrIntEnum    (char *value, int *number);
95    uint16_t *IdStrXInt16Enum (char *value, int *number);
96    float    *IdStrFloatEnum  (char *value, int *number);
97
98 // --------------- Attributes ------------------------------
99
100 private :
101
102    const char *ArgParamOut;    // Output File Name for param
103
104    char *ArgUsed;              // Used Arguments 
105    char **ArgLab; //[ARGMAXCOUNT];  // Arguments Labels
106    char **ArgStr; //[ARGMAXCOUNT];  // Arguments 'strings'
107    int   ArgCount;             // Number of arguments passed 
108    char *Appel;                
109
110    ArgMgr(const ArgMgr&); // Not implemented
111    void operator=(const ArgMgr&); // Not implemented
112 };
113 } // end namespace gdcm
114
115 #endif