1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-03 00:38:44 +00:00
RetroArch/libretro-db/libretrodb.h

111 lines
3.4 KiB
C
Raw Permalink Normal View History

2017-01-22 12:40:32 +00:00
/* Copyright (C) 2010-2017 The RetroArch team
2016-03-21 17:16:05 +00:00
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (libretrodb.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.
*/
2015-01-23 04:59:47 +00:00
#ifndef __LIBRETRODB_H__
#define __LIBRETRODB_H__
#include <stdint.h>
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
#endif
2015-09-21 13:31:00 +00:00
2016-06-03 05:58:15 +00:00
#include <retro_common_api.h>
2015-09-21 13:31:00 +00:00
#include "query.h"
2015-01-23 04:59:47 +00:00
#include "rmsgpack_dom.h"
2016-06-03 05:58:15 +00:00
RETRO_BEGIN_DECLS
2015-01-23 05:05:54 +00:00
2015-09-17 07:46:26 +00:00
typedef struct libretrodb libretrodb_t;
typedef struct libretrodb_cursor libretrodb_cursor_t;
typedef struct libretrodb_index libretrodb_index_t;
typedef int (*libretrodb_value_provider)(void *ctx, struct rmsgpack_dom_value *out);
2015-01-23 04:59:47 +00:00
int libretrodb_create(RFILE *fd, libretrodb_value_provider value_provider, void *ctx);
2015-01-23 04:59:47 +00:00
2015-09-17 07:33:24 +00:00
void libretrodb_close(libretrodb_t *db);
2015-01-23 04:59:47 +00:00
int libretrodb_open(const char *path, libretrodb_t *db, bool write);
2015-01-24 03:04:56 +00:00
2015-09-17 07:33:24 +00:00
int libretrodb_create_index(libretrodb_t *db, const char *name,
2015-01-24 03:04:56 +00:00
const char *field_name);
2015-01-23 04:59:47 +00:00
2015-09-17 07:33:24 +00:00
int libretrodb_find_entry(libretrodb_t *db, const char *index_name,
const void *key, struct rmsgpack_dom_value *out);
2015-01-23 04:59:47 +00:00
2015-09-17 07:46:26 +00:00
libretrodb_t *libretrodb_new(void);
void libretrodb_free(libretrodb_t *db);
libretrodb_cursor_t *libretrodb_cursor_new(void);
void libretrodb_cursor_free(libretrodb_cursor_t *dbc);
2015-01-23 04:59:47 +00:00
/**
* libretrodb_cursor_open:
* @db : Handle to database.
* @cursor : Handle to database cursor.
* @q : Query to execute.
*
* Opens cursor to database based on query @q.
*
* Returns: 0 if successful, otherwise negative.
**/
2015-09-17 07:46:26 +00:00
int libretrodb_cursor_open(libretrodb_t *db,
libretrodb_cursor_t *cursor,
libretrodb_query_t *query);
2015-01-23 04:59:47 +00:00
/**
* libretrodb_cursor_reset:
* @cursor : Handle to database cursor.
*
* Resets cursor.
*
* Returns: ???.
**/
2015-09-17 07:33:24 +00:00
int libretrodb_cursor_reset(libretrodb_cursor_t *cursor);
2015-01-23 04:59:47 +00:00
/**
* libretrodb_cursor_close:
* @cursor : Handle to database cursor.
*
* Closes cursor and frees up allocated memory.
**/
2015-09-17 07:33:24 +00:00
void libretrodb_cursor_close(libretrodb_cursor_t *cursor);
2015-01-23 04:59:47 +00:00
2015-09-17 07:33:24 +00:00
void *libretrodb_query_compile(libretrodb_t *db, const char *query,
size_t buff_len, const char **error);
2015-01-23 04:59:47 +00:00
void libretrodb_query_free(void *q);
2015-09-17 07:33:24 +00:00
int libretrodb_cursor_read_item(libretrodb_cursor_t *cursor,
struct rmsgpack_dom_value *out);
2015-01-23 04:59:47 +00:00
2016-06-03 05:58:15 +00:00
RETRO_END_DECLS
2015-01-23 05:05:54 +00:00
2015-01-23 04:59:47 +00:00
#endif