Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
metadata_repository.h File Reference

main.meta_data: the free-text image metadata (title, description, creator, publisher, rights, notes, version name). More...

#include <glib.h>
#include <stdint.h>
+ Include dependency graph for metadata_repository.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dt_metadata_row_t
 

Typedefs

typedef struct dt_metadata_row_t dt_metadata_row_t
 
typedef void(* dt_metadata_repository_row_cb) (void *user_data, const int keyid, const char *value)
 One main.meta_data row: its key id and its value.
 
typedef void(* dt_metadata_repository_selected_cb) (void *user_data, const int keyid, const char *value, const uint32_t count)
 One distinct (key, value) across the selection, and how many selected images carry it.
 

Functions

G_BEGIN_DECLS GListdt_metadata_repository_get_values (const int32_t imgid, const int keyid)
 Values stored under keyid, ordered by value.
 
GListdt_metadata_repository_get_all (const int32_t imgid)
 Every (key, value) pair of imgid, as a flat list.
 
void dt_metadata_repository_remove (const int32_t imgid, const char *keyid_list)
 Delete the rows of imgid whose key is in keyid_list, a comma-separated list of decimal key ids. Does nothing when keyid_list is NULL.
 
void dt_metadata_repository_add (const dt_metadata_row_t *rows, const size_t count)
 Insert count rows as a single multi-VALUES statement.
 
int32_t dt_metadata_repository_find_image_by_value (const char *value)
 The first image carrying value under any key, or -1.
 
void dt_metadata_repository_foreach (const int32_t imgid, dt_metadata_repository_row_cb cb, void *user_data)
 Every metadata row of imgid, in row order.
 
void dt_metadata_repository_foreach_selected (dt_metadata_repository_selected_cb cb, void *user_data)
 Every distinct (key, value) pair across main.selected_images, ordered by value.
 
void dt_metadata_repository_cleanup (void)
 Finalise the prepared statements. See dt_colorlabel_repository_cleanup().
 

Detailed Description

main.meta_data: the free-text image metadata (title, description, creator, publisher, rights, notes, version name).

One row per (image, key, value), key being a dt_metadata_t index rather than a name – the names live in common/metadata.c, which owns the mapping, the XMP spellings and the visibility flags.

Note
Several functions here take an imgid where a negative value means "every selected image" rather than "no image". That is the convention dt_metadata_get() has always used (id == -1 from the GUI meaning "the selection", any other value meaning the image under the cursor), and it is preserved rather than corrected because the callers pass it straight through from the GUI.

Definition in file metadata_repository.h.

Typedef Documentation

◆ dt_metadata_repository_row_cb

typedef void(* dt_metadata_repository_row_cb) (void *user_data, const int keyid, const char *value)

One main.meta_data row: its key id and its value.

Definition at line 96 of file metadata_repository.h.

◆ dt_metadata_repository_selected_cb

typedef void(* dt_metadata_repository_selected_cb) (void *user_data, const int keyid, const char *value, const uint32_t count)

One distinct (key, value) across the selection, and how many selected images carry it.

Definition at line 104 of file metadata_repository.h.

◆ dt_metadata_row_t

One (image, key, value) row to insert.

Function Documentation

◆ dt_metadata_repository_add()

void dt_metadata_repository_add ( const dt_metadata_row_t rows,
const size_t  count 
)

Insert count rows as a single multi-VALUES statement.

Quoting is done here, with sqlite3_mprintf("%q", …). It used to be done by the caller, which is why common/metadata.c linked against sqlite for one function call: a module that has to escape its own strings for SQL is still writing SQL. Nothing happens when count is 0.

Definition at line 106 of file metadata_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, i, dt_metadata_row_t::imgid, IS_NULL_PTR, dt_metadata_row_t::keyid, L, TRUE, and value.

Referenced by _bulk_add_metadata(), and test_metadata_foreach_selected().

◆ dt_metadata_repository_cleanup()

void dt_metadata_repository_cleanup ( void  )

Finalise the prepared statements. See dt_colorlabel_repository_cleanup().

Definition at line 184 of file metadata_repository.c.

Referenced by dt_metadata_cleanup(), and testdb_teardown().

◆ dt_metadata_repository_find_image_by_value()

int32_t dt_metadata_repository_find_image_by_value ( const char *  value)

The first image carrying value under any key, or -1.

Used to recognise an already-imported file by the filename-datetime marker the importer stores. Matches on value alone, across every key.

Definition at line 133 of file metadata_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, L, and value.

Referenced by dt_metadata_already_imported().

◆ dt_metadata_repository_foreach()

void dt_metadata_repository_foreach ( const int32_t  imgid,
dt_metadata_repository_row_cb  cb,
void user_data 
)

Every metadata row of imgid, in row order.

Definition at line 149 of file metadata_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.

Referenced by dt_set_xmp_dt_metadata().

◆ dt_metadata_repository_foreach_selected()

void dt_metadata_repository_foreach_selected ( dt_metadata_repository_selected_cb  cb,
void user_data 
)

Every distinct (key, value) pair across main.selected_images, ordered by value.

One pass instead of one dt_metadata_repository_get_values() call per key, which is what the panel needs: for each field it must know both the values present and whether every selected image agrees on one – hence the count travelling with the pair.

Definition at line 163 of file metadata_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, and L.

Referenced by _update(), and test_metadata_foreach_selected().

◆ dt_metadata_repository_get_all()

GList * dt_metadata_repository_get_all ( const int32_t  imgid)

Every (key, value) pair of imgid, as a flat list.

Returns
alternating entries: a newly allocated decimal string of the keyid, then its newly allocated value. That shape is what dt_metadata_get_list_id() has always returned and what the XMP writer consumes.

Definition at line 69 of file metadata_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, L, and value.

Referenced by dt_metadata_get_list_id().

◆ dt_metadata_repository_get_values()

G_BEGIN_DECLS GList * dt_metadata_repository_get_values ( const int32_t  imgid,
const int  keyid 
)

Values stored under keyid, ordered by value.

Parameters
imgidthe image, or a negative value for every selected image.
Returns
a GList of newly allocated strings, never containing NULL (a NULL column comes back as ""). Free with g_list_free_full(l, g_free).

Definition at line 28 of file metadata_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, IS_NULL_PTR, L, and value.

Referenced by dt_metadata_get().

◆ dt_metadata_repository_remove()

void dt_metadata_repository_remove ( const int32_t  imgid,
const char *  keyid_list 
)

Delete the rows of imgid whose key is in keyid_list, a comma-separated list of decimal key ids. Does nothing when keyid_list is NULL.

Definition at line 91 of file metadata_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, IS_NULL_PTR, and L.

Referenced by _bulk_remove_metadata().