00001
00002
00003
00004
00005
00006
00007 #ifndef __WVERROR_H
00008 #define __WVERROR_H
00009
00010 #include "wvstring.h"
00011
00023 class WvErrorBase
00024 {
00025 protected:
00026 int errnum;
00027 WvString errstring;
00028
00029 public:
00030 WvErrorBase()
00031 { noerr(); }
00032 virtual ~WvErrorBase();
00033
00039 virtual bool isok() const
00040 { return errnum == 0; }
00041
00048 virtual int geterr() const
00049 { return errnum; }
00050 virtual WvString errstr() const;
00051
00062 virtual void seterr(int _errnum);
00063 void seterr(WvStringParm specialerr);
00064 void seterr(WVSTRING_FORMAT_DECL)
00065 { seterr(WvString(WVSTRING_FORMAT_CALL)); }
00066 void seterr(const WvErrorBase &err);
00067
00069 void noerr()
00070 { errnum = 0; errstring = WvString::null; }
00071 };
00072
00073
00080 class WvError : public WvErrorBase
00081 {
00082 public:
00083 int get() const
00084 { return geterr(); }
00085 WvString str() const
00086 { return errstr(); }
00087
00088 void set(int _errnum)
00089 { seterr(_errnum); }
00090 void set(WvStringParm specialerr)
00091 { seterr(specialerr); }
00092 void set(WVSTRING_FORMAT_DECL)
00093 { seterr(WvString(WVSTRING_FORMAT_CALL)); }
00094 void set(const WvErrorBase &err)
00095 { seterr(err); }
00096
00097 void reset()
00098 { noerr(); }
00099 };
00100
00101
00102 #endif // __WVERROR_H