Top | ![]() |
![]() |
![]() |
![]() |
#define | AS_TYPE_METADATA |
struct | AsMetadataClass |
enum | AsFormatStyle |
enum | AsFormatKind |
enum | AsFormatVersion |
#define | AS_CURRENT_FORMAT_VERSION |
enum | AsParseFlags |
enum | AsMetadataError |
#define | AS_METADATA_ERROR |
AsMetadata |
This object parses AppStream metadata, including AppStream upstream metadata, which is defined by upstream projects. It returns an AsComponent of the data.
See also: AsComponent, AsDatabase
const gchar *
as_format_kind_to_string (AsFormatKind kind
);
Converts the enumerated value to an text representation.
Since: 0.10
AsFormatKind
as_format_kind_from_string (const gchar *kind_str
);
Converts the text representation to an enumerated value.
Since: 0.10
const gchar *
as_format_version_to_string (AsFormatVersion version
);
Converts the enumerated value to an text representation.
Since: 0.10
AsFormatVersion
as_format_version_from_string (const gchar *version_str
);
Converts the text representation to an enumerated value.
Since: 0.10
void as_metadata_parse_file (AsMetadata *metad
,GFile *file
,AsFormatKind format
,GError **error
);
Parses an AppStream upstream metadata file.
metad |
A valid AsMetadata instance |
|
file |
GFile for the upstream metadata |
|
format |
The format the data is in, or |
|
error |
void as_metadata_parse (AsMetadata *metad
,const gchar *data
,AsFormatKind format
,GError **error
);
Parses AppStream metadata.
metad |
An instance of AsMetadata. |
|
data |
Metadata describing one or more software components. |
|
format |
The format of the data (XML or YAML). |
|
error |
void as_metadata_parse_desktop_data (AsMetadata *metad
,const gchar *data
,const gchar *cid
,GError **error
);
Parses XDG Desktop Entry metadata and adds it to the pool.
metad |
An instance of AsMetadata. |
|
data |
Metadata describing one or more software components. |
|
cid |
The component-id the new AsComponent should have. |
|
error |
AsComponent *
as_metadata_get_component (AsMetadata *metad
);
Gets the AsComponent which has been parsed from the XML. If the AppStream XML contained multiple components, return the first component that has been parsed.
void as_metadata_add_component (AsMetadata *metad
,AsComponent *cpt
);
Add an AsComponent to the list of components. This can be used to add multiple components in order to produce a distro-XML AppStream metadata file.
gchar * as_metadata_component_to_metainfo (AsMetadata *metad
,AsFormatKind format
,GError **error
);
Convert an AsComponent to metainfo data. This will always be XML, YAML is no valid format for metainfo files.
The amount of localization included in the metadata depends on how the AsComponent was initially loaded and whether it contains data for all locale.
The first AsComponent added to the internal list will be transformed.
In case no component is present, NULL
is returned.
void as_metadata_save_metainfo (AsMetadata *metad
,const gchar *fname
,AsFormatKind format
,GError **error
);
Serialize AsComponent instance to XML and save it to file. An existing file at the same location will be overridden.
gchar * as_metadata_components_to_collection (AsMetadata *metad
,AsFormatKind format
,GError **error
);
Serialize all AsComponent instances into AppStream
collection metadata.
NULL
is returned if there is nothing to serialize.
metad |
An instance of AsMetadata. |
|
format |
The format to serialize the data to (XML or YAML). |
|
error |
A GError |
void as_metadata_save_collection (AsMetadata *metad
,const gchar *fname
,AsFormatKind format
,GError **error
);
AsFormatVersion
as_metadata_get_format_version (AsMetadata *metad
);
void as_metadata_set_format_version (AsMetadata *metad
,AsFormatVersion version
);
Set the current AppStream format version that we should generate data for or be able to read.
metad |
a AsMetadata instance. |
|
version |
the AppStream metadata format version as AsFormatVersion. |
AsFormatStyle
as_metadata_get_format_style (AsMetadata *metad
);
Get the metadata parsing mode.
void as_metadata_set_format_style (AsMetadata *metad
,AsFormatStyle mode
);
Sets the current metadata parsing mode.
void as_metadata_set_locale (AsMetadata *metad
,const gchar *locale
);
Sets the locale which should be read when processing metadata. All other locales are ignored, which increases parsing speed and reduces memory usage. If you set the locale to "ALL", all locales will be read.
const gchar *
as_metadata_get_locale (AsMetadata *metad
);
Gets the current active locale for parsing metadata, or "ALL" if all locales are read.
void as_metadata_set_origin (AsMetadata *metad
,const gchar *origin
);
Set the origin of AppStream distro metadata
void as_metadata_set_update_existing (AsMetadata *metad
,gboolean update
);
If set to TRUE
, the parser will not create new components but
instead update existing components in the pool with new metadata.
NOTE: Right now, this feature is only implemented for metainfo XML parsing!
void as_metadata_set_write_header (AsMetadata *metad
,gboolean wheader
);
If set to TRUE
, tehe metadata writer will omit writing a DEP-11
header document when in YAML mode, and will not write a root components node
when writing XML data.
Please keep in mind that this will create an invalid DEP-11 YAML AppStream
collection metadata file, and an invalid XML file.
This parameter should only be changed e.g. by the appstream-generator tool.
NOTE: Right now, this feature is only implemented for YAML!
void as_metadata_set_architecture (AsMetadata *metad
,const gchar *arch
);
Set the architecture the components in this metadata belong to.
AsParseFlags
as_metadata_get_parse_flags (AsMetadata *metad
);
Get the metadata parse flags.
void as_metadata_set_parse_flags (AsMetadata *metad
,AsParseFlags flags
);
Sets the current metadata parse flags.
There are a few differences between AppStream's metainfo files (shipped by upstream projects) and the collection metadata (shipped by distributors). The data source kind indicates which style we should process. Usually you do not want to set this explicitly.
A metadata processing error.