00001
00010 #ifndef __SIMGEAR_MISC_EXCEPTION_HXX
00011 #define __SIMGEAR_MISC_EXCEPTION_HXX 1
00012
00013 #include <simgear/compiler.h>
00014 #include STL_STRING
00015
00016 SG_USING_STD(string);
00017
00018
00026 class sg_location
00027 {
00028 public:
00029 sg_location ();
00030 sg_location (const string &path, int line = -1, int column = -1);
00031 virtual ~sg_location ();
00032 virtual const string &getPath () const;
00033 virtual void setPath (const string &path);
00034 virtual int getLine () const;
00035 virtual void setLine (int line);
00036 virtual int getColumn () const;
00037 virtual void setColumn (int column);
00038 virtual int getByte () const;
00039 virtual void setByte (int byte);
00040 virtual string asString () const;
00041 private:
00042 string _path;
00043 int _line;
00044 int _column;
00045 int _byte;
00046 };
00047
00048
00052 class sg_throwable
00053 {
00054 public:
00055 sg_throwable ();
00056 sg_throwable (const string &message, const string &origin = "");
00057 virtual ~sg_throwable ();
00058 virtual const string &getMessage () const;
00059 virtual const string getFormattedMessage () const;
00060 virtual void setMessage (const string &message);
00061 virtual const string &getOrigin () const;
00062 virtual void setOrigin (const string &origin);
00063 private:
00064 string _message;
00065 string _origin;
00066 };
00067
00068
00069
00079 class sg_error : public sg_throwable
00080 {
00081 public:
00082 sg_error ();
00083 sg_error (const string &message, const string &origin = "");
00084 virtual ~sg_error ();
00085 };
00086
00087
00102 class sg_exception : public sg_throwable
00103 {
00104 public:
00105 sg_exception ();
00106 sg_exception (const string &message, const string &origin = "");
00107 virtual ~sg_exception ();
00108 };
00109
00110
00122 class sg_io_exception : public sg_exception
00123 {
00124 public:
00125 sg_io_exception ();
00126 sg_io_exception (const string &message, const string &origin = "");
00127 sg_io_exception (const string &message, const sg_location &location,
00128 const string &origin = "");
00129 virtual ~sg_io_exception ();
00130 virtual const string getFormattedMessage () const;
00131 virtual const sg_location &getLocation () const;
00132 virtual void setLocation (const sg_location &location);
00133 private:
00134 sg_location _location;
00135 };
00136
00137
00149 class sg_format_exception : public sg_exception
00150 {
00151 public:
00152 sg_format_exception ();
00153 sg_format_exception (const string &message, const string &text,
00154 const string &origin = "");
00155 virtual ~sg_format_exception ();
00156 virtual const string &getText () const;
00157 virtual void setText (const string &text);
00158 private:
00159 string _text;
00160 };
00161
00162
00172 class sg_range_exception : public sg_exception
00173 {
00174 public:
00175 sg_range_exception ();
00176 sg_range_exception (const string &message, const string &origin = "");
00177 virtual ~sg_range_exception ();
00178 };
00179
00180 #endif
00181
00182