2016-03-21 17:16:05 +00:00
|
|
|
/* Copyright (C) 2010-2016 The RetroArch team
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------------------------------------------
|
|
|
|
* The following license statement only applies to this file (rmsgpack_dom.h).
|
|
|
|
* ---------------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge,
|
|
|
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation the rights to
|
|
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
|
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
|
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LIBRETRODB_MSGPACK_DOM_H__
|
|
|
|
#define __LIBRETRODB_MSGPACK_DOM_H__
|
2015-01-19 21:47:09 +00:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2016-06-03 05:58:15 +00:00
|
|
|
#include <retro_common_api.h>
|
2016-03-20 15:29:14 +00:00
|
|
|
#include <streams/file_stream.h>
|
2015-09-17 17:57:51 +00:00
|
|
|
|
2016-06-03 05:58:15 +00:00
|
|
|
RETRO_BEGIN_DECLS
|
2015-01-23 05:05:54 +00:00
|
|
|
|
2015-09-17 05:23:36 +00:00
|
|
|
enum rmsgpack_dom_type
|
|
|
|
{
|
2015-01-19 21:47:09 +00:00
|
|
|
RDT_NULL = 0,
|
|
|
|
RDT_BOOL,
|
|
|
|
RDT_UINT,
|
|
|
|
RDT_INT,
|
|
|
|
RDT_STRING,
|
|
|
|
RDT_BINARY,
|
|
|
|
RDT_MAP,
|
|
|
|
RDT_ARRAY
|
|
|
|
};
|
|
|
|
|
2015-09-17 04:39:17 +00:00
|
|
|
struct rmsgpack_dom_value
|
|
|
|
{
|
|
|
|
enum rmsgpack_dom_type type;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
uint64_t uint_;
|
|
|
|
int64_t int_;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32_t len;
|
2015-09-17 07:33:24 +00:00
|
|
|
char *buff;
|
2015-09-17 04:39:17 +00:00
|
|
|
} string;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32_t len;
|
2015-09-17 07:33:24 +00:00
|
|
|
char *buff;
|
2015-09-17 04:39:17 +00:00
|
|
|
} binary;
|
|
|
|
int bool_;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32_t len;
|
2015-09-17 07:33:24 +00:00
|
|
|
struct rmsgpack_dom_pair *items;
|
2015-09-17 04:39:17 +00:00
|
|
|
} map;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32_t len;
|
2015-09-17 07:33:24 +00:00
|
|
|
struct rmsgpack_dom_value *items;
|
2015-09-17 04:39:17 +00:00
|
|
|
} array;
|
|
|
|
} val;
|
2015-01-19 21:47:09 +00:00
|
|
|
};
|
|
|
|
|
2015-09-17 05:23:36 +00:00
|
|
|
struct rmsgpack_dom_pair
|
|
|
|
{
|
2015-01-19 21:47:09 +00:00
|
|
|
struct rmsgpack_dom_value key;
|
|
|
|
struct rmsgpack_dom_value value;
|
|
|
|
};
|
|
|
|
|
2015-09-17 07:33:24 +00:00
|
|
|
void rmsgpack_dom_value_print(struct rmsgpack_dom_value *obj);
|
|
|
|
void rmsgpack_dom_value_free(struct rmsgpack_dom_value *v);
|
|
|
|
|
2015-01-19 21:47:09 +00:00
|
|
|
int rmsgpack_dom_value_cmp(
|
2015-09-17 07:33:24 +00:00
|
|
|
const struct rmsgpack_dom_value *a, const struct rmsgpack_dom_value *b);
|
|
|
|
|
|
|
|
struct rmsgpack_dom_value *rmsgpack_dom_value_map_value(
|
|
|
|
const struct rmsgpack_dom_value *map,
|
|
|
|
const struct rmsgpack_dom_value *key);
|
2015-01-19 21:47:09 +00:00
|
|
|
|
2015-09-17 17:57:51 +00:00
|
|
|
int rmsgpack_dom_read(RFILE *fd, struct rmsgpack_dom_value *out);
|
2015-01-19 21:47:09 +00:00
|
|
|
|
2015-09-17 17:57:51 +00:00
|
|
|
int rmsgpack_dom_write(RFILE *fd, const struct rmsgpack_dom_value *obj);
|
2015-01-23 05:05:54 +00:00
|
|
|
|
2015-09-17 17:57:51 +00:00
|
|
|
int rmsgpack_dom_read_into(RFILE *fd, ...);
|
2015-01-23 05:05:54 +00:00
|
|
|
|
2016-06-03 05:58:15 +00:00
|
|
|
RETRO_END_DECLS
|
2015-01-23 05:05:54 +00:00
|
|
|
|
2015-01-19 21:47:09 +00:00
|
|
|
#endif
|