OWLNext 7.0
Borland's Object Windows Library for the modern age
|
TSocketError converts Windows Sockets errors to string messages. More...
#include <owl/wskerr.h>
Public Member Functions | |
TSocketError (int error=0, unsigned sizeToAllocate=128) | |
This function constructs the object with the error code and the size of the buffer to allocate. | |
virtual | ~TSocketError () |
This function destroys the allocated string. | |
TSocketError (const TSocketError &src) | |
Copies the error code and string. | |
TSocketError & | operator= (const TSocketError &src) |
This function copies the error code and string. | |
void | Init (int error) |
This function initializes the error code. | |
int | GetReasonValue () const |
This function returns the error code. | |
const tchar * | GetReasonString () const |
This function hands the pointer to the string to the caller. | |
tchar * | AppendError (const tchar *stringToAppendErrorTo, tchar *destination=0) |
This function appends the error string to whatever is in the string 'stringToAppendErrorTo' and put the result in 'destination'. | |
tchar * | AppendError (int stringResourceToAppendErrorTo, tchar *destination=0) |
This function is similar to AppendError(char*, char*), but the pre-string comes from a string resource and szStringToAppendErrorTo will be overwritten with what is in the string resource and appended to the Windows Sockets Error description. | |
Protected Member Functions | |
void | GetErrorString () |
Convert the error code to string. | |
Protected Attributes | |
int | Error |
Error code. | |
size_t | SizeToAllocate |
Size to allocate for String. | |
tchar * | String |
Error code converted to string. | |
Friends | |
bool | operator== (const TSocketError &socketError1, const TSocketError &socketError2) |
This function tests for equality between two TSocketError objects. | |
TSocketError converts Windows Sockets errors to string messages.
This function constructs the object with the error code and the size of the buffer to allocate.
Definition at line 24 of file wskerr.cpp.
References GetErrorString().
|
virtual |
This function destroys the allocated string.
Definition at line 36 of file wskerr.cpp.
References String.
owl::TSocketError::TSocketError | ( | const TSocketError & | src | ) |
Copies the error code and string.
Definition at line 44 of file wskerr.cpp.
tchar * owl::TSocketError::AppendError | ( | const tchar * | stringToAppendErrorTo, |
tchar * | destination = 0 ) |
This function appends the error string to whatever is in the string 'stringToAppendErrorTo' and put the result in 'destination'.
You may want to put something specific about the error in the string and then use AppendError() to add the Winsock error code and description to it.
For example, you could say:
And AppendError() will put "\n\nWinsock Error 10057: Socket is not presently connected" after the "Unable to send you mail" string. Quite convenient.
If destination is valid, destination provides the space for the result.
Definition at line 122 of file wskerr.cpp.
References _T, _tcscpy, GetReasonString(), SizeToAllocate, and String.
tchar * owl::TSocketError::AppendError | ( | int | stringResourceToAppendErrorTo, |
tchar * | destination = 0 ) |
This function is similar to AppendError(char*, char*), but the pre-string comes from a string resource and szStringToAppendErrorTo will be overwritten with what is in the string resource and appended to the Windows Sockets Error description.
stringToAppendErrorTo must be able to hold at least 128 characters.
Definition at line 154 of file wskerr.cpp.
References AppendError().
|
protected |
Convert the error code to string.
This function gets a string, suitable for display, based on the nError value.
The previous string is deleted if necessary. Note that the string allocated must be at least 128 characters long. Even though the error strings you see don't have error numbers associated with them, the function prepends the error number to the szString before returning.
If you are writing string resources for the error strings, don't put error numbers in the string, because that will be done for you later.
Definition at line 170 of file wskerr.cpp.
References _T, COUNTOF, Error, SizeToAllocate, and String.
const tchar * owl::TSocketError::GetReasonString | ( | ) | const |
This function hands the pointer to the string to the caller.
The caller shouldn't alter this string (because it doesn't belong to the caller).
Definition at line 96 of file wskerr.cpp.
References String.
int owl::TSocketError::GetReasonValue | ( | ) | const |
This function initializes the error code.
Definition at line 78 of file wskerr.cpp.
References Error, and GetErrorString().
TSocketError & owl::TSocketError::operator= | ( | const TSocketError & | src | ) |
This function copies the error code and string.
Definition at line 55 of file wskerr.cpp.
References Error, SizeToAllocate, String, and strnewdup().
|
friend |
This function tests for equality between two TSocketError objects.
The important criteria for determining equality is the error value. The string is unimportant.
Definition at line 69 of file wskerr.cpp.
|
protected |
|
protected |