- Changed the way Mmgr is used. A subclass inheriting Mmged is instantiated with a pointer to Mmgr which used to be the parent class.

- Separated the I/O stream handler from the Sed class and abstracted it into Sed::IOStream.
- Implemented StdSed::StdStream.
This commit is contained in:
2009-12-19 06:34:42 +00:00
parent 232c0cc1c4
commit de7082d0d0
31 changed files with 944 additions and 630 deletions

View File

@ -3,9 +3,9 @@ pkgincludedir = $(includedir)/qse/cmn
pkginclude_HEADERS = \
mem.h chr.h str.h lda.h map.h \
rex.h sll.h dll.h opt.h tio.h \
fio.h pio.h sio.h time.h misc.h main.h stdio.h
fio.h pio.h sio.h time.h misc.h main.h stdio.h
#if ENABLE_CXX
#pkginclude_HEADERS +=
#endif
if ENABLE_CXX
pkginclude_HEADERS += Mmgr.hpp StdMmgr.hpp Mmged.hpp
endif

View File

@ -33,8 +33,9 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
@ENABLE_CXX_TRUE@am__append_1 = Mmgr.hpp StdMmgr.hpp Mmged.hpp
subdir = include/qse/cmn
DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \
DIST_COMMON = $(am__pkginclude_HEADERS_DIST) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/ac/m4/libtool.m4 \
@ -50,6 +51,9 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
DIST_SOURCES =
am__pkginclude_HEADERS_DIST = mem.h chr.h str.h lda.h map.h rex.h \
sll.h dll.h opt.h tio.h fio.h pio.h sio.h time.h misc.h main.h \
stdio.h Mmgr.hpp StdMmgr.hpp Mmged.hpp
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@ -216,11 +220,9 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
pkginclude_HEADERS = \
mem.h chr.h str.h lda.h map.h \
rex.h sll.h dll.h opt.h tio.h \
fio.h pio.h sio.h time.h misc.h main.h stdio.h
pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h \
opt.h tio.h fio.h pio.h sio.h time.h misc.h main.h stdio.h \
$(am__append_1)
all: all-am
.SUFFIXES:
@ -477,10 +479,6 @@ uninstall-am: uninstall-pkgincludeHEADERS
tags uninstall uninstall-am uninstall-pkgincludeHEADERS
#if ENABLE_CXX
#pkginclude_HEADERS +=
#endif
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,54 @@
/*
* $Id: Sed.hpp 127 2009-05-07 13:15:04Z baconevi $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
QSE is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
QSE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _QSE_CMN_MMGED_HPP_
#define _QSE_CMN_MMGED_HPP_
#include <qse/Types.hpp>
#include <qse/cmn/Mmgr.hpp>
/////////////////////////////////
QSE_BEGIN_NAMESPACE(QSE)
/////////////////////////////////
///
/// The Mmged class defines a memory manager interface to be inherited by
/// a subclass that uses a memory manager.
///
class Mmged: public Types
{
public:
Mmged (Mmgr* mmgr): mmgr (mmgr) {}
///
/// The getMmgr() function returns the memory manager associated.
///
Mmgr* getMmgr () const { return mmgr; }
protected:
Mmgr* mmgr;
};
/////////////////////////////////
QSE_END_NAMESPACE(QSE)
/////////////////////////////////
#endif

View File

@ -0,0 +1,110 @@
/*
* $Id: Sed.hpp 127 2009-05-07 13:15:04Z baconevi $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
QSE is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
QSE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _QSE_CMN_MMGR_HPP_
#define _QSE_CMN_MMGR_HPP_
#include <qse/Types.hpp>
/////////////////////////////////
QSE_BEGIN_NAMESPACE(QSE)
/////////////////////////////////
///
/// The Mmgr class defines a memory manager interface that can be inherited
/// by a class in need of a memory manager as defined in the primitive
/// #qse_mmgr_t type. Using the class over the primitive type enables you to
/// write code in more object-oriented fashion. An inheriting class should
/// implement three pure virtual functions.
///
class Mmgr: public Types, public qse_mmgr_t
{
public:
/// defines an alias type to #qse_mmgr_t
typedef qse_mmgr_t mmgr_t;
///
/// The Mmgr() function builds a memory manager composed of bridge
/// functions connecting itself with it.
///
Mmgr ()
{
this->alloc = alloc_mem;
this->realloc = realloc_mem;
this->free = free_mem;
this->udd = this;
}
///
/// The ~Mmgr() function finalizes a memory manager.
///
virtual ~Mmgr () {}
protected:
///
/// The allocMem() function allocates a chunk of memory of the
/// size @a n and return the pointer to the beginning of the chunk.
/// If it fails to allocate memory, it should return QSE_NULL.
///
virtual void* allocMem (
size_t n ///< size of memory chunk to allocate in bytes
) = 0;
///
/// The reallocMem() function resizes a chunk of memory previously
/// allocated with the allocMem() function. When resized, the contents
/// of the surviving part of a memory chunk is preserved. If it fails to
/// resize memory, it should return QSE_NULL.
///
virtual void* reallocMem (
void* ptr, ///< pointer to memory chunk to resize
size_t n ///< new size in bytes
) = 0;
///
/// The freeMem() function frees a chunk of memory allocated with
/// the allocMem() function or resized with the reallocMem() function.
///
virtual void freeMem (
void* ptr ///< pointer to memory chunk to free
) = 0;
protected:
///
/// bridge function from the #qse_mmgr_t type the allocMem() function.
///
static void* alloc_mem (void* udd, size_t n);
///
/// bridge function from the #qse_mmgr_t type the reallocMem() function.
///
static void* realloc_mem (void* udd, void* ptr, size_t n);
///
/// bridge function from the #qse_mmgr_t type the freeMem() function.
///
static void free_mem (void* udd, void* ptr);
};
/////////////////////////////////
QSE_END_NAMESPACE(QSE)
/////////////////////////////////
#endif

View File

@ -0,0 +1,45 @@
/*
* $Id: Sed.hpp 127 2009-05-07 13:15:04Z baconevi $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
QSE is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
QSE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _QSE_CMN_STDMMGR_HPP_
#define _QSE_CMN_STDMMGR_HPP_
#include <qse/cmn/Mmgr.hpp>
/////////////////////////////////
QSE_BEGIN_NAMESPACE(QSE)
/////////////////////////////////
class StdMmgr: public Mmgr
{
public:
void* allocMem (size_t n);
void* reallocMem (void* ptr, size_t n);
virtual void freeMem (void* ptr);
public:
static StdMmgr DFL;
};
/////////////////////////////////
QSE_END_NAMESPACE(QSE)
/////////////////////////////////
#endif

View File

@ -30,10 +30,18 @@
*/
/**
* The #qse_main macro defines a main function wrapper for an underlying
* platform. Combined with the qse_runmain() function, it provides a consistant
* view to the main function.
* @def qse_main
* The qse_main macro defines a main function wrapper for an underlying
* platform. It is defined to @b main or @b wmain depending on the choice of
* the default character type #qse_char_t. Combined with the qse_runmain()
* function, it provides a consistant view to the main function.
*
* @typedef qse_achar_t
* The qse_achar_t type defines a character type for the second parameter to
* #qse_main. It is defined to #qse_mchar_t or #qse_wchar_t depending on the
* choice of the default character type #qse_char_t.
*/
#if defined(_WIN32) && !defined(__MINGW32__)
# if defined(QSE_CHAR_IS_MCHAR)
# define qse_main main

View File

@ -1,5 +1,5 @@
/*
* $Id: sio.h 287 2009-09-15 10:01:02Z hyunghwan.chung $
* $Id: sio.h 318 2009-12-18 12:34:42Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -21,6 +21,10 @@
#ifndef _QSE_CMN_SIO_H_
#define _QSE_CMN_SIO_H_
/** @file
* This file defines a simple stream I/O interface.
*/
#include <qse/types.h>
#include <qse/macros.h>
#include <qse/cmn/fio.h>