CARMA C++
posixErrors.h
1 #ifndef CARMA_UTIL_POSIX_ERRORS_H
2 #define CARMA_UTIL_POSIX_ERRORS_H
3 
4 #include <string>
5 
6 
7 namespace carma {
8 namespace util {
9 
10 
11 ::std::string getPosixFailureMessage( const char * prefix,
12  int errorCode );
13 
14 ::std::string getPosixFailureMessage( const ::std::string & prefix,
15  int errorCode );
16 
17 
18 void throwPosixError( int errorCode );
19 void throwPosixError( int errorCode, const char * message );
20 void throwPosixError( int errorCode, const ::std::string & message );
21 
22 
23 void logPosixError( int errorCode );
24 void logPosixError( int errorCode, const char * message );
25 void logPosixError( int errorCode, const ::std::string & message );
26 
27 
28 void failIfPosixError( int errorCode );
29 void failIfPosixError( int errorCode, const char * message );
30 void failIfPosixError( int errorCode, const ::std::string & message );
31 
32 
33 void logIfPosixError( int errorCode );
34 void logIfPosixError( int errorCode, const char * message );
35 void logIfPosixError( int errorCode, const ::std::string & message );
36 
37 
38 } // namespace carma::util
39 } // namespace carma
40 
41 
42 inline void
43 carma::util::failIfPosixError( const int errorCode )
44 {
45  if ( errorCode != 0 )
46  throwPosixError( errorCode );
47 }
48 
49 
50 inline void
51 carma::util::failIfPosixError( const int errorCode,
52  const char * const message )
53 {
54  if ( errorCode != 0 )
55  throwPosixError( errorCode, message );
56 }
57 
58 
59 inline void
60 carma::util::failIfPosixError( const int errorCode,
61  const ::std::string & message )
62 {
63  if ( errorCode != 0 )
64  throwPosixError( errorCode, message );
65 }
66 
67 
68 inline void
69 carma::util::logIfPosixError( const int errorCode )
70 {
71  if ( errorCode != 0 )
72  logPosixError( errorCode );
73 }
74 
75 
76 inline void
77 carma::util::logIfPosixError( const int errorCode,
78  const char * const message )
79 {
80  if ( errorCode != 0 )
81  logPosixError( errorCode, message );
82 }
83 
84 
85 inline void
86 carma::util::logIfPosixError( const int errorCode,
87  const ::std::string & message )
88 {
89  if ( errorCode != 0 )
90  logPosixError( errorCode, message );
91 }
92 
93 
94 #endif