added xli/json.c
This commit is contained in:
parent
d7940a7c5b
commit
9a0f2e15b8
@ -1,6 +1,6 @@
|
|||||||
pkgincludedir= $(includedir)/qse/xli
|
pkgincludedir= $(includedir)/qse/xli
|
||||||
|
|
||||||
pkginclude_HEADERS = xli.h stdxli.h
|
pkginclude_HEADERS = xli.h stdxli.h json.h
|
||||||
|
|
||||||
|
|
||||||
if ENABLE_CXX
|
if ENABLE_CXX
|
||||||
|
@ -124,7 +124,7 @@ am__can_run_installinfo = \
|
|||||||
n|no|NO) false;; \
|
n|no|NO) false;; \
|
||||||
*) (install-info --version) >/dev/null 2>&1;; \
|
*) (install-info --version) >/dev/null 2>&1;; \
|
||||||
esac
|
esac
|
||||||
am__pkginclude_HEADERS_DIST = xli.h stdxli.h SkvEnv.hpp
|
am__pkginclude_HEADERS_DIST = xli.h stdxli.h json.h SkvEnv.hpp
|
||||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||||
am__vpath_adj = case $$p in \
|
am__vpath_adj = case $$p in \
|
||||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||||
@ -342,7 +342,7 @@ target_alias = @target_alias@
|
|||||||
top_build_prefix = @top_build_prefix@
|
top_build_prefix = @top_build_prefix@
|
||||||
top_builddir = @top_builddir@
|
top_builddir = @top_builddir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
pkginclude_HEADERS = xli.h stdxli.h $(am__append_1)
|
pkginclude_HEADERS = xli.h stdxli.h json.h $(am__append_1)
|
||||||
all: all-am
|
all: all-am
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
|
225
qse/include/qse/xli/json.h
Normal file
225
qse/include/qse/xli/json.h
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _QSE_XLI_JSON_H_
|
||||||
|
#define _QSE_XLI_JSON_H_
|
||||||
|
|
||||||
|
#include <qse/types.h>
|
||||||
|
#include <qse/macros.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The qse_json_t type defines a simple json parser.
|
||||||
|
*/
|
||||||
|
typedef struct qse_json_t qse_json_t;
|
||||||
|
|
||||||
|
enum qse_json_errnum_t
|
||||||
|
{
|
||||||
|
QSE_JSON_ENOERR = 0,
|
||||||
|
QSE_JSON_EOTHER,
|
||||||
|
QSE_JSON_ENOIMPL,
|
||||||
|
QSE_JSON_ESYSERR,
|
||||||
|
QSE_JSON_EINTERN,
|
||||||
|
|
||||||
|
QSE_JSON_ENOMEM,
|
||||||
|
QSE_JSON_EINVAL,
|
||||||
|
QSE_JSON_EFINIS
|
||||||
|
};
|
||||||
|
typedef enum qse_json_errnum_t qse_json_errnum_t;
|
||||||
|
|
||||||
|
enum qse_json_option_t
|
||||||
|
{
|
||||||
|
QSE_JSON_TRAIT
|
||||||
|
};
|
||||||
|
typedef enum qse_json_option_t qse_json_option_t;
|
||||||
|
|
||||||
|
enum qse_json_trait_t
|
||||||
|
{
|
||||||
|
/* no trait defined at this moment. XXXX is just a placeholder */
|
||||||
|
QSE_JSON_XXXX = (1 << 0)
|
||||||
|
};
|
||||||
|
typedef enum qse_json_trait_t qse_json_trait_t;
|
||||||
|
|
||||||
|
/* ========================================================================= */
|
||||||
|
|
||||||
|
enum qse_json_state_t
|
||||||
|
{
|
||||||
|
QSE_JSON_STATE_START,
|
||||||
|
QSE_JSON_STATE_IN_ARRAY,
|
||||||
|
QSE_JSON_STATE_IN_DIC,
|
||||||
|
|
||||||
|
QSE_JSON_STATE_IN_WORD_VALUE,
|
||||||
|
QSE_JSON_STATE_IN_NUMERIC_VALUE,
|
||||||
|
QSE_JSON_STATE_IN_STRING_VALUE,
|
||||||
|
QSE_JSON_STATE_IN_CHARACTER_VALUE
|
||||||
|
};
|
||||||
|
typedef enum qse_json_state_t qse_json_state_t;
|
||||||
|
|
||||||
|
|
||||||
|
/* ========================================================================= */
|
||||||
|
enum qse_json_inst_t
|
||||||
|
{
|
||||||
|
QSE_JSON_INST_START_ARRAY,
|
||||||
|
QSE_JSON_INST_END_ARRAY,
|
||||||
|
QSE_JSON_INST_START_DIC,
|
||||||
|
QSE_JSON_INST_END_DIC,
|
||||||
|
|
||||||
|
QSE_JSON_INST_KEY,
|
||||||
|
|
||||||
|
QSE_JSON_INST_CHARACTER, /* there is no such element as character in real JSON */
|
||||||
|
QSE_JSON_INST_STRING,
|
||||||
|
QSE_JSON_INST_NUMBER,
|
||||||
|
QSE_JSON_INST_NIL,
|
||||||
|
QSE_JSON_INST_TRUE,
|
||||||
|
QSE_JSON_INST_FALSE,
|
||||||
|
};
|
||||||
|
typedef enum qse_json_inst_t qse_json_inst_t;
|
||||||
|
|
||||||
|
typedef int (*qse_json_instcb_t) (
|
||||||
|
qse_json_t* json,
|
||||||
|
qse_json_inst_t inst,
|
||||||
|
const qse_cstr_t* str
|
||||||
|
);
|
||||||
|
|
||||||
|
struct qse_json_prim_t
|
||||||
|
{
|
||||||
|
qse_json_instcb_t instcb;
|
||||||
|
};
|
||||||
|
typedef struct qse_json_prim_t qse_json_prim_t;
|
||||||
|
|
||||||
|
/* ========================================================================= */
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QSE_EXPORT qse_json_t* qse_json_open (
|
||||||
|
qse_mmgr_t* mmgr,
|
||||||
|
qse_size_t xtnsize,
|
||||||
|
qse_json_prim_t* prim,
|
||||||
|
qse_json_errnum_t* errnum
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT void qse_json_close (
|
||||||
|
qse_json_t* json
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT void qse_json_reset (
|
||||||
|
qse_json_t* json
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT int qse_json_feed (
|
||||||
|
qse_json_t* json,
|
||||||
|
const void* ptr,
|
||||||
|
qse_size_t len,
|
||||||
|
qse_size_t* xlen
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT qse_json_state_t qse_json_getstate (
|
||||||
|
qse_json_t* json
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT int qse_json_setoption (
|
||||||
|
qse_json_t* json,
|
||||||
|
qse_json_option_t id,
|
||||||
|
const void* value
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT int qse_json_getoption (
|
||||||
|
qse_json_t* json,
|
||||||
|
qse_json_option_t id,
|
||||||
|
void* value
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
QSE_EXPORT void* qse_json_getxtn (
|
||||||
|
qse_json_t* json
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT qse_mmgr_t* qse_json_getmmgr (
|
||||||
|
qse_json_t* json
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT qse_cmgr_t* qse_json_getcmgr (
|
||||||
|
qse_json_t* json
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT void qse_json_setcmgr (
|
||||||
|
qse_json_t* json,
|
||||||
|
qse_cmgr_t* cmgr
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
QSE_EXPORT qse_json_errnum_t qse_json_geterrnum (
|
||||||
|
qse_json_t* json
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT const qse_char_t* qse_json_geterrmsg (
|
||||||
|
qse_json_t* json
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT const qse_char_t* qse_json_backuperrmsg (
|
||||||
|
qse_json_t* json
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
QSE_EXPORT void qse_json_seterrnum (
|
||||||
|
qse_json_t* json,
|
||||||
|
qse_json_errnum_t errnum
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT void qse_json_seterrfmt (
|
||||||
|
qse_json_t* json,
|
||||||
|
qse_json_errnum_t errnum,
|
||||||
|
const qse_char_t* fmt,
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT void* qse_json_allocmem (
|
||||||
|
qse_json_t* json,
|
||||||
|
qse_size_t size
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT void* qse_json_callocmem (
|
||||||
|
qse_json_t* json,
|
||||||
|
qse_size_t size
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT void* qse_json_reallocmem (
|
||||||
|
qse_json_t* json,
|
||||||
|
void* ptr,
|
||||||
|
qse_size_t size
|
||||||
|
);
|
||||||
|
|
||||||
|
QSE_EXPORT void qse_json_freemem (
|
||||||
|
qse_json_t* json,
|
||||||
|
void* ptr
|
||||||
|
);
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -8,7 +8,7 @@ lib_LTLIBRARIES = libqsexli.la
|
|||||||
libqsexli_la_SOURCES = xli-prv.h xli.c err.c \
|
libqsexli_la_SOURCES = xli-prv.h xli.c err.c \
|
||||||
read.c read-ini.c read-json.c \
|
read.c read-ini.c read-json.c \
|
||||||
write.c write-ini.c write-json.c \
|
write.c write-ini.c write-json.c \
|
||||||
std.c
|
std.c json.c
|
||||||
libqsexli_la_LDFLAGS = -L../cmn -L../si -version-info 1:0:0 -no-undefined
|
libqsexli_la_LDFLAGS = -L../cmn -L../si -version-info 1:0:0 -no-undefined
|
||||||
libqsexli_la_LIBADD = -lqsesi -lqsecmn
|
libqsexli_la_LIBADD = -lqsesi -lqsecmn
|
||||||
|
|
||||||
|
@ -136,7 +136,8 @@ am__installdirs = "$(DESTDIR)$(libdir)"
|
|||||||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||||
libqsexli_la_DEPENDENCIES =
|
libqsexli_la_DEPENDENCIES =
|
||||||
am_libqsexli_la_OBJECTS = xli.lo err.lo read.lo read-ini.lo \
|
am_libqsexli_la_OBJECTS = xli.lo err.lo read.lo read-ini.lo \
|
||||||
read-json.lo write.lo write-ini.lo write-json.lo std.lo
|
read-json.lo write.lo write-ini.lo write-json.lo std.lo \
|
||||||
|
json.lo
|
||||||
libqsexli_la_OBJECTS = $(am_libqsexli_la_OBJECTS)
|
libqsexli_la_OBJECTS = $(am_libqsexli_la_OBJECTS)
|
||||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||||
@ -410,7 +411,7 @@ lib_LTLIBRARIES = libqsexli.la $(am__append_1)
|
|||||||
libqsexli_la_SOURCES = xli-prv.h xli.c err.c \
|
libqsexli_la_SOURCES = xli-prv.h xli.c err.c \
|
||||||
read.c read-ini.c read-json.c \
|
read.c read-ini.c read-json.c \
|
||||||
write.c write-ini.c write-json.c \
|
write.c write-ini.c write-json.c \
|
||||||
std.c
|
std.c json.c
|
||||||
|
|
||||||
libqsexli_la_LDFLAGS = -L../cmn -L../si -version-info 1:0:0 -no-undefined
|
libqsexli_la_LDFLAGS = -L../cmn -L../si -version-info 1:0:0 -no-undefined
|
||||||
libqsexli_la_LIBADD = -lqsesi -lqsecmn
|
libqsexli_la_LIBADD = -lqsesi -lqsecmn
|
||||||
@ -500,6 +501,7 @@ distclean-compile:
|
|||||||
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SkvEnv.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SkvEnv.Plo@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Plo@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/json.Plo@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read-ini.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read-ini.Plo@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read-json.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read-json.Plo@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read.Plo@am__quote@
|
||||||
|
1004
qse/lib/xli/json.c
Normal file
1004
qse/lib/xli/json.c
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user