ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
CmdLineParser.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7 
8 Redistributions of source code must retain the above copyright notice, this list of
9 conditions and the following disclaimer. Redistributions in binary form must reproduce
10 the above copyright notice, this list of conditions and the following disclaimer
11 in the documentation and/or other materials provided with the distribution.
12 
13 Neither the name of the Johns Hopkins University nor the names of its contributors
14 may be used to endorse or promote products derived from this software without specific
15 prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
19 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
20 SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 DAMAGE.
27 */
28 
29 #ifndef CMD_LINE_PARSER_INCLUDED
30 #define CMD_LINE_PARSER_INCLUDED
31 #include <stdarg.h>
32 #include <string.h>
33 
34 
35 #ifdef _WIN32
36 int strcasecmp(char* c1,char* c2);
37 #endif
38 
40 public:
41  bool set;
42  char* name;
43  cmdLineReadable(const char* name);
44  virtual ~cmdLineReadable(void);
45  virtual int read(char** argv,int argc);
46  virtual void writeValue(char* str);
47 };
48 
49 class cmdLineInt : public cmdLineReadable {
50 public:
51  int value;
52  cmdLineInt(const char* name);
53  cmdLineInt(const char* name,const int& v);
54  int read(char** argv,int argc);
55  void writeValue(char* str);
56 };
57 template<int Dim>
59 public:
60  int values[Dim];
61  cmdLineIntArray(const char* name);
62  cmdLineIntArray(const char* name,const int v[Dim]);
63  int read(char** argv,int argc);
64  void writeValue(char* str);
65 };
66 
67 class cmdLineFloat : public cmdLineReadable {
68 public:
69  float value;
70  cmdLineFloat(const char* name);
71  cmdLineFloat(const char* name,const float& f);
72  int read(char** argv,int argc);
73  void writeValue(char* str);
74 };
75 template<int Dim>
77 public:
78  float values[Dim];
79  cmdLineFloatArray(const char* name);
80  cmdLineFloatArray(const char* name,const float f[Dim]);
81  int read(char** argv,int argc);
82  void writeValue(char* str);
83 };
85 public:
86  char* value;
87  cmdLineString(const char* name);
89  int read(char** argv,int argc);
90  void writeValue(char* str);
91 };
93  int Dim;
94 public:
95  char** values;
96  cmdLineStrings(const char* name,int Dim);
97  ~cmdLineStrings(void);
98  int read(char** argv,int argc);
99  void writeValue(char* str);
100 };
101 template<int Dim>
103 public:
104  char* values[Dim];
105  cmdLineStringArray(const char* name);
107  int read(char** argv,int argc);
108  void writeValue(char* str);
109 };
110 
111 // This reads the arguments in argc, matches them against "names" and sets
112 // the values of "r" appropriately. Parameters start with "--"
113 void cmdLineParse(int argc, char **argv,int num,cmdLineReadable** r,int dumpError=1);
114 
115 char* GetFileExtension(char* fileName);
116 char* GetLocalFileName(char* fileName);
117 char** ReadWords(const char* fileName,int& cnt);
118 
119 #include "CmdLineParser.inl"
120 #endif // CMD_LINE_PARSER_INCLUDED
char * GetLocalFileName(char *fileName)
char * GetFileExtension(char *fileName)
void cmdLineParse(int argc, char **argv, int num, cmdLineReadable **r, int dumpError=1)
char ** ReadWords(const char *fileName, int &cnt)
float values[Dim]
Definition: CmdLineParser.h:78
int read(char **argv, int argc)
cmdLineFloatArray(const char *name)
void writeValue(char *str)
cmdLineFloatArray(const char *name, const float f[Dim])
cmdLineFloat(const char *name)
int read(char **argv, int argc)
void writeValue(char *str)
cmdLineIntArray(const char *name, const int v[Dim])
cmdLineIntArray(const char *name)
void writeValue(char *str)
int read(char **argv, int argc)
void writeValue(char *str)
int read(char **argv, int argc)
cmdLineInt(const char *name)
cmdLineReadable(const char *name)
virtual void writeValue(char *str)
virtual ~cmdLineReadable(void)
virtual int read(char **argv, int argc)
cmdLineStringArray(const char *name)
int read(char **argv, int argc)
char * values[Dim]
void writeValue(char *str)
int read(char **argv, int argc)
void writeValue(char *str)
cmdLineString(const char *name)
void writeValue(char *str)
cmdLineStrings(const char *name, int Dim)
int read(char **argv, int argc)