AsDatabase: AppStream Library Reference Manual

## AsDatabase AsDatabase — Read-only access to the AppStream component database |

## Functions

AsDatabase * | as_database_new ()
GQuark | as_database_error_quark ()
gboolean | as_database_open ()
const gchar * | as_database_get_location ()
void | as_database_set_location ()
GPtrArray * | as_database_find_components ()
GPtrArray * | as_database_get_all_components ()
AsComponent * | as_database_get_component_by_id ()
GPtrArray * | as_database_get_components_by_provided_item ()
GPtrArray * | as_database_get_components_by_kind ()

## Types and Values

#define | AS_TYPE_DATABASE
struct | AsDatabaseClass
enum | AsDatabaseError
#define | AS_DATABASE_ERROR
| AsDatabase

## Object Hierarchy

        GObject
        ╰── AsDatabase

## Includes

    #include <appstream.h>

## Description

This object provides access to the Appstream Xapian database of available software components. You can search for components using various criteria, as well as getting some information about the data provided by this AppStream database.

By default, the global software component cache is used as datasource, unless a different database is explicitly defined via `as_database_set_location`().

A new cache can be created using the appstreamcli(1) utility.

See also: AsComponent, AsDataPool

## Functions

### as_database_new ()

    AsDatabase *
    as_database_new (void);

Creates a new AsDatabase.

#### Returns

a AsDatabase.

[transfer full]

### as_database_error_quark ()

    GQuark
    as_database_error_quark (void);

#### Returns

An error quark.

### as_database_open ()

    gboolean
    as_database_open (AsDatabase *db,
                      GError **error);

Open the current AppStream metadata cache for reading.

#### Parameters

db | An instance of AsDatabase. |
error | A GError or `NULL`. |

#### Returns

`TRUE` on success, `FALSE` on error.

### as_database_get_location ()

    const gchar *
    as_database_get_location (AsDatabase *db);

Get the current path of the AppStream database we use.

#### Parameters

db | An instance of AsDatabase. |

### as_database_set_location ()

    void
    as_database_set_location (AsDatabase *db,
                              const gchar *dir);

Set the location of the AppStream database we use.

#### Parameters

db | An instance of AsDatabase. |
dir | The directory of the Xapian database. |

### as_database_find_components ()

    GPtrArray *
    as_database_find_components (AsDatabase *db,
                                 const gchar *term,
                                 const gchar *cats_str,
                                 GError **error);

Find components in the AppStream database, which match a given term. You can limit the search to a specific set of categories by setting the categories string to a semicolon-separated list of lower-cased category names.

#### Parameters

db | An instance of AsDatabase. |
term | a search-term to look for. | [nullable]
cats_str | A semicolon-delimited list of lower-cased category names, e.g. "science;development". | [nullable]
error | A GError or `NULL`. |

#### Returns

an array of AsComponent objects which have been found.

[element-type AsComponent][transfer full]

### as_database_get_all_components ()

    GPtrArray *
    as_database_get_all_components (AsDatabase *db,
                                    GError **error);

Dump a list of all software components found in the database.

#### Parameters

db | An instance of AsDatabase. |
error | A GError or `NULL`. |

#### Returns

an array of AsComponent objects.

[element-type AsComponent][transfer full]

### as_database_get_component_by_id ()

    AsComponent *
    as_database_get_component_by_id (AsDatabase *db,
                                     const gchar *cid,
                                     GError **error);

Get a component by its AppStream-ID.

#### Parameters

db | An instance of AsDatabase. |
cid | the ID of the component, e.g. "org.kde.gwenview.desktop" |
error | A GError or `NULL`. |

#### Returns

an AsComponent or `NULL` if none was found.

[transfer full]

### as_database_get_components_by_provided_item ()

    GPtrArray *
    as_database_get_components_by_provided_item
                                   (AsDatabase *db,
                                    AsProvidedKind kind,
                                    const gchar *item,
                                    GError **error);

Find components in the Appstream database.

#### Parameters

db | An instance of AsDatabase. |
kind | an AsProvidesKind |
item | the name of the provided item. |
error | A GError or `NULL`. |

#### Returns

an array of AsComponent objects which have been found, NULL on error.

[element-type AsComponent][transfer full]

### as_database_get_components_by_kind ()

    GPtrArray *
    as_database_get_components_by_kind (AsDatabase *db,
                                        AsComponentKind kind,
                                        GError **error);

Return a list of all components in the database which match a certain kind.

#### Parameters

db | An instance of AsDatabase. |
kind | an AsComponentKind. |
error | A GError or `NULL`. |

#### Returns

an array of AsComponent objects which have been found, `NULL` on error.

[element-type AsComponent][transfer full]

## Types and Values

### AS_TYPE_DATABASE

    #define AS_TYPE_DATABASE (as_database_get_type ())

### struct AsDatabaseClass

    struct AsDatabaseClass {
    	GObjectClass parent_class;
    };

### enum AsDatabaseError

A database query error.

#### Members

AS_DATABASE_ERROR_FAILED | Generic failure |
AS_DATABASE_ERROR_MISSING | Database was not found |
AS_DATABASE_ERROR_CLOSED | Tried to perform action on a closed database. |
AS_DATABASE_ERROR_TERM_INVALID | A query term was invalid. |

### AS_DATABASE_ERROR

    #define AS_DATABASE_ERROR as_database_error_quark ()

### AsDatabase

    typedef struct _AsDatabase AsDatabase;