openni2_exception.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011 Willow Garage, Inc.
5  * Suat Gedikli <gedikli@willowgarage.com>
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  */
37 #ifndef __OPENNI2_EXCEPTION__
38 #define __OPENNI2_EXCEPTION__
39 
40 #include <cstdarg>
41 #include <cstdio>
42 #include <exception>
43 #include <string>
44 
45 #if defined _WIN32 && defined _MSC_VER
46 # define __PRETTY_FUNCTION__ __FUNCTION__
47 #endif
48 #define THROW_OPENNI_EXCEPTION(format,...) throwOpenNIException( __PRETTY_FUNCTION__, __FILE__, __LINE__, format , ##__VA_ARGS__ )
49 
50 namespace openni2_wrapper
51 {
57 class OpenNI2Exception : public std::exception
58 {
59 public:
60  OpenNI2Exception(const std::string& function_name,
61  const std::string& file_name,
62  unsigned line_number,
63  const std::string& message) throw ();
64 
65  virtual ~OpenNI2Exception() throw ();
66  OpenNI2Exception & operator=(const OpenNI2Exception& exception) throw ();
67  virtual const char* what() const throw ();
68 
69  const std::string& getFunctionName() const throw ();
70  const std::string& getFileName() const throw ();
71  unsigned getLineNumber() const throw ();
72 
73 protected:
74  std::string function_name_;
75  std::string file_name_;
76  unsigned line_number_;
77  std::string message_;
78  std::string message_long_;
79 };
80 
81 inline void throwOpenNIException(const char* function, const char* file, unsigned line, const char* format, ...)
82 {
83  static char msg[1024];
84  va_list args;
85  va_start(args, format);
86  vsprintf(msg, format, args);
87  throw OpenNI2Exception(function, file, line, msg);
88 }
89 } // namespace openni_camera
90 #endif
OpenNI2Exception(const std::string &function_name, const std::string &file_name, unsigned line_number, const std::string &message)
const std::string & getFileName() const
OpenNI2Exception & operator=(const OpenNI2Exception &exception)
void throwOpenNIException(const char *function, const char *file, unsigned line, const char *format,...)
General exception class.
virtual const char * what() const
const std::string & getFunctionName() const


openni2_camera
Author(s): Julius Kammerl
autogenerated on Fri Jun 7 2019 22:05:43