00001 #ifndef HZZ2L2NU_INCLUDE_HZZEXCEPTION_H_
00002 #define HZZ2L2NU_INCLUDE_HZZEXCEPTION_H_
00003
00004 #include <sstream>
00005 #include <string>
00006 #include <stdexcept>
00007
00008
00017 class HZZException : public std::exception {
00018 public:
00020 HZZException(std::string message = "")
00021 : message_{message} {}
00022
00024 template<typename T>
00025 HZZException &operator<<(T const &token) {
00026 message_ << token;
00027 return *this;
00028 }
00029
00031 char const *what() const noexcept override {
00032 buffer_ = message_.str();
00033 return buffer_.c_str();
00034 }
00035
00036 private:
00038 std::ostringstream message_;
00039
00041 mutable std::string buffer_;
00042 };
00043
00044 #endif // HZZ2L2NU_INCLUDE_HZZEXCEPTION_H_