WvStreams
wverror.h
1/* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 *
5 * A class for managing error numbers and strings.
6 */
7#ifndef __WVERROR_H
8#define __WVERROR_H
9
10#include "wvstring.h"
11
24{
25protected:
26 int errnum;
27 WvString errstring;
28
29public:
31 { noerr(); }
32 virtual ~WvErrorBase();
33
39 virtual bool isok() const
40 { return errnum == 0; }
41
48 virtual int geterr() const
49 { return errnum; }
50 virtual WvString errstr() const;
51
56 static WvString strerror(int errnum);
57
68 virtual void seterr(int _errnum);
69 void seterr(WvStringParm specialerr);
70 void seterr(WVSTRING_FORMAT_DECL)
71 { seterr(WvString(WVSTRING_FORMAT_CALL)); }
72 void seterr_both(int _errnum, WvStringParm specialerr);
73 void seterr_both(int _errnum, WVSTRING_FORMAT_DECL)
74 { seterr_both(_errnum, WvString(WVSTRING_FORMAT_CALL)); }
75 void seterr(const WvErrorBase &err);
76
78 void noerr()
79 { errnum = 0; errstring = WvString::null; }
80};
81
82
89class WvError : public WvErrorBase
90{
91public:
92 int get() const
93 { return geterr(); }
94 WvString str() const
95 { return errstr(); }
96
97 void set(int _errnum)
98 { seterr(_errnum); }
99 void set(WvStringParm specialerr)
100 { seterr(specialerr); }
101 void set(WVSTRING_FORMAT_DECL)
102 { seterr(WvString(WVSTRING_FORMAT_CALL)); }
103 void set_both(int _errnum, WvStringParm specialerr)
104 { seterr_both(_errnum, specialerr); }
105 void set(const WvErrorBase &err)
106 { seterr(err); }
107
108 void reset()
109 { noerr(); }
110};
111
112
113#endif // __WVERROR_H
A class for managing error numbers and strings.
Definition wverror.h:24
static WvString strerror(int errnum)
A replacement for the operating system strerror() function that can map more kinds of error strings (...
Definition wverror.cc:91
void noerr()
Reset our error state - there's no error condition anymore.
Definition wverror.h:78
virtual bool isok() const
By default, returns true if geterr() == 0.
Definition wverror.h:39
virtual void seterr(int _errnum)
Set the errnum variable – we have an error.
Definition wverror.cc:144
virtual int geterr() const
If isok() is false, return the system error number corresponding to the error, -1 for a special error...
Definition wverror.h:48
A variant of WvErrorBase suitable for embedding as a member of your own object, preferably called 'er...
Definition wverror.h:90
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Definition wvstring.h:94
WvString is an implementation of a simple and efficient printable-string class.
Definition wvstring.h:330