2013-02-05 15:04:15 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2019-06-06 05:28:23 +00:00
|
|
|
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
|
2013-02-05 15:04:15 +00:00
|
|
|
|
2014-11-19 14:42:24 +00:00
|
|
|
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.
|
2013-02-05 15:04:15 +00:00
|
|
|
|
2014-11-19 14:42:24 +00:00
|
|
|
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.
|
2013-02-05 15:04:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _QSE_LIB_XLI_XLI_H_
|
|
|
|
#define _QSE_LIB_XLI_XLI_H_
|
|
|
|
|
|
|
|
#include <qse/xli/xli.h>
|
|
|
|
#include <qse/cmn/str.h>
|
2013-07-11 16:55:08 +00:00
|
|
|
#include <qse/cmn/rbt.h>
|
2016-04-29 03:55:42 +00:00
|
|
|
#include "../cmn/mem-prv.h"
|
2013-02-05 15:04:15 +00:00
|
|
|
|
2015-08-30 03:11:54 +00:00
|
|
|
enum qse_xli_tok_type_t
|
|
|
|
{
|
|
|
|
QSE_XLI_TOK_EOF,
|
|
|
|
QSE_XLI_TOK_XINCLUDE,
|
2018-01-10 10:01:41 +00:00
|
|
|
QSE_XLI_TOK_TRUE,
|
|
|
|
QSE_XLI_TOK_FALSE,
|
|
|
|
QSE_XLI_TOK_NIL,
|
2018-01-05 10:55:20 +00:00
|
|
|
QSE_XLI_TOK_COLON,
|
2018-01-09 10:45:43 +00:00
|
|
|
QSE_XLI_TOK_SEMICOLON,
|
2015-08-30 03:11:54 +00:00
|
|
|
QSE_XLI_TOK_LBRACE,
|
|
|
|
QSE_XLI_TOK_RBRACE,
|
2018-01-08 08:25:49 +00:00
|
|
|
QSE_XLI_TOK_LBRACK,
|
|
|
|
QSE_XLI_TOK_RBRACK,
|
|
|
|
QSE_XLI_TOK_LPAREN,
|
|
|
|
QSE_XLI_TOK_RPAREN,
|
2015-08-30 03:11:54 +00:00
|
|
|
QSE_XLI_TOK_EQ,
|
|
|
|
QSE_XLI_TOK_COMMA,
|
|
|
|
QSE_XLI_TOK_DQSTR,
|
|
|
|
QSE_XLI_TOK_SQSTR,
|
|
|
|
QSE_XLI_TOK_NSTR,
|
|
|
|
QSE_XLI_TOK_IDENT,
|
|
|
|
QSE_XLI_TOK_TEXT,
|
2015-08-31 13:31:30 +00:00
|
|
|
QSE_XLI_TOK_TAG,
|
|
|
|
QSE_XLI_TOK_NL
|
2015-08-30 03:11:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum qse_xli_tok_type_t qse_xli_tok_type_t;
|
|
|
|
|
2013-02-05 15:04:15 +00:00
|
|
|
typedef struct qse_xli_tok_t qse_xli_tok_t;
|
|
|
|
|
|
|
|
struct qse_xli_tok_t
|
|
|
|
{
|
2015-08-30 03:11:54 +00:00
|
|
|
qse_xli_tok_type_t type;
|
|
|
|
qse_str_t* name;
|
|
|
|
qse_xli_loc_t loc;
|
2013-02-05 15:04:15 +00:00
|
|
|
};
|
|
|
|
|
2013-06-23 14:44:29 +00:00
|
|
|
typedef struct qse_xli_list_link_t qse_xli_list_link_t;
|
|
|
|
|
|
|
|
struct qse_xli_list_link_t
|
|
|
|
{
|
|
|
|
qse_xli_list_link_t* next;
|
|
|
|
qse_xli_list_t* list;
|
|
|
|
};
|
|
|
|
|
2013-09-16 14:32:50 +00:00
|
|
|
typedef struct qse_xli_root_list_t qse_xli_root_list_t;
|
|
|
|
|
|
|
|
struct qse_xli_root_list_t
|
|
|
|
{
|
|
|
|
qse_xli_list_t list;
|
|
|
|
qse_xli_nil_t xnil;
|
2018-01-10 10:01:41 +00:00
|
|
|
qse_xli_true_t xtrue;
|
|
|
|
qse_xli_false_t xfalse;
|
2013-09-16 14:32:50 +00:00
|
|
|
qse_mmgr_t* mmgr;
|
|
|
|
};
|
|
|
|
|
2013-02-05 15:04:15 +00:00
|
|
|
struct qse_xli_t
|
|
|
|
{
|
2019-06-24 14:24:14 +00:00
|
|
|
QSE_XLI_HDR;
|
2013-02-09 13:31:31 +00:00
|
|
|
|
|
|
|
qse_xli_errstr_t errstr; /**< error string getter */
|
|
|
|
qse_xli_errnum_t errnum; /**< stores an error number */
|
|
|
|
qse_char_t errmsg[128]; /**< error message holder */
|
|
|
|
qse_xli_loc_t errloc; /**< location of the last error */
|
2013-02-05 15:04:15 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
2013-09-16 11:03:44 +00:00
|
|
|
int trait;
|
|
|
|
qse_size_t pair_xtnsize;
|
2013-09-20 07:18:26 +00:00
|
|
|
qse_size_t root_xtnsize;
|
2015-03-19 07:26:06 +00:00
|
|
|
qse_char_t key_splitter; /**< character to use to split a key in the fqpn format */
|
2018-01-19 15:57:44 +00:00
|
|
|
qse_xli_cbs_t cbs;
|
2018-01-19 03:53:43 +00:00
|
|
|
|
|
|
|
int (*strcmp) (const qse_char_t* s1, const qse_char_t* s2);
|
|
|
|
int (*strxcmp) (const qse_char_t* s1, qse_size_t len1, const qse_char_t* s2);
|
2013-02-05 15:04:15 +00:00
|
|
|
} opt;
|
|
|
|
|
|
|
|
qse_xli_ecb_t* ecb;
|
|
|
|
|
2013-09-16 14:32:50 +00:00
|
|
|
qse_xli_root_list_t* root;
|
2018-01-09 10:45:43 +00:00
|
|
|
qse_xli_list_link_t* parlink; /* internal use only - link that points to the list being read currently */
|
2013-07-11 16:55:08 +00:00
|
|
|
|
|
|
|
qse_str_t* dotted_curkey;
|
|
|
|
qse_rbt_t* schema;
|
2013-02-05 15:04:15 +00:00
|
|
|
|
|
|
|
qse_xli_tok_t tok;
|
2013-07-01 15:16:19 +00:00
|
|
|
int tok_status;
|
2013-02-05 15:04:15 +00:00
|
|
|
struct
|
|
|
|
{
|
2013-06-01 13:34:57 +00:00
|
|
|
qse_xli_io_impl_t impl; /* input handler */
|
2015-08-30 03:11:54 +00:00
|
|
|
qse_xli_io_lxc_t last;
|
2013-06-29 17:01:32 +00:00
|
|
|
qse_xli_io_arg_t top; /* for top level */
|
2013-02-05 15:04:15 +00:00
|
|
|
qse_xli_io_arg_t* inp; /* current */
|
2013-06-29 17:01:32 +00:00
|
|
|
} rio;
|
|
|
|
qse_link_t* rio_names;
|
2013-06-01 13:34:57 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
qse_xli_io_impl_t impl; /* output handler */
|
2013-06-27 15:18:33 +00:00
|
|
|
qse_xli_io_arg_t top; /* for top level */
|
2013-06-01 13:34:57 +00:00
|
|
|
qse_xli_io_arg_t* inp; /* current */
|
|
|
|
} wio;
|
2013-07-01 09:26:39 +00:00
|
|
|
qse_link_t* wio_names;
|
2013-02-05 15:04:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-09-20 07:18:26 +00:00
|
|
|
int qse_xli_init (qse_xli_t* xli, qse_mmgr_t* mmgr, qse_size_t rootxtnsize);
|
2013-02-05 15:04:15 +00:00
|
|
|
|
|
|
|
void qse_xli_fini (qse_xli_t* xli);
|
|
|
|
|
2013-02-09 13:31:31 +00:00
|
|
|
const qse_char_t* qse_xli_dflerrstr (
|
2018-01-09 10:45:43 +00:00
|
|
|
const qse_xli_t* xli, qse_xli_errnum_t errnum);
|
2013-02-09 13:31:31 +00:00
|
|
|
|
2013-06-29 17:01:32 +00:00
|
|
|
void qse_xli_clearrionames (qse_xli_t* xli);
|
2013-07-01 09:26:39 +00:00
|
|
|
void qse_xli_clearwionames (qse_xli_t* xli);
|
2013-05-15 12:05:24 +00:00
|
|
|
|
2015-08-29 13:04:46 +00:00
|
|
|
int qse_xli_getchar (qse_xli_t* xli);
|
2015-09-02 01:27:08 +00:00
|
|
|
int qse_xli_openrstream (qse_xli_t* xli, qse_xli_io_arg_t* arg);
|
|
|
|
int qse_xli_closeactiverstream (qse_xli_t* xli);
|
|
|
|
|
|
|
|
int qse_xli_openwstream (qse_xli_t* xli, const qse_char_t* path, int old_depth);
|
|
|
|
int qse_xli_closeactivewstream (qse_xli_t* xli, int* org_depth);
|
|
|
|
int qse_xli_flushwstream (qse_xli_t* xli, qse_xli_io_arg_t* arg);
|
2015-08-29 13:04:46 +00:00
|
|
|
|
|
|
|
qse_xli_list_link_t* qse_xli_makelistlink (qse_xli_t* xli, qse_xli_list_t* parlist);
|
|
|
|
void qse_xli_freelistlink (qse_xli_t* xli, qse_xli_list_link_t* link);
|
|
|
|
|
2018-01-09 10:45:43 +00:00
|
|
|
|
|
|
|
qse_xli_str_t* qse_xli_makestrval (qse_xli_t* xli, const qse_cstr_t* value, const qse_char_t* strtag);
|
|
|
|
qse_xli_list_t* qse_xli_makelistval (qse_xli_t* xli);
|
|
|
|
void qse_xli_freeval (qse_xli_t* xli, qse_xli_val_t* val);
|
|
|
|
|
2013-02-05 15:04:15 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|