renamed ErrorCode to ErrorNumber wherever possible
substituted this->getMmgr()->reallocate() and this->getMmgr()->dispose() for QSE_MMGR_REALLOC() and QSE_MMGR_FREE() in TcpServer.cpp
This commit is contained in:
@ -223,9 +223,9 @@ public:
|
||||
|
||||
|
||||
/** defines common error codes */
|
||||
enum ErrorCode
|
||||
enum ErrorNumber
|
||||
{
|
||||
/* [NOTE] if you change items here, you must change the stock error description in ErrorGrab */
|
||||
/* [NOTE] if you change items here, you must change the stock error description in TypesErrorNumberToStr::operator() */
|
||||
|
||||
E_ENOERR, /**< no error */
|
||||
E_EOTHER, /**< other error */
|
||||
|
@ -33,17 +33,17 @@
|
||||
|
||||
QSE_BEGIN_NAMESPACE(QSE)
|
||||
|
||||
template <typename ERRCODE, typename ERRCODETOSTR, int MSGSZ>
|
||||
template <typename ERRNUM, typename ERRNUMTOSTR, int MSGSZ>
|
||||
class QSE_EXPORT ErrorGrab
|
||||
{
|
||||
public:
|
||||
ErrorGrab(): _errcode((ERRCODE)0)
|
||||
ErrorGrab(): _errnum((ERRNUM)0)
|
||||
{
|
||||
this->_errmsg[0] = QSE_T('\0');
|
||||
this->_errmsg_backup[0] = QSE_T('\0');
|
||||
}
|
||||
|
||||
ERRCODE getErrorCode () const QSE_CPP_NOEXCEPT { return this->_errcode; }
|
||||
ERRNUM getErrorNumber () const QSE_CPP_NOEXCEPT { return this->_errnum; }
|
||||
|
||||
const qse_char_t* getErrorMsg () const QSE_CPP_NOEXCEPT { return this->_errmsg; }
|
||||
const qse_char_t* backupErrorMsg () QSE_CPP_NOEXCEPT
|
||||
@ -52,41 +52,41 @@ public:
|
||||
return this->_errmsg_backup;
|
||||
}
|
||||
|
||||
void setErrorFmtv (ERRCODE errcode, const qse_char_t* fmt, va_list ap) QSE_CPP_NOEXCEPT
|
||||
void setErrorFmtv (ERRNUM errnum, const qse_char_t* fmt, va_list ap) QSE_CPP_NOEXCEPT
|
||||
{
|
||||
this->_errcode = errcode;
|
||||
this->_errnum = errnum;
|
||||
qse_strxvfmt (this->_errmsg, QSE_COUNTOF(this->_errmsg), fmt, ap);
|
||||
}
|
||||
|
||||
void setErrorFmt (ERRCODE errcode, const qse_char_t* fmt, ...) QSE_CPP_NOEXCEPT
|
||||
void setErrorFmt (ERRNUM errnum, const qse_char_t* fmt, ...) QSE_CPP_NOEXCEPT
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
this->setErrorFmtv (errcode, fmt, ap);
|
||||
this->setErrorFmtv (errnum, fmt, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
void setErrorCode (ERRCODE errcode)
|
||||
void setErrorNumber (ERRNUM errnum)
|
||||
{
|
||||
this->_errcode = errcode;
|
||||
qse_strxcpy (this->_errmsg, QSE_COUNTOF(this->_errmsg), this->_errtostr(errcode));
|
||||
this->_errnum = errnum;
|
||||
qse_strxcpy (this->_errmsg, QSE_COUNTOF(this->_errmsg), this->_errtostr(errnum));
|
||||
}
|
||||
|
||||
private:
|
||||
ERRCODE _errcode;
|
||||
ERRCODETOSTR _errtostr;
|
||||
ERRNUM _errnum;
|
||||
ERRNUMTOSTR _errtostr;
|
||||
qse_char_t _errmsg_backup[MSGSZ];
|
||||
qse_char_t _errmsg[MSGSZ];
|
||||
};
|
||||
|
||||
// the stock functor class to convert the Types::ErrorCode to a string
|
||||
struct TypesErrorCodeToStr
|
||||
// the stock functor class to convert the Types::ErrorNumber to a string
|
||||
struct TypesErrorNumberToStr
|
||||
{
|
||||
const qse_char_t* operator() (Types::ErrorCode errcode);
|
||||
const qse_char_t* operator() (Types::ErrorNumber errnum);
|
||||
};
|
||||
|
||||
typedef ErrorGrab<Types::ErrorCode, TypesErrorCodeToStr, 128> ErrorGrab128;
|
||||
typedef ErrorGrab<Types::ErrorCode, TypesErrorCodeToStr, 256> ErrorGrab256;
|
||||
typedef ErrorGrab<Types::ErrorNumber, TypesErrorNumberToStr, 128> ErrorGrab128;
|
||||
typedef ErrorGrab<Types::ErrorNumber, TypesErrorNumberToStr, 256> ErrorGrab256;
|
||||
|
||||
QSE_END_NAMESPACE(QSE)
|
||||
|
||||
|
@ -50,8 +50,8 @@ public:
|
||||
Socket () QSE_CPP_NOEXCEPT;
|
||||
virtual ~Socket () QSE_CPP_NOEXCEPT;
|
||||
|
||||
ErrorCode getErrorCode () const QSE_CPP_NOEXCEPT { return this->errcode; }
|
||||
void setErrorCode (ErrorCode errcode) QSE_CPP_NOEXCEPT { this->errcode = errcode; }
|
||||
ErrorNumber getErrorNumber () const QSE_CPP_NOEXCEPT { return this->errcode; }
|
||||
void setErrorNumber (ErrorNumber errcode) QSE_CPP_NOEXCEPT { this->errcode = errcode; }
|
||||
|
||||
int open (int domain, int type, int protocol, int traits = 0) QSE_CPP_NOEXCEPT;
|
||||
void close () QSE_CPP_NOEXCEPT;
|
||||
@ -161,7 +161,7 @@ public:
|
||||
protected:
|
||||
qse_sck_hnd_t handle;
|
||||
int domain;
|
||||
ErrorCode errcode;
|
||||
ErrorNumber errcode;
|
||||
|
||||
void set_errcode_with_syserr (int syserr);
|
||||
int get_ifce_index (const void* name, qse_size_t len, bool wchar);
|
||||
|
@ -355,7 +355,7 @@ public:
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
this->setErrorCode (E_ENOMEM);
|
||||
this->setErrorNumber (E_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -390,7 +390,7 @@ private:
|
||||
{
|
||||
if (!this->__lfunc)
|
||||
{
|
||||
//this->setErrorCode (TcpServer::E_ENOMEM or E_EINVAL??);
|
||||
//this->setErrorNumber (TcpServer::E_ENOMEM or E_EINVAL??);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ QSE_BEGIN_NAMESPACE(QSE)
|
||||
class Sttp: public Mmged, public Uncopyable
|
||||
{
|
||||
public:
|
||||
enum ErrorCode
|
||||
enum ErrorNumber
|
||||
{
|
||||
E_NOERR = 0,
|
||||
E_MEMORY,
|
||||
@ -53,8 +53,7 @@ public:
|
||||
E_SEMICOLON,
|
||||
E_TOOMANYARGS,
|
||||
E_WRONGARG,
|
||||
E_WRONGCHAR,
|
||||
__NERRCODES__
|
||||
E_WRONGCHAR
|
||||
};
|
||||
|
||||
Sttp (Transmittable* s = QSE_NULL, Mmgr* mmgr = QSE_NULL) QSE_CPP_NOEXCEPT;
|
||||
@ -89,7 +88,7 @@ public:
|
||||
this->opt_send_newline = opt;
|
||||
}
|
||||
|
||||
int getErrorCode() const QSE_CPP_NOEXCEPT
|
||||
int getErrorNumber() const QSE_CPP_NOEXCEPT
|
||||
{
|
||||
return this->p_errcode;
|
||||
}
|
||||
@ -105,8 +104,8 @@ public:
|
||||
// Socket sck;
|
||||
// Sttp sttp(sck);
|
||||
// if (sttp->receiveCmd(&cmd) <= -1 &&
|
||||
// sttp->getErrorCode() == Sttp::E_RECEIVE &&
|
||||
// sck->getErrorCode() == Socket::E_EAGAIN) { ... }
|
||||
// sttp->getErrorNumber() == Sttp::E_RECEIVE &&
|
||||
// sck->getErrorNumber() == Socket::E_EAGAIN) { ... }
|
||||
// \endcode
|
||||
//
|
||||
// \return 1 if a command is received. 0 if end of input is detected
|
||||
@ -120,7 +119,7 @@ public:
|
||||
|
||||
const qse_char_t* getErrorStr () const QSE_CPP_NOEXCEPT;
|
||||
|
||||
void setErrorCode (int code) QSE_CPP_NOEXCEPT
|
||||
void setErrorNumber (int code) QSE_CPP_NOEXCEPT
|
||||
{
|
||||
this->p_errcode = code;
|
||||
}
|
||||
@ -145,7 +144,7 @@ protected:
|
||||
};
|
||||
|
||||
Transmittable* p_medium;
|
||||
int p_errcode; /* ErrorCode */
|
||||
int p_errcode; /* ErrorNumber */
|
||||
|
||||
qse_mchar_t inbuf [MAX_INBUF_LEN];
|
||||
qse_mchar_t outbuf[MAX_OUTBUF_LEN];
|
||||
|
Reference in New Issue
Block a user