00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00023 #ifndef __vtkKWArguments_h
00024 #define __vtkKWArguments_h
00025
00026 #include "vtkObject.h"
00027
00028 class vtkKWArgumentsInternal;
00029
00030 class VTK_EXPORT vtkKWArguments : public vtkObject
00031 {
00032 public:
00033 static vtkKWArguments* New();
00034 vtkTypeRevisionMacro(vtkKWArguments,vtkObject);
00035 void PrintSelf(ostream& os, vtkIndent indent);
00036
00037
00038
00039
00041
00042 enum ArgumentTypeEnum {
00043 NO_ARGUMENT,
00044 CONCAT_ARGUMENT,
00045 SPACE_ARGUMENT,
00046 EQUAL_ARGUMENT
00047 };
00049
00050 enum VariableTypeEnum {
00051 NO_VARIABLE_TYPE = 0,
00052 INT_TYPE,
00053 DOUBLE_TYPE,
00054 STRING_TYPE
00055 };
00056
00057
00058 typedef int(*CallbackType)(const char* argument, const char* value,
00059 void* call_data);
00060 typedef int(*ErrorCallbackType)(const char* argument, void* client_data);
00061
00062 struct CallbackStructure
00063 {
00064 const char* Argument;
00065 int ArgumentType;
00066 CallbackType Callback;
00067 void* CallData;
00068 void* Variable;
00069 int VariableType;
00070 const char* Help;
00071 };
00072
00075 void Initialize(int argc, char* argv[]);
00076
00077
00078
00080
00083 void Initialize();
00084 void AddArgument(const char* arg);
00086
00088 int Parse();
00089
00091
00095 void AddCallback(const char* argument, ArgumentTypeEnum type, CallbackType callback,
00096 void* call_data, const char* help);
00097 void AddCallback(const char* argument, ArgumentTypeEnum type, const char* help)
00098 {
00099 this->AddCallback(argument, type, 0, 0, help);
00100 }
00102
00104
00106 void AddHandler(const char* argument, ArgumentTypeEnum type, VariableTypeEnum vtype, void* variable, const char* help);
00107 void AddHandler(const char* argument, ArgumentTypeEnum type, int* variable, const char* help);
00108 void AddHandler(const char* argument, ArgumentTypeEnum type, double* variable, const char* help);
00109 void AddHandler(const char* argument, ArgumentTypeEnum type, char** variable, const char* help);
00110 void AddBooleanHandler(const char* argument, int* variable, const char* help);
00112
00115 void AddCallbacks(CallbackStructure* callbacks);
00116
00118
00119 void SetClientData(void* client_data);
00120 void SetUnknownArgumentCallback(ErrorCallbackType callback);
00122
00125 void GetRemainingArguments(int* argc, char*** argv);
00126
00128
00130 vtkGetStringMacro(Help);
00131 const char* GetHelp(const char* arg);
00133
00135
00136 vtkSetMacro(LineLength, unsigned int);
00137 vtkGetMacro(LineLength, unsigned int);
00139
00141
00143 int IsSpecified(const char* arg);
00144 const char* GetValue(const char* arg);
00146
00147 protected:
00148 vtkKWArguments();
00149 ~vtkKWArguments();
00150
00151 vtkSetStringMacro(Help);
00152 void GenerateHelp();
00153
00154
00155 typedef vtkKWArgumentsInternal Internal;
00156
00157 Internal* Internals;
00158 char* Help;
00159
00160 unsigned int LineLength;
00161
00162 private:
00163 vtkKWArguments(const vtkKWArguments&);
00164 void operator=(const vtkKWArguments&);
00165 };
00166
00167
00168 #endif
00169
00170
00171
00172
00173