add QSE_XLI_PAIRXTNSIZE and qse_xli_getpairxtn()

This commit is contained in:
hyung-hwan 2013-09-16 11:03:44 +00:00
parent 7e98acf59f
commit cb170d2e7a
3 changed files with 24 additions and 4 deletions

View File

@ -72,7 +72,8 @@ typedef const qse_char_t* (*qse_xli_errstr_t) (
enum qse_xli_opt_t enum qse_xli_opt_t
{ {
QSE_XLI_TRAIT QSE_XLI_TRAIT,
QSE_XLI_PAIRXTNSIZE
}; };
typedef enum qse_xli_opt_t qse_xli_opt_t; typedef enum qse_xli_opt_t qse_xli_opt_t;
@ -499,6 +500,11 @@ QSE_EXPORT void qse_xli_freemem (
void* ptr void* ptr
); );
QSE_EXPORT void* qse_xli_getpairxtn (
qse_xli_t* xli,
qse_xli_pair_t* pair
);
QSE_EXPORT qse_xli_pair_t* qse_xli_insertpair ( QSE_EXPORT qse_xli_pair_t* qse_xli_insertpair (
qse_xli_t* xli, qse_xli_t* xli,
qse_xli_list_t* list, qse_xli_list_t* list,

View File

@ -109,6 +109,10 @@ int qse_xli_setopt (qse_xli_t* xli, qse_xli_opt_t id, const void* value)
case QSE_XLI_TRAIT: case QSE_XLI_TRAIT:
xli->opt.trait = *(const int*)value; xli->opt.trait = *(const int*)value;
return 0; return 0;
case QSE_XLI_PAIRXTNSIZE:
xli->opt.pair_xtnsize = *(const qse_size_t*)value;
return 0;
} }
qse_xli_seterrnum (xli, QSE_XLI_EINVAL, QSE_NULL); qse_xli_seterrnum (xli, QSE_XLI_EINVAL, QSE_NULL);
@ -122,6 +126,10 @@ int qse_xli_getopt (qse_xli_t* xli, qse_xli_opt_t id, void* value)
case QSE_XLI_TRAIT: case QSE_XLI_TRAIT:
*(int*)value = xli->opt.trait; *(int*)value = xli->opt.trait;
return 0; return 0;
case QSE_XLI_PAIRXTNSIZE:
*(qse_size_t*)value = xli->opt.pair_xtnsize;
return 0;
}; };
qse_xli_seterrnum (xli, QSE_XLI_EINVAL, QSE_NULL); qse_xli_seterrnum (xli, QSE_XLI_EINVAL, QSE_NULL);
@ -214,12 +222,12 @@ static qse_xli_pair_t* insert_pair (
alen = alias? alias->len: 0; alen = alias? alias->len: 0;
pair = qse_xli_callocmem (xli, pair = qse_xli_callocmem (xli,
QSE_SIZEOF(*pair) + QSE_SIZEOF(*pair) + xli->opt.pair_xtnsize +
((key->len + 1) * QSE_SIZEOF(*key->ptr)) + ((key->len + 1) * QSE_SIZEOF(*key->ptr)) +
((alen + 1) * QSE_SIZEOF(*alias->ptr))); ((alen + 1) * QSE_SIZEOF(*alias->ptr)));
if (pair == QSE_NULL) return QSE_NULL; if (pair == QSE_NULL) return QSE_NULL;
kptr = (qse_char_t*)(pair + 1); kptr = (qse_char_t*)((qse_uint8_t*)(pair + 1) + xli->opt.pair_xtnsize);
qse_strcpy (kptr, key->ptr); qse_strcpy (kptr, key->ptr);
pair->type = QSE_XLI_PAIR; pair->type = QSE_XLI_PAIR;
@ -236,6 +244,11 @@ static qse_xli_pair_t* insert_pair (
return pair; return pair;
} }
void* qse_xli_getpairxtn (qse_xli_t* xli, qse_xli_pair_t* pair)
{
return (void*)(pair + 1);
}
qse_xli_pair_t* qse_xli_insertpair ( qse_xli_pair_t* qse_xli_insertpair (
qse_xli_t* xli, qse_xli_list_t* parent, qse_xli_atom_t* peer, qse_xli_t* xli, qse_xli_list_t* parent, qse_xli_atom_t* peer,
const qse_char_t* key, const qse_char_t* alias, qse_xli_val_t* value) const qse_char_t* key, const qse_char_t* alias, qse_xli_val_t* value)

View File

@ -54,7 +54,8 @@ struct qse_xli_t
struct struct
{ {
int trait; int trait;
qse_size_t pair_xtnsize;
} opt; } opt;
qse_xli_ecb_t* ecb; qse_xli_ecb_t* ecb;