Scarab  v2.4.2
Project 8 C++ Utility Library
error.hh
Go to the documentation of this file.
1 #ifndef SCARAB_EXCEPTION_HH_
2 #define SCARAB_EXCEPTION_HH_
3 
4 #include <exception>
5 #include <sstream>
6 #include <string>
7 
8 #include "scarab_api.hh"
9 
10 namespace scarab
11 {
12 
13  class SCARAB_API error : public ::std::exception
14  {
15  public:
16  error();
17  error( const error& );
18  ~error() throw ();
19 
20  template< class x_streamable >
21  error& operator<<( x_streamable a_fragment );
22  error& operator<<( const std::string& a_fragment );
23  error& operator<<( const char* a_fragment );
24 
25  virtual const char* what() const throw();
26 
27  private:
28  std::string f_error;
29  };
30 
31  template< class x_streamable >
32  error& error::operator<<( x_streamable a_fragment )
33  {
34  std::stringstream stream;
35  stream << a_fragment;
36  stream >> f_error;
37  return *this;
38  }
39 
40  inline error& error::operator<<( const std::string& a_fragment )
41  {
42  f_error += a_fragment;
43  return *this;
44  }
45 
46  inline error& error::operator<<( const char* a_fragment )
47  {
48  f_error += std::string( a_fragment );
49  return *this;
50  }
51 
52 
53 }
54 
55 #endif /* SCARAB_EXCEPTION_HH_ */
#define SCARAB_API
Definition: scarab_api.hh:24
std::string f_error
Definition: error.hh:28
SCARAB_API std::ostream & operator<<(std::ostream &out, const param_array &a_value)
Definition: param_array.cc:167
error & operator<<(x_streamable a_fragment)
Definition: error.hh:32