From b12e3f401615a2b692b205d6da43d03b55ab75a0 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 14 Jun 2019 01:05:38 +0000 Subject: [PATCH] made ErrorGrab a template class --- qse/include/qse/cmn/ErrorGrab.hpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/qse/include/qse/cmn/ErrorGrab.hpp b/qse/include/qse/cmn/ErrorGrab.hpp index ad1b671e..5fb907ca 100644 --- a/qse/include/qse/cmn/ErrorGrab.hpp +++ b/qse/include/qse/cmn/ErrorGrab.hpp @@ -33,7 +33,7 @@ QSE_BEGIN_NAMESPACE(QSE) -template +template class QSE_EXPORT ErrorGrab { public: @@ -66,16 +66,27 @@ public: va_end (ap); } - void setErrorCode (ERRCODE errcode); + void setErrorCode (ERRCODE errcode) + { + this->_errcode = errcode; + qse_strxcpy (this->_errmsg, QSE_COUNTOF(this->_errmsg), this->_errtostr(errcode)); + } private: ERRCODE _errcode; + ERRCODETOSTR _errtostr; qse_char_t _errmsg_backup[MSGSZ]; qse_char_t _errmsg[MSGSZ]; }; -typedef ErrorGrab ErrorGrab128; -typedef ErrorGrab ErrorGrab256; +// the stock functor class to convert the Types::ErrorCode to a string +struct TypesErrorCodeToStr +{ + const qse_char_t* operator() (Types::ErrorCode errcode); +}; + +typedef ErrorGrab ErrorGrab128; +typedef ErrorGrab ErrorGrab256; QSE_END_NAMESPACE(QSE)