2019-12-15 20:23:02 +01:00
|
|
|
#ifndef _CRI_UTF_H_
|
|
|
|
#define _CRI_UTF_H_
|
|
|
|
|
|
|
|
#include "../streamfile.h"
|
|
|
|
|
2020-01-24 22:52:04 +01:00
|
|
|
/* CRI @UTF (Universal Table Format?) is a generic database-like table made of rows (called records)
|
|
|
|
* and columns (called fields) that contain numbers/strings/binary data, which also can be other tables.
|
2019-12-15 20:23:02 +01:00
|
|
|
*
|
|
|
|
* A table starts with "@UTF" and defines some values (row/data/string offsets, counts, etc)
|
2020-01-24 22:52:04 +01:00
|
|
|
* then DB schema (column type+name), then rows, string table and binary data. Formats using @UTF
|
2019-12-15 20:23:02 +01:00
|
|
|
* store and read data by row number + column name. Being a generic table with no fixed schema
|
2020-01-24 22:52:04 +01:00
|
|
|
* CRI uses it for different purposes (.acf: cues, .cpk: files, .aax: bgm, .usm: video, etc),
|
|
|
|
* and seems used to serialize classes/objects too.
|
2019-12-15 20:23:02 +01:00
|
|
|
*
|
|
|
|
* (adapted from hcs's code to do multiple querys in the same table)
|
|
|
|
*/
|
|
|
|
|
|
|
|
//todo move to src/util subdir
|
|
|
|
|
|
|
|
/* opaque struct */
|
|
|
|
typedef struct utf_context utf_context;
|
|
|
|
|
|
|
|
/* open a CRI UTF table at offset, returning table name and rows. Passed streamfile is used internally for next calls */
|
2020-01-24 22:52:04 +01:00
|
|
|
utf_context* utf_open(STREAMFILE* sf, uint32_t table_offset, int* p_rows, const char** p_row_name);
|
|
|
|
void utf_close(utf_context* utf);
|
2019-12-15 20:23:02 +01:00
|
|
|
/* query calls */
|
2020-11-15 00:11:48 +01:00
|
|
|
int utf_query_s8(utf_context* utf, int row, const char* column, int8_t* value);
|
2020-01-24 22:52:04 +01:00
|
|
|
int utf_query_u8(utf_context* utf, int row, const char* column, uint8_t* value);
|
2020-11-15 00:11:48 +01:00
|
|
|
int utf_query_s16(utf_context* utf, int row, const char* column, int16_t* value);
|
2020-01-24 22:52:04 +01:00
|
|
|
int utf_query_u16(utf_context* utf, int row, const char* column, uint16_t* value);
|
2020-11-15 00:11:48 +01:00
|
|
|
int utf_query_s32(utf_context* utf, int row, const char* column, int32_t* value);
|
2020-01-24 22:52:04 +01:00
|
|
|
int utf_query_u32(utf_context* utf, int row, const char* column, uint32_t* value);
|
2020-11-15 00:11:48 +01:00
|
|
|
int utf_query_s64(utf_context* utf, int row, const char* column, int64_t* value);
|
|
|
|
int utf_query_u64(utf_context* utf, int row, const char* column, uint64_t* value);
|
2020-01-24 22:52:04 +01:00
|
|
|
int utf_query_string(utf_context* utf, int row, const char* column, const char** value);
|
|
|
|
int utf_query_data(utf_context* utf, int row, const char* column, uint32_t* offset, uint32_t* size);
|
2019-12-15 20:23:02 +01:00
|
|
|
|
|
|
|
#endif /* _CRI_UTF_H_ */
|