RetroArch/libretro-db
Twinaphex 2a39dc7045
Merge pull request #7594 from markwkidd/patch-2
fix libretro-db Makefile
2018-11-15 21:50:57 +01:00
..
lua Add hint defines to libretro.h 2017-12-11 12:53:47 +01:00
.gitignore libretro-db: Ignore compiled binaries 2018-04-14 14:08:28 -04:00
bintree.c
bintree.h
c_converter_test.sh
c_converter.c libretro-db: Fix whitespace 2018-04-14 14:10:40 -04:00
dat_converter
libretrodb_tool.c Clean up trailing whitespace 2017-12-12 00:24:18 -08:00
libretrodb.c Don't use mmap for libretrodb - using mmap seems 2018-02-13 07:34:19 +01:00
libretrodb.h
Makefile fix libretro-db Makefile 2018-11-15 10:38:24 -05:00
query.c Clean up trailing whitespace 2017-12-12 00:24:18 -08:00
query.h
README.md update, expand, and re-sequence libretro-db doc 2018-11-15 13:02:41 -05:00
rmsgpack_dom.c Clean up trailing whitespace 2017-12-12 00:24:18 -08:00
rmsgpack_dom.h
rmsgpack_test.c Add hint defines to libretro.h 2017-12-11 12:53:47 +01:00
rmsgpack.c Cleanups - fix warnings 2018-05-07 15:05:59 +02:00
rmsgpack.h

libretrodb

A small read only database Mainly to be used by retroarch

Usage

Files specified later in the chain will override earlier ones if the same key exists multiple times.

  • To list out the content of a db libretrodb_tool <db file> list
  • To create an index libretrodb_tool <db file> create-index <index name> <field name>
  • To find an entry with an index libretrodb_tool <db file> find <index name> <value>

Compiling a single database with c_converter

git clone git@github.com:libretro/libretro-super.git
cd libretro-super
./libretro-fetch.sh retroarch
cd retroarch
./configure
cd libretro-db
c_converter "NAME_OF_RDB_FILE.rdb" "NAME_OF_SOURCE_DAT.dat"

Compiling all databases with libretro-build-database.sh

This approach builds and uses the c_converter program to compile the databases

git clone git@github.com:libretro/libretro-super.git
cd libretro-super
./libretro-fetch.sh retroarch
cd retroarch
./configure
cd ..
./libretro-build-database.sh

Lua DAT file converter

To convert a dat file use:

dat_converter <db file> <dat file>

If you want to merge multiple dat files you need to run:

dat_converter <db file> <match key> <dat file> ...

for example:

dat_converter snes.rdb rom.crc snes1.dat snes2.dat

Query examples

Some examples of queries you can use with libretrodbtool:

  1. Glob pattern matching Usecase : Search for all games starting with 'Street Fighter' in the 'name' field (glob pattern matching)

libretrodb_tool <db file> find "{'name':glob('Street Fighter*')}"

  1. Combined number matching query Usecase: Search for all games released on October 1995.

libretrodb_tool <db file> find "{'releasemonth':10,'releaseyear':1995}"

  1. Names only search Usecase: Search for all games released on October 1995, wont print checksums, filename or rom size, only the game name.

libretrodb_tool <db file> get-names "{'releasemonth':10,'releaseyear':1995}"

Writing Lua converters

In order to write you own converter you must have a lua file that implements the following functions:

-- this function gets called before the db is created and should validate the
-- arguments and set up the ground for db insertion
function init(...)
	local args = {...}
	local script_name = args[1]
end

-- this is in iterator function. It is called before each insert.
-- the function should return a table for insertion or nil when there are no
-- more records to insert.
function get_value()
	return {
		key = "value", -- will be saved as string
		num = 3, -- will be saved as int
		bin = binary("some string"), -- will be saved as binary
		unum = uint(3), -- will be saved as uint
		some_bool = true, -- will be saved as bool
	}
end