00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _SRC_SERROR_H_
00018 #define _SRC_SERROR_H_ 1
00019
00028 #include <lib/sconfig.h>
00029
00030 #include <lib/tl/tlstring.h>
00031 #include <glib/gerror.h>
00032
00033
00054 class SError
00055 {
00056 private:
00057 TLString errmsg;
00058 int ecode;
00059 int edomain;
00060
00061 void _assign(GError *&g);
00062 public:
00064 inline SError() : errmsg(),ecode(0),edomain(-1) { }
00066 inline SError(const SError &e) : errmsg(e.errmsg),ecode(e.ecode),
00067 edomain(e.edomain) { }
00070 inline SError(GError *&g) : errmsg(),ecode(0),edomain(-1)
00071 { _assign(g); }
00073 inline SError(const char *str,int _code,int _domain=-1) :
00074 errmsg(str),ecode(_code),edomain(_domain) { }
00076 inline SError(const TLString &str,int _code,int _domain=-1) :
00077 errmsg(str),ecode(_code),edomain(_domain) { }
00079 inline ~SError() {}
00080
00083 inline SError &operator=(GError *&g)
00084 { _assign(g); return(*this); }
00086 inline SError &operator=(const SError &e)
00087 { errmsg=e.errmsg; ecode=e.ecode; edomain=e.edomain; return(*this); }
00088
00090 inline operator bool() const
00091 { return(ecode); }
00093 inline bool operator!() const
00094 { return(!ecode); }
00095
00097 inline void clear()
00098 { errmsg=NULL; ecode=0; edomain=-1; }
00099
00101 inline const TLString &msg() const
00102 { return(errmsg); }
00103
00105 void AppendMsg(const TLString &str);
00107 void AppendMsg(const char *str);
00108
00110 inline int code() const
00111 { return(ecode); }
00112 };
00113
00114 #endif