Debian Codegraph @

src/thirdparty/PoissonRecon/CmdLineParser.h

raw
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
32 #include <stdarg.h>
33 #include <cstring>
34 #include <cstdlib>
35 #include <string>
36 #include <cassert>
37 #include <string.h>
38 #include <vector>
39 #include "Geometry.h"
40
41 namespace PoissonRecon
42 {
43 #ifdef WIN32
44 int strcasecmp( const char* c1 , const char* c2 );
45 #endif // WIN32
46
47 class CmdLineReadable
48 {
49 public:
50 bool set;
51 char *name;
52 CmdLineReadable( const char *name );
53 virtual ~CmdLineReadable( void );
54 virtual int read( char** argv , int argc );
55 virtual void writeValue( char* str ) const;
56 };
57
58 template< typename Type > struct CmdLineType;
59
60 template< typename Type >
61 struct CmdLineType
62 {
63 static void WriteValue( Type t , char* str );
64 static void CleanUp( Type* t ){}
65 static Type Initialize( void ){ return Type(); }
66 static Type Copy( Type t ){ return t; }
67 static Type StringToType( const char *str );
68 };
69
70 template< typename Real , unsigned int Dim >
71 struct CmdLineType< Point< Real , Dim > >
72 {
73 using Type = Point< Real , Dim >;
74 static void WriteValue( Type t , char* str );
75 static void CleanUp( Type* t ){}
76 static Type Initialize( void ){ return Type(); }
77 static Type Copy( Type t ){ return t; }
78 static Type StringToType( const char *str );
79 };
80 template< class Type >
81 class CmdLineParameter : public CmdLineReadable
82 {
83 public:
84 Type value;
85 CmdLineParameter( const char *name );
86 CmdLineParameter( const char *name , Type v );
87 ~CmdLineParameter( void );
88 int read( char** argv , int argc );
89 void writeValue( char* str ) const;
90 bool expectsArg( void ) const { return true; }
91 };
92
93 template< class Type , int Dim >
94 class CmdLineParameterArray : public CmdLineReadable
95 {
96 public:
97 Type values[Dim];
98 CmdLineParameterArray( const char *name, const Type* v=NULL );
99 ~CmdLineParameterArray( void );
100 int read( char** argv , int argc );
101 void writeValue( char* str ) const;
102 bool expectsArg( void ) const { return true; }
103 };
104
105 template< class Type >
106 class CmdLineParameters : public CmdLineReadable
107 {
108 public:
109 int count;
110 Type *values;
111 CmdLineParameters( const char* name );
112 ~CmdLineParameters( void );
113 int read( char** argv , int argc );
114 void writeValue( char* str ) const;
115 bool expectsArg( void ) const { return true; }
116 };
117
118 void CmdLineParse( int argc , char **argv, CmdLineReadable** params );
119 char* FileExtension( char* fileName );
120 char* LocalFileName( char* fileName );
121 char* DirectoryName( char* fileName );
122 char* GetFileExtension( const char* fileName );
123 char* GetLocalFileName( const char* fileName );
124 char** ReadWords( const char* fileName , int& cnt );
125
126 #include "CmdLineParser.inl"
127 }
128 #endif // CMD_LINE_PARSER_INCLUDED