Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
parse.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2012, Willow Garage, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Willow Garage, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * $Id: parse.h 5155 2012-03-17 21:45:48Z rusu $
37  *
38  */
39 #ifndef PCL_CONSOLE_PARSE_H_
40 #define PCL_CONSOLE_PARSE_H_
41 
42 #include <vector>
43 #include <string>
44 #include <string.h>
45 #include <stdlib.h>
46 #include <boost/algorithm/string.hpp>
47 #include <sstream>
48 
49 #include <pcl/pcl_macros.h>
50 
51 namespace pcl
52 {
53  namespace console
54  {
64  PCL_EXPORTS bool
65  find_switch (int argc, char** argv, const char* argument_name);
66 
73  PCL_EXPORTS int
74  find_argument (int argc, char** argv, const char* argument_name);
75 
83  template<typename Type> int
84  parse (int argc, char** argv, const char* argument_name, Type& value)
85  {
86  int index = find_argument (argc, argv, argument_name) + 1;
87 
88  if (index > 0 && index < argc)
89  {
90  std::istringstream stream;
91  stream.clear ();
92  stream.str (argv[index]);
93  stream >> value;
94  }
95 
96  return (index - 1);
97  }
98 
106  PCL_EXPORTS int
107  parse_argument (int argc, char** argv, const char* str, std::string &val);
108 
116  PCL_EXPORTS int
117  parse_argument (int argc, char** argv, const char* str, bool &val);
118 
126  PCL_EXPORTS int
127  parse_argument (int argc, char** argv, const char* str, float &val);
128 
136  PCL_EXPORTS int
137  parse_argument (int argc, char** argv, const char* str, double &val);
138 
146  PCL_EXPORTS int
147  parse_argument (int argc, char** argv, const char* str, int &val);
148 
156  PCL_EXPORTS int
157  parse_argument (int argc, char** argv, const char* str, unsigned int &val);
158 
166  PCL_EXPORTS int
167  parse_argument (int argc, char** argv, const char* str, char &val);
168 
178  PCL_EXPORTS int
179  parse_2x_arguments (int argc, char** argv, const char* str, float &f, float &s, bool debug = true);
180 
190  PCL_EXPORTS int
191  parse_2x_arguments (int argc, char** argv, const char* str, double &f, double &s, bool debug = true);
192 
202  PCL_EXPORTS int
203  parse_2x_arguments (int argc, char** argv, const char* str, int &f, int &s, bool debug = true);
204 
215  PCL_EXPORTS int
216  parse_3x_arguments (int argc, char** argv, const char* str, float &f, float &s, float &t, bool debug = true);
217 
228  PCL_EXPORTS int
229  parse_3x_arguments (int argc, char** argv, const char* str, double &f, double &s, double &t, bool debug = true);
230 
241  PCL_EXPORTS int
242  parse_3x_arguments (int argc, char** argv, const char* str, int &f, int &s, int &t, bool debug = true);
243 
251  PCL_EXPORTS int
252  parse_x_arguments (int argc, char** argv, const char* str, std::vector<double>& v);
253 
261  PCL_EXPORTS int
262  parse_x_arguments (int argc, char** argv, const char* str, std::vector<float>& v);
263 
271  PCL_EXPORTS int
272  parse_x_arguments (int argc, char** argv, const char* str, std::vector<int>& v);
273 
281  PCL_EXPORTS bool
282  parse_multiple_arguments (int argc, char** argv, const char* str, std::vector<int> &values);
283 
291  PCL_EXPORTS bool
292  parse_multiple_arguments (int argc, char** argv, const char* str, std::vector<float> &values);
293 
301  PCL_EXPORTS bool
302  parse_multiple_arguments (int argc, char** argv, const char* str, std::vector<double> &values);
303 
311  PCL_EXPORTS bool
312  parse_multiple_arguments (int argc, char** argv, const char* str, std::vector<std::string> &values);
313 
323  PCL_EXPORTS bool
324  parse_multiple_2x_arguments (int argc, char** argv, const char* str,
325  std::vector<double> &values_f,
326  std::vector<double> &values_s);
327 
338  PCL_EXPORTS bool
339  parse_multiple_3x_arguments (int argc, char** argv, const char* str,
340  std::vector<double> &values_f,
341  std::vector<double> &values_s,
342  std::vector<double> &values_t);
343 
350  PCL_EXPORTS std::vector<int>
351  parse_file_extension_argument (int argc, char** argv, const std::string &ext);
352  }
353 }
354 
355 #endif // PCL_CONSOLE_PARSE_H_
356