1 /*=========================================================================
4 Module: $RCSfile: gdcmArgMgr.h,v $
6 Date: $Date: 2005/08/28 16:56:05 $
7 Version: $Revision: 1.10 $
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.
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.
17 =========================================================================*/
22 #include "gdcmCommon.h"
23 #include <stdio.h> // for FILE
24 #include <stdlib.h> // For atof
29 #define ID_RFILE_TEXT "rt"
30 #define ARGMAXCOUNT 100 // Maximum number of arguments
31 #define ARG_LONG_MAX 1000
34 #define ARG_DEFAULT_PARAMOUT "fileout.par"
35 #define ARG_DEFAULT_LOGFILE "gdcm.log"
37 #define ARG_LABEL_LOGFILE "LOG"
38 #define ARG_LABEL_PARAMOUT "paramout"
40 #define START_USAGE(usage) const char *usage[] = {
41 #define FINISH_USAGE 0};
43 //-----------------------------------------------------------------------------
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')
51 class GDCM_EXPORT ArgMgr
54 ArgMgr(int argc, char **argv);
57 int ArgMgrDefined (const char *param); // Checks if Param is defined
58 char *ArgMgrValue (const char *param); // 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 **usage); // Display program usage
62 int ArgMgrPrintUnusedLabels (void); // Prints unused labels
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 char *ArgMgrGetString(const char *param, char*);// Gets a string (with default value)
67 int ArgMgrGetLabel (const char *param, char *, int);
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);
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
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
84 int FiltreLong (char *);
85 const char *LoadedParam(const char *, FILE *);
86 int ArgLoadFromFile (char *);
87 void ArgStdArgs (void);
89 // These ones are 'general purpose methods'
91 char *Majuscule (const char *);
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);
98 // --------------- Attributes ------------------------------
102 const char *ArgParamOut; // Output File Name for param
104 char *ArgUsed; // Used Arguments
105 char *ArgLab[ARGMAXCOUNT]; // Arguments Labels
106 char *ArgStr[ARGMAXCOUNT]; // Arguments 'strings'
107 int ArgCount; // Number of arguments passed
110 } // end namespace gdcm