iRoCS Toolbox  1.1.0
BlitzAnalyzeError.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2010 Robert Bensch
4  *
5  * Image Analysis Lab, University of Freiburg, Germany
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  **************************************************************************/
22 
23 #ifndef ANALYZEERROR_HH
24 #define ANALYZEERROR_HH
25 
26 #ifdef HAVE_CONFIG_H
27 #include <config.hh>
28 #endif
29 
30 #include <string>
31 #include <sstream>
32 #include <iostream>
33 
34  /*======================================================================*/
39  /*======================================================================*/
41 public:
42  /*======================================================================*/
48  /*======================================================================*/
50 
51  /*======================================================================*/
59  /*======================================================================*/
60  BlitzAnalyzeError(const std::string& message)
61  :_message(message) {}
62 
63  /*======================================================================*/
69  /*======================================================================*/
70  template<class DataType>
71  BlitzAnalyzeError & operator<<(const DataType &data) {
72  std::ostringstream os;
73  os << data;
74  _message += os.str();
75  return *this;
76  }
77 
78  /*======================================================================*/
84  /*======================================================================*/
85  std::string str() const {
86  return _message;
87  }
88 
89  const char* what() const {
90  return _message.c_str();
91  }
92 
93 private:
94  std::string _message;
95 
96 };
97 
98 #endif
BlitzAnalyzeError()
Default constructor.
std::string str() const
Returns the error message.
BlitzAnalyzeError(const std::string &message)
Creates an error object with the given message.
BlitzAnalyzeError & operator<<(const DataType &data)
Appends the given data to the message string.
Error class for BlitzAnalyzeFile.
const char * what() const