added ErrorGrab and used it in TcpServer
This commit is contained in:
78
qse/include/qse/cmn/ErrorGrab.hpp
Normal file
78
qse/include/qse/cmn/ErrorGrab.hpp
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_CMN_ERRORGRAB_CLASS_
|
||||
#define _QSE_CMN_ERRORGRAB_CLASS_
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <qse/Types.hpp>
|
||||
#include <qse/cmn/str.h>
|
||||
|
||||
QSE_BEGIN_NAMESPACE(QSE)
|
||||
|
||||
class QSE_EXPORT ErrorGrab
|
||||
{
|
||||
public:
|
||||
ErrorGrab(): _errcode(Types::E_ENOERR)
|
||||
{
|
||||
this->_errmsg[0] = QSE_T('\0');
|
||||
this->_errmsg_backup[0] = QSE_T('\0');
|
||||
}
|
||||
|
||||
Types::ErrorCode getErrorCode () const QSE_CPP_NOEXCEPT { return this->_errcode; }
|
||||
|
||||
const qse_char_t* getErrorMsg () const QSE_CPP_NOEXCEPT { return this->_errmsg; }
|
||||
const qse_char_t* backupErrorMsg () QSE_CPP_NOEXCEPT
|
||||
{
|
||||
qse_strcpy (this->_errmsg_backup, this->_errmsg);
|
||||
return this->_errmsg_backup;
|
||||
}
|
||||
|
||||
void setErrorFmtv (Types::ErrorCode errcode, const qse_char_t* fmt, va_list ap) QSE_CPP_NOEXCEPT
|
||||
{
|
||||
this->_errcode = errcode;
|
||||
qse_strxvfmt (this->_errmsg, QSE_COUNTOF(this->_errmsg), fmt, ap);
|
||||
}
|
||||
|
||||
void setErrorFmt (Types::ErrorCode errcode, const qse_char_t* fmt, ...) QSE_CPP_NOEXCEPT
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
this->setErrorFmtv (errcode, fmt, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
void setErrorCode (Types::ErrorCode errcode);
|
||||
|
||||
private:
|
||||
Types::ErrorCode _errcode;
|
||||
qse_char_t _errmsg_backup[256];
|
||||
qse_char_t _errmsg[256];
|
||||
};
|
||||
|
||||
QSE_END_NAMESPACE(QSE)
|
||||
|
||||
#endif
|
@ -45,6 +45,7 @@ pkginclude_HEADERS += \
|
||||
Association.hpp \
|
||||
BinaryHeap.hpp \
|
||||
Bitset.hpp \
|
||||
ErrorGrab.hpp \
|
||||
HashList.hpp \
|
||||
HashTable.hpp \
|
||||
HeapMmgr.hpp \
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.15 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -92,6 +92,7 @@ host_triplet = @host@
|
||||
@ENABLE_CXX_TRUE@ Association.hpp \
|
||||
@ENABLE_CXX_TRUE@ BinaryHeap.hpp \
|
||||
@ENABLE_CXX_TRUE@ Bitset.hpp \
|
||||
@ENABLE_CXX_TRUE@ ErrorGrab.hpp \
|
||||
@ENABLE_CXX_TRUE@ HashList.hpp \
|
||||
@ENABLE_CXX_TRUE@ HashTable.hpp \
|
||||
@ENABLE_CXX_TRUE@ HeapMmgr.hpp \
|
||||
@ -150,10 +151,11 @@ am__pkginclude_HEADERS_DIST = alg.h arr.h chr.h cp949.h cp950.h dll.h \
|
||||
main.h map.h mb8.h mbwc.h mem.h oht.h opt.h path.h pma.h rbt.h \
|
||||
rex.h sll.h slmb.h str.h time.h tmr.h tre.h test.h uni.h uri.h \
|
||||
utf8.h xma.h Array.hpp Association.hpp BinaryHeap.hpp \
|
||||
Bitset.hpp HashList.hpp HashTable.hpp HeapMmgr.hpp \
|
||||
LinkedList.hpp Mmged.hpp Mmgr.hpp Mpool.hpp Named.hpp \
|
||||
RedBlackTree.hpp RedBlackTable.hpp ScopedPtr.hpp SharedPtr.hpp \
|
||||
StrBase.hpp String.hpp StdMmgr.hpp Transmittable.hpp
|
||||
Bitset.hpp ErrorGrab.hpp HashList.hpp HashTable.hpp \
|
||||
HeapMmgr.hpp LinkedList.hpp Mmged.hpp Mmgr.hpp Mpool.hpp \
|
||||
Named.hpp RedBlackTree.hpp RedBlackTable.hpp ScopedPtr.hpp \
|
||||
SharedPtr.hpp StrBase.hpp String.hpp StdMmgr.hpp \
|
||||
Transmittable.hpp
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
@ -362,7 +364,6 @@ pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
@ -396,8 +397,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
@ -488,7 +489,10 @@ cscopelist-am: $(am__tagged_files)
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
distdir-am: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
|
Reference in New Issue
Block a user