#include "CTBretcode.hxx"
Public Methods | |
CTBretcode () | |
CTBretcode (int i_code) | |
CTBretcode (int i_code, const char *c_text1) | |
CTBretcode (int i_code, const char *c_text1, const char *c_text2) | |
CTBretcode (int i_code, const char *c_text1, const char *c_text2, const char *c_text3) | |
CTBretcode (int i_code, int i_errno) | |
CTBretcode (int i_code, const char *c_text1, int i_errno) | |
CTBretcode (int i_code, const CTBretcode &rc) | |
CTBretcode (int i_code, const char *c_text1, const CTBretcode &rc) | |
CTBretcode (const CTBretcode &rhs) | |
void | Set (int i_code) |
void | Set (int i_code, const char *c_text1) |
void | Set (int i_code, const char *c_text1, const char *c_text2) |
void | Set (int i_code, const char *c_text1, const char *c_text2, const char *c_text3) |
void | Set (int i_code, int i_errno) |
void | Set (int i_code, const char *c_text1, int i_errno) |
void | Set (int i_code, const CTBretcode &rc) |
void | Set (int i_code, const char *c_text1, const CTBretcode &rc) |
int | Code () const |
int | Errno () const |
const char * | Text1 () const |
const char * | Text2 () const |
const char * | Text3 () const |
void | ToStream (ostream &os=cout) const |
bool | operator! () const |
operator int () const | |
operator const char * () const | |
CTBretcode & | operator= (const CTBretcode &rhs) |
CTBretcode & | operator= (int i_code) |
Private Attributes | |
int | mi_code |
int | mi_errno |
const char * | mc_text1 |
const char * | mc_text2 |
const char * | mc_text3 |
Related Functions | |
(Note that these are not member functions.) | |
ostream & | operator<< (ostream &os, const CTBretcode &obj) |
This class allows to pass both a numerical return code, the system errno and a set of up to 3 text messages in an efficient way. The numerical return code is usually used to control the flow in the calling routine, while the text messages and the stored errno value are by and large used to generate notifications.
CTBretcode
handles one integer return code and three strings, in the following called text1
, text2
, and text3
. The first string should be a textural representation of the return code, while the other two can be used to express qualifications and specializations.
The implementation of CTBretcode
assumes that all const char*
pointers passed to constructors and Set()
methods refer to character strings with infinite life time. In general one should only pass pointers to string constants or a string literal for any of the c_text arguments.
The text messages should in general have no embedded or trailing newlines. However, the ToStream()
method is tolerant to trailing newlines.
There is a range of constructors to setup the code and text fields, and also a set of Set()
methods with corresponding argument lists.
Two constructors and corresponding Set()
methods allow to setup a CTBretcode
object with a text message derived from a system error code, usually taken from errno
.
Two constructor and corresponding Set()
methods allow to use the text messages from another CTBretcode
object. This is in particular useful when a return code is passed through several layers of calls.
Definition at line 16 of file CTBretcode.hxx.
|
Default constructor: sets code=0.
Definition at line 17 of file CTBretcode.icc. |
|
Constructor: set code, no text.
Definition at line 28 of file CTBretcode.icc. |
|
Constructor: set code and text1.
Definition at line 39 of file CTBretcode.icc. |
|
Constructor: set code, text1, and text2.
Definition at line 50 of file CTBretcode.icc. |
|
Constructor: set code, text1, text2, and text3.
Definition at line 62 of file CTBretcode.icc. |
|
Constructor: set code and errno.
This form is useful after a standart library routine returned with an error. The message text, when printed with if(tcgetattr(mi_fd, &m_oldtios) == -1) { return CTBretcode(err_xxx,errno); } Definition at line 84 of file CTBretcode.icc. |
|
Constructor: set code, errno, and text1. This form is useful after a standart library routine returned with an error. if(tcgetattr(mi_fd, &m_oldtios) == -1) { return CTBretcode(err_xxx,"tcgetattr failed",errno); } err_xxx , the primary message text, here "tcgetattr failed", describes the environment of the problem while the secondary message text will be derived from the value of errno and will describe the details.
Definition at line 108 of file CTBretcode.icc. |
|
Constructor: set code, use text from rc.
This form allows to set the code but take all the text messages from another CTBretcode rc; .. rc = foo(); if (!rc) return CTBretcode(err_xxx,rc); Definition at line 130 of file CTBretcode.icc. |
|
Constructor: set code and text1, get text2 and text3 from rc.
This form allows to set the code and the primary message and setup the secondary and ternary message from another CTBretcode rc; .. rc = foo(); if (rc) return CTBretcode(err_xxx,"error in foo()",rc); Definition at line 153 of file CTBretcode.icc. |
|
Copy constructor.
Definition at line 165 of file CTBretcode.icc. |
|
Set code to i_code, clear errno and all text.
Definition at line 176 of file CTBretcode.icc. |
|
Set code and text1.
Definition at line 189 of file CTBretcode.icc. |
|
Set code, text1, and text2.
Definition at line 202 of file CTBretcode.icc. |
|
Set code, text1, text2, and text3.
Definition at line 216 of file CTBretcode.icc. |
|
Set code and errno. See also corresponding contructor CTBretcode(int i_code, int i_errno). Definition at line 233 of file CTBretcode.icc. |
|
Set code, errno and text1. See also corresponding constructor CTBretcode(int i_code, const char* c_text1, int i_errno). Definition at line 250 of file CTBretcode.icc. |
|
Set code, use text from rc.
Definition at line 263 of file CTBretcode.icc. |
|
Set code and text1, get text2 and text3 from rc.
Definition at line 276 of file CTBretcode.icc. |
|
Returns numerical return code.
Definition at line 290 of file CTBretcode.icc. |
|
Returns stored errno.
Definition at line 298 of file CTBretcode.icc. |
|
Returns 1st text message.
Definition at line 306 of file CTBretcode.icc. |
|
Returns 2nd text message.
Definition at line 314 of file CTBretcode.icc. |
|
Returns 3rd text message.
Definition at line 322 of file CTBretcode.icc. |
|
ostream insertion.
The text1 - text2 - text3 - text(errno) Return code: nnn Definition at line 96 of file CTBretcode.cxx. Referenced by operator<<().
|
|
Returns
This operator method allows to use a CTBretcode rc; .. rc = foo(); if (!rc) { .. // executed if foo() succeded } Definition at line 342 of file CTBretcode.icc. |
|
Convert to
Definition at line 350 of file CTBretcode.icc. |
|
Convert to
This conversion method returns a
This somewhat contrived semantics is necessary to have consistent behavior with operator int() and Definition at line 132 of file CTBretcode.cxx. |
|
Copy
Definition at line 358 of file CTBretcode.icc. |
|
Set code to i_code, clear errno and all text.
Definition at line 371 of file CTBretcode.icc. |
|
ostream insertion operator, forwards to
Definition at line 387 of file CTBretcode.icc. |
|
return code.
Definition at line 70 of file CTBretcode.hxx. |
|
associated
Definition at line 71 of file CTBretcode.hxx. |
|
1st message text.
Definition at line 72 of file CTBretcode.hxx. |
|
2nd message text.
Definition at line 73 of file CTBretcode.hxx. |
|
3rd message text.
Definition at line 74 of file CTBretcode.hxx. |