removed qse_ccls_t and related functions and added qse_strtrm()
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.hpp 75 2009-02-22 14:10:34Z hyunghwan.chung $
|
||||
* $Id: Awk.hpp 127 2009-05-07 13:15:04Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -54,7 +54,6 @@ public:
|
||||
typedef qse_map_pair_t pair_t;
|
||||
|
||||
typedef qse_mmgr_t mmgr_t;
|
||||
typedef qse_ccls_t ccls_t;
|
||||
|
||||
/** Represents an internal awk value */
|
||||
typedef qse_awk_val_t val_t;
|
||||
@ -68,21 +67,6 @@ public:
|
||||
/** Represents an runtime I/O data */
|
||||
typedef qse_awk_riod_t riod_t;
|
||||
|
||||
enum ccls_id_t
|
||||
{
|
||||
CCLS_UPPER = QSE_CCLS_UPPER,
|
||||
CCLS_LOWER = QSE_CCLS_LOWER,
|
||||
CCLS_ALPHA = QSE_CCLS_ALPHA,
|
||||
CCLS_DIGIT = QSE_CCLS_DIGIT,
|
||||
CCLS_XDIGIT = QSE_CCLS_XDIGIT,
|
||||
CCLS_ALNUM = QSE_CCLS_ALNUM,
|
||||
CCLS_SPACE = QSE_CCLS_SPACE,
|
||||
CCLS_PRINT = QSE_CCLS_PRINT,
|
||||
CCLS_GRAPH = QSE_CCLS_GRAPH,
|
||||
CCLS_CNTRL = QSE_CCLS_CNTRL,
|
||||
CCLS_PUNCT = QSE_CCLS_PUNCT
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents the source code I/O context for Awk::parse.
|
||||
* An instance of Awk::Source is passed to Awk::openSource,
|
||||
@ -774,16 +758,6 @@ public:
|
||||
return qse_awk_getmmgr (awk);
|
||||
}
|
||||
|
||||
ccls_t* getCcls()
|
||||
{
|
||||
return qse_awk_getccls (awk);
|
||||
}
|
||||
|
||||
const ccls_t* getCcls() const
|
||||
{
|
||||
return qse_awk_getccls (awk);
|
||||
}
|
||||
|
||||
protected:
|
||||
void setError (ErrorCode code);
|
||||
void setError (ErrorCode code, size_t line);
|
||||
@ -1052,9 +1026,6 @@ protected:
|
||||
virtual void* reallocMem (void* ptr, size_t n) = 0;
|
||||
virtual void freeMem (void* ptr) = 0;
|
||||
|
||||
virtual bool_t isType (cint_t c, ccls_id_t type) = 0;
|
||||
virtual cint_t transCase (cint_t c, ccls_id_t type) = 0;
|
||||
|
||||
virtual real_t pow (real_t x, real_t y) = 0;
|
||||
virtual int vsprintf (char_t* buf, size_t size,
|
||||
const char_t* fmt, va_list arg) = 0;
|
||||
@ -1087,9 +1058,6 @@ protected:
|
||||
static void* reallocMem (void* data, void* ptr, size_t n);
|
||||
static void freeMem (void* data, void* ptr);
|
||||
|
||||
static bool_t isType (awk_t* awk, cint_t c, qse_ccls_id_t type);
|
||||
static cint_t transCase (awk_t* awk, cint_t c, qse_ccls_id_t type);
|
||||
|
||||
static real_t pow (awk_t* data, real_t x, real_t y);
|
||||
static int sprintf (awk_t* data, char_t* buf, size_t size,
|
||||
const char_t* fmt, ...);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: StdAwk.hpp 75 2009-02-22 14:10:34Z hyunghwan.chung $
|
||||
* $Id: StdAwk.hpp 127 2009-05-07 13:15:04Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -84,9 +84,6 @@ protected:
|
||||
void* reallocMem (void* ptr, size_t n);
|
||||
void freeMem (void* ptr);
|
||||
|
||||
bool_t isType (cint_t c, ccls_id_t type);
|
||||
cint_t transCase (cint_t c, ccls_id_t type);
|
||||
|
||||
real_t pow (real_t x, real_t y);
|
||||
int vsprintf (char_t* buf, size_t size,
|
||||
const char_t* fmt, va_list arg);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.h 100 2009-03-14 03:14:39Z hyunghwan.chung $
|
||||
* $Id: awk.h 127 2009-05-07 13:15:04Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -199,18 +199,6 @@ typedef int (*qse_awk_sprintf_t) (
|
||||
...
|
||||
);
|
||||
|
||||
typedef qse_bool_t (*qse_awk_isccls_t) (
|
||||
qse_awk_t* awk,
|
||||
qse_cint_t c,
|
||||
qse_ccls_id_t type
|
||||
);
|
||||
|
||||
typedef qse_cint_t (*qse_awk_toccls_t) (
|
||||
qse_awk_t* awk,
|
||||
qse_cint_t c,
|
||||
qse_ccls_id_t type
|
||||
);
|
||||
|
||||
/****e* AWK/qse_awk_sio_cmd_t
|
||||
* NAME
|
||||
* qse_awk_sio_cmd_t - define source IO commands
|
||||
@ -308,8 +296,6 @@ struct qse_awk_prm_t
|
||||
{
|
||||
qse_awk_pow_t pow;
|
||||
qse_awk_sprintf_t sprintf;
|
||||
qse_awk_isccls_t isccls;
|
||||
qse_awk_toccls_t toccls;
|
||||
|
||||
#if 0
|
||||
/* TODO: accept regular expression handling functions */
|
||||
@ -885,21 +871,6 @@ qse_awk_prm_t* qse_awk_getprm (
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* AWK/qse_awk_getccls
|
||||
* NAME
|
||||
* qse_awk_getccls - get the character classifier
|
||||
* DESCRIPTION
|
||||
* The qse_awk_getccls() function returns the character classifier composed
|
||||
* from the primitive functions in a call to qse_awk_open(). The data field
|
||||
* is set to the awk object. The classifier returned is valid while the
|
||||
* associated awk object is alive.
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_ccls_t* qse_awk_getccls (
|
||||
qse_awk_t* awk
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* AWK/qse_awk_clear
|
||||
* NAME
|
||||
* qse_awk_clear - clear a qse_awk_t object
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: chr.h 75 2009-02-22 14:10:34Z hyunghwan.chung $
|
||||
* $Id: chr.h 127 2009-05-07 13:15:04Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -22,35 +22,82 @@
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/* gets a pointer to the default memory manager */
|
||||
#define QSE_CCLS_GETDFL() (qse_ccls)
|
||||
/****t* Common/qse_ccls_id_t
|
||||
* NAME
|
||||
* qse_ccls_id_t - define character class types
|
||||
* SYNOPSIS
|
||||
*/
|
||||
enum qse_ccls_id_t
|
||||
{
|
||||
QSE_CCLS_UPPER,
|
||||
QSE_CCLS_LOWER,
|
||||
QSE_CCLS_ALPHA,
|
||||
QSE_CCLS_DIGIT,
|
||||
QSE_CCLS_XDIGIT,
|
||||
QSE_CCLS_ALNUM,
|
||||
QSE_CCLS_SPACE,
|
||||
QSE_CCLS_PRINT,
|
||||
QSE_CCLS_GRAPH,
|
||||
QSE_CCLS_CNTRL,
|
||||
QSE_CCLS_PUNCT
|
||||
};
|
||||
typedef enum qse_ccls_id_t qse_ccls_id_t;
|
||||
/******/
|
||||
|
||||
/* sets a pointer to the default memory manager */
|
||||
#define QSE_CCLS_SETDFL(m) ((qse_ccls)=(m))
|
||||
|
||||
#define QSE_CCLS_IS(ccls,c,type) ((ccls)->is((ccls)->data,c,type))
|
||||
#define QSE_CCLS_TO(ccls,c,type) ((ccls)->to((ccls)->data,c,type))
|
||||
|
||||
#define QSE_CCLS_ISUPPER(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_UPPER)
|
||||
#define QSE_CCLS_ISLOWER(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_LOWER)
|
||||
#define QSE_CCLS_ISALPHA(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_ALPHA)
|
||||
#define QSE_CCLS_ISDIGIT(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_DIGIT)
|
||||
#define QSE_CCLS_ISXDIGIT(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_XDIGIT)
|
||||
#define QSE_CCLS_ISALNUM(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_ALNUM)
|
||||
#define QSE_CCLS_ISSPACE(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_SPACE)
|
||||
#define QSE_CCLS_ISPRINT(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_PRINT)
|
||||
#define QSE_CCLS_ISGRAPH(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_GRAPH)
|
||||
#define QSE_CCLS_ISCNTRL(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_CNTRL)
|
||||
#define QSE_CCLS_ISPUNCT(ccls,c) QSE_CCLS_IS(ccls,c,QSE_CCLS_PUNCT)
|
||||
#define QSE_CCLS_TOUPPER(ccls,c) QSE_CCLS_TO(ccls,c,QSE_CCLS_UPPER)
|
||||
#define QSE_CCLS_TOLOWER(ccls,c) QSE_CCLS_TO(ccls,c,QSE_CCLS_LOWER)
|
||||
#ifdef USE_STDC
|
||||
# if defined(QSE_CHAR_IS_MCHAR)
|
||||
# include <ctype.h>
|
||||
# define QSE_ISUPPER(c) isupper(c)
|
||||
# define QSE_ISLOWER(c) islower(c)
|
||||
# define QSE_ISALPHA(c) isalpha(c)
|
||||
# define QSE_ISDIGIT(c) isdigit(c)
|
||||
# define QSE_ISXDIGIT(c) isxdigit(c)
|
||||
# define QSE_ISALNUM(c) isalnum(c)
|
||||
# define QSE_ISSPACE(c) isspace(c)
|
||||
# define QSE_ISPRINT(c) isprint(c)
|
||||
# define QSE_ISGRAPH(c) isgraph(c)
|
||||
# define QSE_ISCNTRL(c) iscntrl(c)
|
||||
# define QSE_ISPUNCT(c) ispunct(c)
|
||||
# define QSE_TOUPPER(c) toupper(c)
|
||||
# define QSE_TOLOWER(c) tolower(c)
|
||||
# elif defined(QSE_CHAR_IS_WCHAR)
|
||||
# include <wctype.h>
|
||||
# define QSE_ISUPPER(c) iswupper(c)
|
||||
# define QSE_ISLOWER(c) iswlower(c)
|
||||
# define QSE_ISALPHA(c) iswalpha(c)
|
||||
# define QSE_ISDIGIT(c) iswdigit(c)
|
||||
# define QSE_ISXDIGIT(c) iswxdigit(c)
|
||||
# define QSE_ISALNUM(c) iswalnum(c)
|
||||
# define QSE_ISSPACE(c) iswspace(c)
|
||||
# define QSE_ISPRINT(c) iswprint(c)
|
||||
# define QSE_ISGRAPH(c) iswgraph(c)
|
||||
# define QSE_ISCNTRL(c) iswcntrl(c)
|
||||
# define QSE_ISPUNCT(c) iswpunct(c)
|
||||
# define QSE_TOUPPER(c) towupper(c)
|
||||
# define QSE_TOLOWER(c) towlower(c)
|
||||
# else
|
||||
# error Unsupported character type
|
||||
# endif
|
||||
#else
|
||||
# define QSE_ISUPPER(c) (qse_ccls_is(c,QSE_CCLS_UPPER))
|
||||
# define QSE_ISLOWER(c) (qse_ccls_is(c,QSE_CCLS_LOWER))
|
||||
# define QSE_ISALPHA(c) (qse_ccls_is(c,QSE_CCLS_ALPHA))
|
||||
# define QSE_ISDIGIT(c) (qse_ccls_is(c,QSE_CCLS_DIGIT))
|
||||
# define QSE_ISXDIGIT(c) (qse_ccls_is(c,QSE_CCLS_XDIGIT))
|
||||
# define QSE_ISALNUM(c) (qse_ccls_is(c,QSE_CCLS_ALNUM))
|
||||
# define QSE_ISSPACE(c) (qse_ccls_is(c,QSE_CCLS_SPACE))
|
||||
# define QSE_ISPRINT(c) (qse_ccls_is(c,QSE_CCLS_PRINT))
|
||||
# define QSE_ISGRAPH(c) (qse_ccls_is(c,QSE_CCLS_GRAPH))
|
||||
# define QSE_ISCNTRL(c) (qse_ccls_is(c,QSE_CCLS_CNTRL))
|
||||
# define QSE_ISPUNCT(c) (qse_ccls_is(c,QSE_CCLS_PUNCT))
|
||||
# define QSE_TOUPPER(c) (qse_ccls_to(c,QSE_CCLS_UPPER))
|
||||
# define QSE_TOLOWER(c) (qse_ccls_to(c,QSE_CCLS_LOWER))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern qse_ccls_t* qse_ccls;
|
||||
|
||||
qse_bool_t qse_ccls_is (
|
||||
qse_cint_t c,
|
||||
qse_ccls_id_t type
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: rex.h 75 2009-02-22 14:10:34Z hyunghwan.chung $
|
||||
* $Id: rex.h 127 2009-05-07 13:15:04Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -86,7 +86,7 @@ void* qse_buildrex (
|
||||
const qse_char_t* ptn, qse_size_t len, int* errnum);
|
||||
|
||||
int qse_matchrex (
|
||||
qse_mmgr_t* mmgr, qse_ccls_t* ccls, qse_size_t depth,
|
||||
qse_mmgr_t* mmgr, qse_size_t depth,
|
||||
void* code, int option,
|
||||
const qse_char_t* str, qse_size_t len,
|
||||
const qse_char_t** match_ptr, qse_size_t* match_len, int* errnum);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: str.h 126 2009-05-05 02:12:38Z hyunghwan.chung $
|
||||
* $Id: str.h 127 2009-05-07 13:15:04Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -109,6 +109,12 @@ struct qse_str_t
|
||||
if (__ston_f > 0) value *= -1; \
|
||||
}
|
||||
|
||||
enum qse_strtrm_opt_t
|
||||
{
|
||||
QSE_STRTRM_LEFT = (1 << 0),
|
||||
QSE_STRTRM_RIGHT = (1 << 1)
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -238,8 +244,7 @@ int qse_strxncmp (
|
||||
const qse_char_t* s1, qse_size_t len1,
|
||||
const qse_char_t* s2, qse_size_t len2);
|
||||
|
||||
int qse_strcasecmp (
|
||||
const qse_char_t* s1, const qse_char_t* s2, qse_ccls_t* ccls);
|
||||
int qse_strcasecmp (const qse_char_t* s1, const qse_char_t* s2);
|
||||
|
||||
/****f* Common/qse_strxncasecmp
|
||||
* NAME
|
||||
@ -248,9 +253,7 @@ int qse_strcasecmp (
|
||||
* The qse_strxncasecmp() function compares characters at the same position
|
||||
* in each string after converting them to the same case temporarily.
|
||||
* It accepts two strings and a character class handler. A string is
|
||||
* represented by its beginning pointer and length. You can write your own
|
||||
* character class handler or use QSE_CCLS_GETDFL() to get the default
|
||||
* character class handler.
|
||||
* represented by its beginning pointer and length.
|
||||
*
|
||||
* For two strings to be equal, they need to have the same length and all
|
||||
* characters in the first string should be equal to their counterpart in the
|
||||
@ -259,15 +262,15 @@ int qse_strcasecmp (
|
||||
* The qse_strxncasecmp() returns 0 if two strings are equal, a positive
|
||||
* number if the first string is larger, -1 if the second string is larger.
|
||||
* EXAMPLES
|
||||
* qse_strxncasecmp (QSE_T("foo"), 3, QSE_T("FoO"), 3, QSE_CCLS_GETDFL());
|
||||
* The example compares "foo" and "FoO" case-insenstively.
|
||||
* qse_strxncasecmp (QSE_T("foo"), 3, QSE_T("FoO"), 3);
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_strxncasecmp (
|
||||
const qse_char_t* s1 /* the pointer to the first string */,
|
||||
qse_size_t len1 /* the length of the first string */,
|
||||
const qse_char_t* s2 /* the pointer to the second string */,
|
||||
qse_size_t len2 /* the length of the second string */,
|
||||
qse_ccls_t* ccls /* character class handler */
|
||||
qse_size_t len2 /* the length of the second string */
|
||||
);
|
||||
/******/
|
||||
|
||||
@ -396,6 +399,7 @@ int qse_str_yield (
|
||||
* qse_str_getsizer - get the sizer
|
||||
* RETURN
|
||||
* a sizer function set or QSE_NULL if no sizer is set.
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_str_sizer_t qse_str_getsizer (
|
||||
qse_str_t* str
|
||||
@ -428,6 +432,7 @@ void qse_str_setsizer (
|
||||
* You may use QSE_STR_CAPA(str) macro for performance sake.
|
||||
* RETURNS
|
||||
* current capacity in number of characters.
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_str_getcapa (
|
||||
qse_str_t* str
|
||||
@ -443,6 +448,7 @@ qse_size_t qse_str_getcapa (
|
||||
* from the buffer.
|
||||
* RETURNS
|
||||
* (qse_size_t)-1 on failure, new capacity on success
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_str_setcapa (
|
||||
qse_str_t* str,
|
||||
@ -453,6 +459,7 @@ qse_size_t qse_str_setcapa (
|
||||
/****f* Common/qse_str_getlen
|
||||
* NAME
|
||||
* qse_str_getlen - get length
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_str_getlen (
|
||||
qse_str_t* str
|
||||
@ -464,6 +471,7 @@ qse_size_t qse_str_getlen (
|
||||
* qse_str_setlen - change length
|
||||
* RETURNS
|
||||
* (qse_size_t)-1 on failure, new length on success
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_str_setlen (
|
||||
qse_str_t* str,
|
||||
@ -477,6 +485,7 @@ qse_size_t qse_str_setlen (
|
||||
* DESCRIPTION
|
||||
* The qse_str_clear() funtion deletes all characters in a string and sets
|
||||
* the length to 0. It doesn't resize the internal buffer.
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_str_clear (
|
||||
qse_str_t* str
|
||||
@ -489,6 +498,7 @@ void qse_str_clear (
|
||||
* DESCRIPTION
|
||||
* The qse_str_swap() function exchanges the pointers to a buffer between
|
||||
* two strings. It updates the length and the capacity accordingly.
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void qse_str_swap (
|
||||
qse_str_t* str1,
|
||||
@ -529,37 +539,77 @@ qse_size_t qse_str_nccat (
|
||||
qse_size_t len
|
||||
);
|
||||
|
||||
/****f* Common/qse_strspltr
|
||||
/****f* Common/qse_strspl
|
||||
* NAME
|
||||
* qse_strspltr - split a string translating special escane sequences
|
||||
* qse_strspl - split a string into fields
|
||||
* SEE ALSO
|
||||
* qse_strspltrn
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_strspl (
|
||||
qse_char_t* str,
|
||||
const qse_char_t* delim,
|
||||
qse_char_t lquote,
|
||||
qse_char_t rquote,
|
||||
qse_char_t escape
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_strspltrn
|
||||
* NAME
|
||||
* qse_strspltrn - split a string translating special escape sequences
|
||||
* DESCRIPTION
|
||||
* The argument trset is translation character set which is composed
|
||||
* The argument trset is a translation character set which is composed
|
||||
* of multiple character pairs. An escape character followed by the
|
||||
* first character in a pair is translated into the second character
|
||||
* in the pair. If trset is QSE_NULL, no translation is performed.
|
||||
* EXAMPLES
|
||||
* Let's translate a sequence of '\n' and '\r' to a new line and a carriage
|
||||
* return respectively.
|
||||
* qse_strspltrn (str, QSE_T(':'), QSE_T('['), QSE_T(']'), QSE_T('\\'), QSE_T("n\nr\r"), &nfields);
|
||||
* Given [xxx]:[\rabc\ndef]:[] as an input, the example breaks the second
|
||||
* fields to <CR>abc<NL>def where <CR> is a carriage return and <NL> is a
|
||||
* new line.
|
||||
* SEE ALSO
|
||||
* If you don't need any translation, you may call qse_strspl() alternatively.
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_strspltr (
|
||||
qse_char_t* str,
|
||||
int qse_strspltrn (
|
||||
qse_char_t* str,
|
||||
const qse_char_t* delim,
|
||||
qse_char_t lquote,
|
||||
qse_char_t lquote,
|
||||
qse_char_t rquote,
|
||||
qse_char_t escape,
|
||||
qse_char_t escape,
|
||||
const qse_char_t* trset
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_strspl
|
||||
/****f* Common/qse_strtrm
|
||||
* NAME
|
||||
* qse_strspl - split a string
|
||||
* qse_strtrm - remove leading and/or trailing spaces from a string
|
||||
* DESCRIPTION
|
||||
* The qse_strtrm() function removes leading spaces and/or trailing
|
||||
* spaces from a string depending on the opt parameter. You can form
|
||||
* the opt parameter by bitwise-OR'ing one or more of the following
|
||||
* values.
|
||||
* * QSE_STRTRM_LEFT - remove leading spaces
|
||||
* * QSE_STRTRM_RIGHT - remove trailing spaces
|
||||
* It returns the pointer to the trimmed string.
|
||||
* NOTE
|
||||
* Should it remove leading spaces, it just returns the pointer to
|
||||
* the first non-space character in the string. Should it remove trailing
|
||||
* spaces, it inserts a QSE_T('\0') character after the last non-space
|
||||
* characters.
|
||||
* EXAMPLES
|
||||
* The example removes leading and trailing spaces from the string a.
|
||||
* qse_char_t a[] = QSE_T(" this is a test string ");
|
||||
* qse_printf (QSE_T("[%s]\n"), a);
|
||||
* qse_printf (QSE_T("[%s]\n"), qse_strtrm (a, QSE_STRTRM_LEFT|QSE_STRTRM_RIGHT));
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_strspl (
|
||||
qse_char_t* str,
|
||||
const qse_char_t* delim,
|
||||
qse_char_t lquote,
|
||||
qse_char_t rquote,
|
||||
qse_char_t escape
|
||||
qse_char_t* qse_strtrm (
|
||||
qse_char_t* str,
|
||||
int opt
|
||||
);
|
||||
/******/
|
||||
|
||||
@ -569,8 +619,8 @@ int qse_strspl (
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_mbstowcs (
|
||||
const qse_mchar_t* mbs,
|
||||
qse_wchar_t* wcs,
|
||||
const qse_mchar_t* mbs,
|
||||
qse_wchar_t* wcs,
|
||||
qse_size_t* wcslen
|
||||
);
|
||||
/******/
|
||||
@ -583,9 +633,9 @@ qse_size_t qse_mbstowcs (
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_mbsntowcsn (
|
||||
const qse_mchar_t* mbs,
|
||||
const qse_mchar_t* mbs,
|
||||
qse_size_t mbslen,
|
||||
qse_wchar_t* wcs,
|
||||
qse_wchar_t* wcs,
|
||||
qse_size_t* wcslen
|
||||
);
|
||||
/******/
|
||||
@ -646,8 +696,8 @@ qse_size_t qse_wcsntombsnlen (
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_wcstombs (
|
||||
const qse_wchar_t* wcs,
|
||||
qse_mchar_t* mbs,
|
||||
const qse_wchar_t* wcs,
|
||||
qse_mchar_t* mbs,
|
||||
qse_size_t* mbslen
|
||||
);
|
||||
/******/
|
||||
@ -660,9 +710,9 @@ qse_size_t qse_wcstombs (
|
||||
* SYNOPSIS
|
||||
*/
|
||||
qse_size_t qse_wcsntombsn (
|
||||
const qse_wchar_t* wcs,
|
||||
const qse_wchar_t* wcs,
|
||||
qse_size_t wcslen,
|
||||
qse_mchar_t* mbs,
|
||||
qse_mchar_t* mbs,
|
||||
qse_size_t* mbslen
|
||||
);
|
||||
/******/
|
||||
@ -679,8 +729,8 @@ qse_size_t qse_wcsntombsn (
|
||||
* SYNOPSIS
|
||||
*/
|
||||
int qse_wcstombs_strict (
|
||||
const qse_wchar_t* wcs,
|
||||
qse_mchar_t* mbs,
|
||||
const qse_wchar_t* wcs,
|
||||
qse_mchar_t* mbs,
|
||||
qse_size_t mbslen
|
||||
);
|
||||
/******/
|
||||
|
@ -48,7 +48,6 @@ typedef void (*qse_lsp_dprintf_t) (void* data, const qse_char_t* fmt, ...);
|
||||
struct qse_lsp_prmfns_t
|
||||
{
|
||||
qse_mmgr_t mmgr;
|
||||
qse_ccls_t ccls;
|
||||
|
||||
/* utilities */
|
||||
struct
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: types.h 90 2009-03-01 09:58:19Z hyunghwan.chung $
|
||||
* $Id: types.h 127 2009-05-07 13:15:04Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
|
||||
@ -419,46 +419,4 @@ struct qse_mmgr_t
|
||||
typedef struct qse_mmgr_t qse_mmgr_t;
|
||||
/******/
|
||||
|
||||
/****t* Base/qse_ccls_id_t
|
||||
* NAME
|
||||
* qse_ccls_id_t - define character class types
|
||||
* SYNOPSIS
|
||||
*/
|
||||
enum qse_ccls_id_t
|
||||
{
|
||||
QSE_CCLS_UPPER,
|
||||
QSE_CCLS_LOWER,
|
||||
QSE_CCLS_ALPHA,
|
||||
QSE_CCLS_DIGIT,
|
||||
QSE_CCLS_XDIGIT,
|
||||
QSE_CCLS_ALNUM,
|
||||
QSE_CCLS_SPACE,
|
||||
QSE_CCLS_PRINT,
|
||||
QSE_CCLS_GRAPH,
|
||||
QSE_CCLS_CNTRL,
|
||||
QSE_CCLS_PUNCT
|
||||
};
|
||||
/******/
|
||||
|
||||
typedef enum qse_ccls_id_t qse_ccls_id_t;
|
||||
|
||||
typedef qse_bool_t (*qse_ccls_is_t) (
|
||||
void* data, qse_cint_t c, qse_ccls_id_t type);
|
||||
typedef qse_cint_t (*qse_ccls_to_t) (
|
||||
void* data, qse_cint_t c, qse_ccls_id_t type);
|
||||
|
||||
/****t* Base/qse_ccls_t
|
||||
* NAME
|
||||
* qse_mmgr_t - define a character classifier
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct qse_ccls_t
|
||||
{
|
||||
qse_ccls_is_t is;
|
||||
qse_ccls_to_t to;
|
||||
void* data;
|
||||
};
|
||||
typedef struct qse_ccls_t qse_ccls_t;
|
||||
/******/
|
||||
|
||||
#endif
|
||||
|
@ -85,42 +85,15 @@ typedef qse_ssize_t (*qse_sed_iof_t) (
|
||||
qse_size_t count
|
||||
);
|
||||
|
||||
typedef qse_bool_t (*qse_sed_isccls_t) (
|
||||
qse_sed_t* sed,
|
||||
qse_cint_t c,
|
||||
qse_ccls_id_t type
|
||||
);
|
||||
|
||||
typedef qse_cint_t (*qse_sed_toccls_t) (
|
||||
qse_sed_t* sed,
|
||||
qse_cint_t c,
|
||||
qse_ccls_id_t type
|
||||
);
|
||||
|
||||
typedef struct qse_sed_cmd_t qse_sed_cmd_t; /* command */
|
||||
typedef enum qse_sed_errnum_t qse_sed_errnum_t;
|
||||
|
||||
/****f* Text Processor/qse_sed_prm_t
|
||||
* NAME
|
||||
* qse_sed_prm_t - define primitive functions
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct qse_sed_prm_t
|
||||
{
|
||||
qse_sed_isccls_t isccls;
|
||||
qse_sed_toccls_t toccls;
|
||||
};
|
||||
typedef struct qse_sed_prm_t qse_sed_prm_t;
|
||||
/******/
|
||||
|
||||
struct qse_sed_t
|
||||
{
|
||||
QSE_DEFINE_COMMON_FIELDS (sed)
|
||||
qse_sed_errnum_t errnum;
|
||||
int option;
|
||||
|
||||
qse_ccls_t ccls;
|
||||
|
||||
/* source code pointers */
|
||||
struct
|
||||
{
|
||||
@ -191,8 +164,7 @@ QSE_DEFINE_COMMON_FUNCTIONS (sed)
|
||||
*/
|
||||
qse_sed_t* qse_sed_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t xtn,
|
||||
qse_sed_prm_t* prm
|
||||
qse_size_t xtn
|
||||
);
|
||||
/******/
|
||||
|
||||
@ -213,8 +185,7 @@ void qse_sed_close (
|
||||
*/
|
||||
qse_sed_t* qse_sed_init (
|
||||
qse_sed_t* sed,
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_sed_prm_t* prm
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
/******/
|
||||
|
||||
|
Reference in New Issue
Block a user