ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/truck/Common/posix.hpp
Revision: 2
Committed: 2007-04-25T21:28:10-07:00 (15 years, 5 months ago) by douglas
File size: 559 byte(s)
Log Message:
Woo!

File Contents

# Content
1 // Truck Computer Dooom!
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #ifndef _posix_hpp_
8 #define _posix_hpp_
9
10 #include <cerrno>
11 #include <cstring>
12 #include <exception>
13
14 namespace Posix
15 {
16
17 inline int CheckError(int status);
18
19 class Error : public std::exception
20 {
21 int code;
22 char message[1024];
23
24 public:
25 Error();
26 virtual ~Error() throw() {}
27
28 virtual int GetCode() const { return code; }
29 virtual const char *what() const throw() { return message; }
30 };
31
32 inline int CheckError(int status)
33 {
34 if (status == -1)
35 throw Error();
36
37 return status;
38 }
39
40 }
41
42 #endif//_posix_hpp_