00001 00007 /* Copyright (C) 2010, Bernd Speiser */ 00008 /* This file is part of Quantity. 00009 00010 Quantity is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU General Public License 00012 as published by the Free Software Foundation; either version 2 00013 of the License, or (at your option) any later version. 00014 00015 Quantity is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00023 02111-1307, USA. 00024 */ 00025 00026 #ifndef _UnitError_h 00027 #define _UnitError_h 00028 00029 //STL includes 00030 #include <string> 00031 00032 namespace unit 00033 { 00034 00036 // 00037 // exception classes 00038 // 00040 00042 00046 class UnitError 00047 { 00048 public: 00049 UnitError( const std::string& message ) 00050 : _message( message ) 00051 {} 00052 virtual ~UnitError(){} 00053 00054 virtual std::string message() const 00055 { 00056 return _message; 00057 } 00058 00059 00060 protected: 00061 std::string _message; 00062 00063 }; 00064 00066 00069 class UnitMismatch : public UnitError 00070 { 00071 private: 00073 static const std::string UNIT_MISMATCH; 00074 00075 public: 00077 00079 UnitMismatch (void) : UnitError (UNIT_MISMATCH) {} 00080 00082 00084 UnitMismatch (const std::string message) : UnitError (message) {} 00085 }; 00086 00088 00090 class UnitInputError : public UnitError 00091 { 00092 private: 00094 static const std::string INPUT_ERROR; 00095 00096 public: 00098 00100 UnitInputError (void) : UnitError (INPUT_ERROR) {} 00101 00103 00105 UnitInputError (const std::string message) : UnitError (message) {} 00106 }; 00107 00109 00111 class UnitSyntaxError : public UnitError 00112 { 00113 private: 00115 static const std::string INPUT_ERROR; 00116 00117 public: 00119 00121 UnitSyntaxError (void) : UnitError (INPUT_ERROR) {} 00122 00124 00126 UnitSyntaxError (const std::string message) : UnitError (message) {} 00127 }; 00128 00129 } // namespace unit 00130 00131 #endif // _UnitError_h 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144