glibmm: Gio::SettingsSchemaSource Class Reference

glibmm 2.68.1

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gio::SettingsSchemaSource Class Referencefinal

See SettingsSchema. More...

`#include <giomm/settingsschemasource.h>`

## Public Member Functions
void | reference () const
| Increment the reference count for this object. More...
void | unreference () const
| Decrement the reference count for this object. More...
GSettingsSchemaSource* | gobj ()
| Provides access to the underlying C instance. More...
const GSettingsSchemaSource* | gobj () const
| Provides access to the underlying C instance. More...
GSettingsSchemaSource* | gobj_copy () const
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
| SettingsSchemaSource ()=delete
| SettingsSchemaSource (const SettingsSchemaSource&)=delete
SettingsSchemaSource& | operator= (const SettingsSchemaSource&)=delete
Glib::RefPtr< SettingsSchema > | lookup (const Glib::ustring& schema_id, bool recursive)
| Looks up a schema with the identifier schema_id in source. More...
Glib::RefPtr< const SettingsSchema > | lookup (const Glib::ustring& schema_id, bool recursive) const
| Looks up a schema with the identifier schema_id in source. More...
std::vector< Glib::ustring > | list_schemas (bool relocatable, bool recursive) const
| Lists the schemas in a given source. More...

## Static Public Member Functions
static Glib::RefPtr< SettingsSchemaSource > | get_default ()
| Gets the default system schema source. More...
static Glib::RefPtr< SettingsSchemaSource > | create (const std::string& directory, bool trusted, const Glib::RefPtr< SettingsSchemaSource >& parent=get_default())
| Attempts to create a new schema source corresponding to the contents of the given directory. More...

## Protected Member Functions
void | operator delete (void*, std::size_t)

## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gio::SettingsSchemaSource > | wrap (GSettingsSchemaSource* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Detailed Description

See SettingsSchema.

Since glibmm 2.32:

## Constructor & Destructor Documentation

## ◆ SettingsSchemaSource() [1/2]

Gio::SettingsSchemaSource::SettingsSchemaSource | ( |  | ) |
| delete

## ◆ SettingsSchemaSource() [2/2]

Gio::SettingsSchemaSource::SettingsSchemaSource | ( | const SettingsSchemaSource& |  | ) |
| delete

## Member Function Documentation

## ◆ create()

static Glib::RefPtr<SettingsSchemaSource> Gio::SettingsSchemaSource::create | ( | const std::string & | directory,
|  | bool | trusted,
|  | const Glib::RefPtr< SettingsSchemaSource >& | parent = `get_default()`
| ) |  |
| static

Attempts to create a new schema source corresponding to the contents of the given directory.

This function is not required for normal uses of Settings but it may be useful to authors of plugin management systems.

The directory should contain a file called `gschemas.compiled` as produced by the [glib-compile-schemas][glib-compile-schemas] tool.

If trusted is `true` then `gschemas.compiled` is trusted not to be corrupted. This assumption has a performance advantage, but can result in crashes or inconsistent behaviour in the case of a corrupted file. Generally, you should set trusted to `true` for files installed by the system and to `false` for files in the home directory.

In either case, an empty file or some types of corruption in the file will result in Glib::FileError::INVALID_ARGUMENT being returned.

If parent is non-`nullptr` then there are two effects.

First, if g_settings_schema_source_lookup() is called with the recursive flag set to `true` and the schema can not be found in the source, the lookup will recurse to the parent.

Second, any references to other schemas specified within this source (ie: `child` or `extends`) references may be resolved from the parent.

For this second reason, except in very unusual situations, the parent should probably be given as the default schema source, as returned by g_settings_schema_source_get_default().

Since glibmm 2.32:

Parameters

  directory | The filename of a directory.
  parent | A SettingsSchemaSource, or `nullptr`.
  trusted | `true`, if the directory is trusted.

Exceptions

  Glib::Error |

## ◆ get_default()

static Glib::RefPtr<SettingsSchemaSource> Gio::SettingsSchemaSource::get_default | ( |  | ) |
| static

Gets the default system schema source.

This function is not required for normal uses of Settings but it may be useful to authors of plugin management systems or to those who want to introspect the content of schemas.

If no schemas are installed, `nullptr` will be returned.

The returned source may actually consist of multiple schema sources from different directories, depending on which directories were given in `XDG_DATA_DIRS` and `GSETTINGS_SCHEMA_DIR`. For this reason, all lookups performed against the default source should probably be done recursively.

Since glibmm 2.32:

Returns
  The default schema source.

## ◆ gobj() [1/2]

GSettingsSchemaSource* Gio::SettingsSchemaSource::gobj | ( |  | ) |

Provides access to the underlying C instance.

## ◆ gobj() [2/2]

const GSettingsSchemaSource* Gio::SettingsSchemaSource::gobj | ( |  | ) | const

Provides access to the underlying C instance.

## ◆ gobj_copy()

GSettingsSchemaSource* Gio::SettingsSchemaSource::gobj_copy | ( |  | ) | const

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

## ◆ list_schemas()

std::vector<Glib::ustring> Gio::SettingsSchemaSource::list_schemas | ( | bool | relocatable,
|  | bool | recursive
| ) |  | const

Lists the schemas in a given source.

Do not call this function from normal programs. It is designed for use by database editors, commandline tools, etc.

Since glibmm 2.64:

Parameters

  relocatable | Whether you want the list of relocatable schemas (`true`) or the list of non-relocatable schemas (`false`) for this source. Non-relocatable schemas are those for which you can call Gio::Settings::create() without specifying a path. Relocatable schemas are those for which you must pass a path to Gio::Settings::create().
  recursive | If `true`, the list will include parent sources. If `false`, it will only include the schemas from one source (i.e. one directory). You probably want to recurse.

Returns
  a vector of the names of the schemas matching the given parameters.

## ◆ lookup() [1/2]

Glib::RefPtr<SettingsSchema> Gio::SettingsSchemaSource::lookup | ( | const Glib::ustring& | schema_id,
|  | bool | recursive
| ) |  |

Looks up a schema with the identifier schema_id in source.

This function is not required for normal uses of Settings but it may be useful to authors of plugin management systems or to those who want to introspect the content of schemas.

If the schema isn't found directly in source and recursive is `true` then the parent sources will also be checked.

If the schema isn't found, `nullptr` is returned.

Since glibmm 2.32:

Parameters

  schema_id | A schema ID.
  recursive | `true` if the lookup should be recursive.

Returns
  A new SettingsSchema.

## ◆ lookup() [2/2]

Glib::RefPtr<const SettingsSchema> Gio::SettingsSchemaSource::lookup | ( | const Glib::ustring& | schema_id,
|  | bool | recursive
| ) |  | const

Looks up a schema with the identifier schema_id in source.

This function is not required for normal uses of Settings but it may be useful to authors of plugin management systems or to those who want to introspect the content of schemas.

If the schema isn't found directly in source and recursive is `true` then the parent sources will also be checked.

If the schema isn't found, `nullptr` is returned.

Since glibmm 2.32:

Parameters

  schema_id | A schema ID.
  recursive | `true` if the lookup should be recursive.

Returns
  A new SettingsSchema.

## ◆ operator delete()

void Gio::SettingsSchemaSource::operator delete | ( | void * | ,
|  | std::size_t |
| ) |  |
| protected

## ◆ operator=()

SettingsSchemaSource& Gio::SettingsSchemaSource::operator= | ( | const SettingsSchemaSource& |  | ) |
| delete

## ◆ reference()

void Gio::SettingsSchemaSource::reference | ( |  | ) | const

Increment the reference count for this object.

You should never need to do this manually - use the object via a RefPtr instead.

## ◆ unreference()

void Gio::SettingsSchemaSource::unreference | ( |  | ) | const

Decrement the reference count for this object.

You should never need to do this manually - use the object via a RefPtr instead.

## Friends And Related Function Documentation

## ◆ wrap()

Glib::RefPtr< Gio::SettingsSchemaSource > wrap | ( | GSettingsSchemaSource * | object,
|  | bool | take_copy = `false`
| ) |  |
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.