added partial code for cut

This commit is contained in:
2009-10-05 08:08:27 +00:00
parent 22394802f8
commit 6de11d0391
20 changed files with 1806 additions and 24 deletions

View File

@ -1,5 +1,5 @@
# EXTRA_DIST =
SUBDIRS = cmn sed awk lsp utl
SUBDIRS = cmn sed awk cut lsp utl
pkgincludedir = $(includedir)/qse

View File

@ -211,7 +211,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
# EXTRA_DIST =
SUBDIRS = cmn sed awk lsp utl
SUBDIRS = cmn sed awk cut lsp utl
pkginclude_HEADERS = config.h conf_msw.h conf_vms.h types.h macros.h \
pack1.h unpack.h $(am__append_1)
all: config.h

View File

@ -0,0 +1,8 @@
pkgincludedir= $(includedir)/qse/cut
pkginclude_HEADERS = cut.h
#if ENABLE_CXX
#pkginclude_HEADERS += Cut.hpp StdCut.hpp
#endif

View File

@ -0,0 +1,435 @@
# Makefile.in generated by automake 1.10.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = include/qse/cut
DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/ac/m4/libtool.m4 \
$(top_srcdir)/ac/m4/ltoptions.m4 \
$(top_srcdir)/ac/m4/ltsugar.m4 \
$(top_srcdir)/ac/m4/ltversion.m4 \
$(top_srcdir)/ac/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(pkgincludedir)"
pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(pkginclude_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
pkgincludedir = $(includedir)/qse/cut
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_MODE = @BUILD_MODE@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CHAR_MODE = @CHAR_MODE@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
HAVE_CXX = @HAVE_CXX@
HAVE_OBJC = @HAVE_OBJC@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJC = @OBJC@
OBJCDEPMODE = @OBJCDEPMODE@
OBJCFLAGS = @OBJCFLAGS@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
QSE_SIZEOF_CHAR = @QSE_SIZEOF_CHAR@
QSE_SIZEOF_DOUBLE = @QSE_SIZEOF_DOUBLE@
QSE_SIZEOF_FLOAT = @QSE_SIZEOF_FLOAT@
QSE_SIZEOF_INT = @QSE_SIZEOF_INT@
QSE_SIZEOF_LONG = @QSE_SIZEOF_LONG@
QSE_SIZEOF_LONG_DOUBLE = @QSE_SIZEOF_LONG_DOUBLE@
QSE_SIZEOF_LONG_LONG = @QSE_SIZEOF_LONG_LONG@
QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@
QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@
QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@
RANLIB = @RANLIB@
RM = @RM@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
ac_ct_OBJC = @ac_ct_OBJC@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
pkginclude_HEADERS = cut.h
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/qse/cut/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign include/qse/cut/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*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);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-pkgincludeHEADERS: $(pkginclude_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)"
@list='$(pkginclude_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \
$(pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \
done
uninstall-pkgincludeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(pkginclude_HEADERS)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \
rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(pkgincludedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-pkgincludeHEADERS
install-dvi: install-dvi-am
install-exec-am:
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-pkgincludeHEADERS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool ctags distclean distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-pkgincludeHEADERS install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-pkgincludeHEADERS
#if ENABLE_CXX
#pkginclude_HEADERS += Cut.hpp StdCut.hpp
#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:

330
qse/include/qse/cut/cut.h Normal file
View File

@ -0,0 +1,330 @@
/*
* $Id: cut.h 287 2009-09-15 10:01:02Z 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_CUT_CUT_H_
#define _QSE_CUT_CUT_H_
#include <qse/types.h>
#include <qse/macros.h>
#include <qse/cmn/str.h>
/** @file
* cut utility
*/
/** @struct qse_cut_t
*/
typedef struct qse_cut_t qse_cut_t;
/**
* the qse_cut_errnum_t type defines error numbers.
*/
enum qse_cut_errnum_t
{
QSE_CUT_ENOERR, /**< no error */
QSE_CUT_ENOMEM, /**< insufficient memory */
QSE_CUT_ESELNV, /**< selector not valid */
QSE_CUT_EREXIC, /**< regular expression '${0}' incomplete */
QSE_CUT_EREXBL, /**< failed to compile regular expression '${0}' */
QSE_CUT_EREXMA, /**< failed to match regular expression */
QSE_CUT_EA1PHB, /**< address 1 prohibited for '${0}' */
QSE_CUT_EA2PHB, /**< address 2 prohibited */
QSE_CUT_EA2MOI, /**< address 2 missing or invalid */
QSE_CUT_ENEWLN, /**< newline expected */
QSE_CUT_EBSEXP, /**< backslash expected */
QSE_CUT_EBSDEL, /**< backslash used as delimiter */
QSE_CUT_EGBABS, /**< garbage after backslash */
QSE_CUT_ESCEXP, /**< semicolon expected */
QSE_CUT_ELABEM, /**< empty label name */
QSE_CUT_ELABDU, /**< duplicate label name '${0}' */
QSE_CUT_ELABNF, /**< label '${0}' not found */
QSE_CUT_EFILEM, /**< empty file name */
QSE_CUT_EFILIL, /**< illegal file name */
QSE_CUT_ETSNSL, /**< strings in translation set not the same length*/
QSE_CUT_EGRNBA, /**< group brackets not balanced */
QSE_CUT_EGRNTD, /**< group nesting too deep */
QSE_CUT_EOCSDU, /**< multiple occurrence specifiers */
QSE_CUT_EOCSZE, /**< occurrence specifier zero */
QSE_CUT_EOCSTL, /**< occurrence specifier too large */
QSE_CUT_EIOFIL, /**< io error with file '${0}'*/
QSE_CUT_EIOUSR /**< error returned by user io handler */
};
typedef enum qse_cut_errnum_t qse_cut_errnum_t;
/**
* The qse_cut_errstr_t type defines a error string getter. It should return
* an error formatting string for an error number requested. A new string
* should contain the same number of positional parameters (${X}) as in the
* default error formatting string. You can set a new getter into a stream
* editor with the qse_cut_seterrstr() function to customize an error string.
*/
typedef const qse_char_t* (*qse_cut_errstr_t) (
qse_cut_t* sed, /**< stream editor */
qse_cut_errnum_t num /**< an error number */
);
/**
* The qse_cut_option_t type defines various option codes for a stream editor.
* Options can be OR'ed with each other and be passed to a stream editor with
* the qse_cut_setoption() function.
*/
enum qse_cut_option_t
{
QSE_CUT_STRIPLS = (1 << 0), /**< strip leading spaces from text */
QSE_CUT_KEEPTBS = (1 << 1), /**< keep an trailing backslash */
QSE_CUT_ENSURENL = (1 << 2), /**< ensure NL at the text end */
QSE_CUT_QUIET = (1 << 3), /**< do not print pattern space */
QSE_CUT_STRICT = (1 << 4), /**< do strict address check */
QSE_CUT_STARTSTEP = (1 << 5), /**< allow start~step */
QSE_CUT_REXBOUND = (1 << 6), /**< allow {n,m} in regular expression */
QSE_CUT_SAMELINE = (1 << 7), /**< allow text on the same line as c, a, i */
};
typedef enum qse_cut_option_t qse_cut_option_t;
/**
* The qse_cut_depth_t type defines IDs for qse_cut_getmaxdepth() and
* qse_cut_setmaxdepth().
*/
enum qse_cut_depth_t
{
QSE_CUT_DEPTH_REX_BUILD = (1 << 0),
QSE_CUT_DEPTH_REX_MATCH = (1 << 1)
};
typedef enum qse_cut_depth_t qse_cut_depth_t;
/**
* The qse_cut_io_cmd_t type defines IO command codes. The code indicates
* the action to take in an IO handler.
*/
enum qse_cut_io_cmd_t
{
QSE_CUT_IO_OPEN = 0,
QSE_CUT_IO_CLOSE = 1,
QSE_CUT_IO_READ = 2,
QSE_CUT_IO_WRITE = 3
};
typedef enum qse_cut_io_cmd_t qse_cut_io_cmd_t;
/**
* The qse_cut_io_arg_t type defines a data structure required by an IO handler.
*/
struct qse_cut_io_arg_t
{
void* handle; /**< IO handle */
const qse_char_t* path; /**< file path. QSE_NULL for a console */
};
typedef struct qse_cut_io_arg_t qse_cut_io_arg_t;
/**
* The qse_cut_io_fun_t type defines an IO handler. An IO handler is called by
* qse_cut_exec().
*/
typedef qse_ssize_t (*qse_cut_io_fun_t) (
qse_cut_t* sed,
qse_cut_io_cmd_t cmd,
qse_cut_io_arg_t* arg,
qse_char_t* data,
qse_size_t count
);
#ifdef __cplusplus
extern "C" {
#endif
QSE_DEFINE_COMMON_FUNCTIONS (cut)
/**
* The qse_cut_open() function creates a stream editor object. A memory
* manager provided is used to allocate and destory the object and any dynamic
* data through out its lifetime. An extension area is allocated if an
* extension size greater than 0 is specified. You can access it with the
* qse_cut_getxtn() function and use it to store arbitrary data associated
* with the object. See #QSE_DEFINE_COMMON_FUNCTIONS() for qse_cut_getxtn().
* When done, you should destroy the object with the qse_cut_close() function
* to avoid any resource leaks including memory.
* @return A pointer to a stream editor on success, QSE_NULL on failure
*/
qse_cut_t* qse_cut_open (
qse_mmgr_t* mmgr, /**< a memory manager */
qse_size_t xtn /**< the size of extension in bytes */
);
/**
* The qse_cut_close() function destroys a stream editor.
*/
void qse_cut_close (
qse_cut_t* cut /**< stream editor */
);
/**
* The qse_cut_getoption() function retrieves the current options set in
* a stream editor.
* @return 0 or a number OR'ed of #qse_cut_option_t values
*/
int qse_cut_getoption (
qse_cut_t* cut /**< stream editor */
);
/**
* The qse_cut_setoption() function sets the option code.
*/
void qse_cut_setoption (
qse_cut_t* cut, /**< stream editor */
int opt /**< 0 or a number OR'ed of #qse_cut_option_t values */
);
/**
* The qse_cut_getmaxdepth() gets the maximum processing depth.
*/
qse_size_t qse_cut_getmaxdepth (
qse_cut_t* cut, /**< stream editor */
qse_cut_depth_t id /**< one of qse_cut_depth_t values */
);
/**
* The qse_cut_setmaxdepth() sets the maximum processing depth.
*/
void qse_cut_setmaxdepth (
qse_cut_t* cut, /**< stream editor */
int ids, /**< 0 or a number OR'ed of #qse_cut_depth_t values */
qse_size_t depth /**< maximum depth level */
);
/**
* The qse_cut_geterrstr() gets an error string getter.
*/
qse_cut_errstr_t qse_cut_geterrstr (
qse_cut_t* cut /**< stream editor */
);
/**
* The qse_cut_seterrstr() sets an error string getter that is called to
* compose an error message when its retrieval is requested.
*
* Here is an example of changing the formatting string for the #QSE_CUT_ECMDNR
* error.
* @code
* qse_cut_errstr_t orgerrstr;
*
* const qse_char_t* myerrstr (qse_cut_t* cut, qse_cut_errnum_t num)
* {
* if (num == QSE_CUT_ECMDNR) return QSE_T("unrecognized command ${0}");
* return orgerrstr (cut, num);
* }
* int main ()
* {
* qse_cut_t* cut;
* ...
* orgerrstr = qse_cut_geterrstr (cut);
* qse_cut_seterrstr (cut, myerrstr);
* ...
* }
* @endcode
*/
void qse_cut_seterrstr (
qse_cut_t* cut, /**< stream editor */
qse_cut_errstr_t errstr /**< an error string getter */
);
/**
* The qse_cut_geterrnum() function gets the number of the last error.
* @return the number of the last error
*/
qse_cut_errnum_t qse_cut_geterrnum (
qse_cut_t* cut /**< stream editor */
);
/**
* The qse_cut_geterrmsg() function gets a string describing the last error.
* @return a pointer to an error message
*/
const qse_char_t* qse_cut_geterrmsg (
qse_cut_t* cut /**< stream editor */
);
/**
* The qse_cut_geterror() function gets an error number, an error location,
* and an error message. The information is set to the memory area pointed
* to by each parameter.
*/
void qse_cut_geterror (
qse_cut_t* cut, /**< stream editor */
qse_cut_errnum_t* errnum, /**< error number */
const qse_char_t** errmsg /**< error message */
);
/**
* The qse_cut_seterrnum() function sets error information omitting error
* location.
*/
void qse_cut_seterrnum (
qse_cut_t* cut, /**< stream editor */
qse_cut_errnum_t errnum, /**< error number */
const qse_cstr_t* errarg /**< argument for formatting error message */
);
/**
* The qse_cut_seterrmsg() function sets error information with a customized
* message for a given error number.
*/
void qse_cut_seterrmsg (
qse_cut_t* cut, /**< stream editor */
qse_cut_errnum_t errnum, /**< error number */
const qse_char_t* errmsg /**< error message */
);
/**
* The qse_cut_seterror() function sets an error number, an error location, and
* an error message. An error string is composed of a formatting string
* and an array of formatting parameters.
*/
void qse_cut_seterror (
qse_cut_t* cut, /**< stream editor */
qse_cut_errnum_t errnum, /**< error number */
const qse_cstr_t* errarg /**< array of arguments for formatting
* an error message */
);
/**
* The qse_cut_comp() function compiles a selector into an internal form.
* @return 0 on success, -1 on error
*/
int qse_cut_comp (
qse_cut_t* cut, /**< stream editor */
const qse_char_t* ptr, /**< pointer to a string containing commands */
qse_size_t len /**< the number of characters in the string */
);
/**
* The qse_cut_exec() function executes the compiled commands.
* @return 0 on success, -1 on error
*/
int qse_cut_exec (
qse_cut_t* cut, /**< stream editor */
qse_cut_io_fun_t inf, /**< stream reader */
qse_cut_io_fun_t outf /**< stream writer */
);
#ifdef __cplusplus
}
#endif
#endif