![]() | ![]() | ![]() | Gwyddion Library Reference Manual | ![]() |
---|
GwyContainer — A container with items identified by a GQuark.
#define GWY_CONTAINER_PATHSEP #define GWY_CONTAINER_PATHSEP_STR void (*GwyContainerNotifyFunc) (GwyContainer *container, const guchar *path, gpointer user_data); typedef GwyKeyVal; struct GwyContainer; GObject* gwy_container_new (void); GType gwy_container_value_type (GwyContainer *container, GQuark key); gboolean gwy_container_contains (GwyContainer *container, GQuark key); GValue gwy_container_get_value (GwyContainer *container, GQuark key); void gwy_container_set_value (GwyContainer *container, ...); void gwy_container_set_value_by_name (GwyContainer *container, ...); gboolean gwy_container_remove (GwyContainer *container, GQuark key); gsize gwy_container_remove_by_prefix (GwyContainer *container, const gchar *prefix); gboolean gwy_container_rename (GwyContainer *container, GQuark key, GQuark newkey, gboolean force); gsize gwy_container_foreach (GwyContainer *container, const gchar *prefix, GHFunc function, gpointer user_data); void gwy_container_set_boolean (GwyContainer *container, GQuark key, gboolean value); gboolean gwy_container_get_boolean (GwyContainer *container, GQuark key); gboolean gwy_container_gis_boolean (GwyContainer *container, GQuark key, gboolean *value); void gwy_container_set_uchar (GwyContainer *container, GQuark key, guchar value); guchar gwy_container_get_uchar (GwyContainer *container, GQuark key); gboolean gwy_container_gis_uchar (GwyContainer *container, GQuark key, guchar *value); void gwy_container_set_int32 (GwyContainer *container, GQuark key, gint32 value); gint32 gwy_container_get_int32 (GwyContainer *container, GQuark key); gboolean gwy_container_gis_int32 (GwyContainer *container, GQuark key, gint32 *value); void gwy_container_set_int64 (GwyContainer *container, GQuark key, gint64 value); gint64 gwy_container_get_int64 (GwyContainer *container, GQuark key); gboolean gwy_container_gis_int64 (GwyContainer *container, GQuark key, gint64 *value); void gwy_container_set_double (GwyContainer *container, GQuark key, gdouble value); gdouble gwy_container_get_double (GwyContainer *container, GQuark key); gboolean gwy_container_gis_double (GwyContainer *container, GQuark key, gdouble *value); void gwy_container_set_string (GwyContainer *container, GQuark key, const guchar *value); guchar* gwy_container_get_string (GwyContainer *container, GQuark key); gboolean gwy_container_gis_string (GwyContainer *container, GQuark key, const guchar **value); void gwy_container_set_object (GwyContainer *container, GQuark key, GObject *value); GObject* gwy_container_get_object (GwyContainer *container, GQuark key); gboolean gwy_container_gis_object (GwyContainer *container, GQuark key, GObject **value); #define gwy_container_value_type_by_name(c,n) #define gwy_container_contains_by_name (c,n) #define gwy_container_get_value_by_name (c,n) #define gwy_container_remove_by_name (c,n) #define gwy_container_rename_by_name (c,n,nn,f) #define gwy_container_set_boolean_by_name(c,n,v) #define gwy_container_get_boolean_by_name(c,n) #define gwy_container_gis_boolean_by_name(c,n,v) #define gwy_container_set_uchar_by_name (c,n,v) #define gwy_container_get_uchar_by_name (c,n) #define gwy_container_gis_uchar_by_name (c,n,v) #define gwy_container_set_int32_by_name (c,n,v) #define gwy_container_get_int32_by_name (c,n) #define gwy_container_gis_int32_by_name (c,n,v) #define gwy_container_set_int64_by_name (c,n,v) #define gwy_container_get_int64_by_name (c,n) #define gwy_container_gis_int64_by_name (c,n,v) #define gwy_container_set_double_by_name(c,n,v) #define gwy_container_get_double_by_name(c,n) #define gwy_container_gis_double_by_name(c,n,v) #define gwy_container_set_string_by_name(c,n,v) #define gwy_container_get_string_by_name(c,n) #define gwy_container_gis_string_by_name(c,n,v) #define gwy_container_set_object_by_name(c,n,v) #define gwy_container_get_object_by_name(c,n) #define gwy_container_gis_object_by_name(c,n,v)
GObject +----GwyContainer
GwyContainer implements GwySerializable.
A general-purpose container. Items in GwyContainer are identified by a GQuark (or its string).
#define GWY_CONTAINER_PATHSEP '/'
Path separator to be used for hierarchical structures in the container.
#define GWY_CONTAINER_PATHSEP_STR "/"
Path separator to be used for hierarchical structures in the container, as a string.
void (*GwyContainerNotifyFunc) (GwyContainer *container, const guchar *path, gpointer user_data);
container: | |
path: | |
user_data: |
GObject* gwy_container_new (void);
Creates a new GwyContainer.
Returns : | The container, as a GObject. |
GType gwy_container_value_type (GwyContainer *container, GQuark key);
Returns the type of value in container identified by key.
container: | A GwyContainer. |
key: | A GQuark key. |
Returns : | The value type as GType. |
gboolean gwy_container_contains (GwyContainer *container, GQuark key);
Returns TRUE if container contains a value identified by key.
container: | A GwyContainer. |
key: | A GQuark key. |
Returns : | Whether container contains something identified by key. |
GValue gwy_container_get_value (GwyContainer *container, GQuark key);
Returns the value in container identified by key.
container: | A GwyContainer. |
key: | A GQuark key. |
Returns : | The value as a GValue. |
void gwy_container_set_value (GwyContainer *container, ...);
Inserts or updates several values in container.
container: | A GwyContainer. |
...: | A NULL-terminated list of GQuark keys and GValue values. |
void gwy_container_set_value_by_name (GwyContainer *container, ...);
Inserts or updates several values in container.
container: | A GwyContainer. |
...: | A NULL-terminated list of string keys and GValue values. |
gboolean gwy_container_remove (GwyContainer *container, GQuark key);
Removes a value identified by key from container.
container: | A GwyContainer. |
key: | A GQuark key. |
Returns : | TRUE if there was such a value and was removed. |
gsize gwy_container_remove_by_prefix (GwyContainer *container, const gchar *prefix);
Removes a values whose key start with prefix from container container.
prefix can be NULL, all values are then removed.
container: | A GwyContainer. |
prefix: | A nul-terminated id prefix. |
Returns : | The number of values removed. |
gboolean gwy_container_rename (GwyContainer *container, GQuark key, GQuark newkey, gboolean force);
Makes a value in container identified by key to be identified by newkey.
When force is TRUE existing value at newkey is removed from container. When it's FALSE, an existing value newkey inhibits the rename and FALSE is returned.
container: | A GwyContainer. |
key: | The current key. |
newkey: | A new key for the value. |
force: | Whether to delete existing value at newkey. |
Returns : | Whether the rename succeeded. |
gsize gwy_container_foreach (GwyContainer *container, const gchar *prefix, GHFunc function, gpointer user_data);
Calls function on each container item whose identifier starts with prefix.
The function is called function(GQuark key, GValue *value, user_data).
An empty prefix means function will be called on all container items with a name. A NULL prefix means function will be called on all container, even those identified only by a stray nameless GQuark.
container: | A GwyContainer. |
prefix: | A nul-terminated id prefix. |
function: | The function called on the items. |
user_data: | The user data passed to function. |
Returns : | The number of items function was called on. |
void gwy_container_set_boolean (GwyContainer *container, GQuark key, gboolean value);
Stores a boolean into container, identified by key.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | A boolean. |
gboolean gwy_container_get_boolean (GwyContainer *container, GQuark key);
Returns the boolean in container identified by key.
container: | A GwyContainer. |
key: | A GQuark key. |
Returns : | The boolean as gboolean. |
gboolean gwy_container_gis_boolean (GwyContainer *container, GQuark key, gboolean *value);
Get-if-set a boolean from container.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | Pointer to the boolean to update. |
Returns : | TRUE if v was actually updated, FALSE when there is no such boolean in the container. |
void gwy_container_set_uchar (GwyContainer *container, GQuark key, guchar value);
Stores an unsigned character into container, identified by key.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | An unsigned character. |
guchar gwy_container_get_uchar (GwyContainer *container, GQuark key);
Returns the unsigned character in container identified by key.
container: | A GwyContainer. |
key: | A GQuark key. |
Returns : | The character as guchar. |
gboolean gwy_container_gis_uchar (GwyContainer *container, GQuark key, guchar *value);
Get-if-set an unsigned char from container.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | Pointer to the unsigned char to update. |
Returns : | TRUE if v was actually updated, FALSE when there is no such unsigned char in the container. |
void gwy_container_set_int32 (GwyContainer *container, GQuark key, gint32 value);
Stores a 32bit integer into container, identified by key.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | A 32bit integer. |
gint32 gwy_container_get_int32 (GwyContainer *container, GQuark key);
Returns the 32bit integer in container identified by key.
container: | A GwyContainer. |
key: | A GQuark key. |
Returns : | The integer as guint32. |
gboolean gwy_container_gis_int32 (GwyContainer *container, GQuark key, gint32 *value);
Get-if-set a 32bit integer from container.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | Pointer to the 32bit integer to update. |
Returns : | TRUE if v was actually updated, FALSE when there is no such 32bit integer in the container. |
void gwy_container_set_int64 (GwyContainer *container, GQuark key, gint64 value);
Stores a 64bit integer into container, identified by key.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | A 64bit integer. |
gint64 gwy_container_get_int64 (GwyContainer *container, GQuark key);
Returns the 64bit integer in container identified by key.
container: | A GwyContainer. |
key: | A GQuark key. |
Returns : | The 64bit integer as guint64. |
gboolean gwy_container_gis_int64 (GwyContainer *container, GQuark key, gint64 *value);
Get-if-set a 64bit integer from container.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | Pointer to the 64bit integer to update. |
Returns : | TRUE if v was actually updated, FALSE when there is no such 64bit integer in the container. |
void gwy_container_set_double (GwyContainer *container, GQuark key, gdouble value);
Stores a double into container, identified by key.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | A double. |
gdouble gwy_container_get_double (GwyContainer *container, GQuark key);
Returns the double in container identified by key.
container: | A GwyContainer. |
key: | A GQuark key. |
Returns : | The double as gdouble. |
gboolean gwy_container_gis_double (GwyContainer *container, GQuark key, gdouble *value);
Get-if-set a double from container.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | Pointer to the double to update. |
Returns : | TRUE if v was actually updated, FALSE when there is no such double in the container. |
void gwy_container_set_string (GwyContainer *container, GQuark key, const guchar *value);
Stores a string into container, identified by key.
The container takes ownership of the string, so it can't be used on static strings, use g_strdup() to duplicate them first.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | A nul-terminated string. |
guchar* gwy_container_get_string (GwyContainer *container, GQuark key);
Returns the string in container identified by key.
The returned string must be treated as constant and never freed or modified.
container: | A GwyContainer. |
key: | A GQuark key. |
Returns : | The string. |
gboolean gwy_container_gis_string (GwyContainer *container, GQuark key, const guchar **value);
Get-if-set a string from container.
The string eventually stored in value must be treated as constant and never freed or modified.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | Pointer to the string pointer to update. |
Returns : | TRUE if v was actually updated, FALSE when there is no such string in the container. |
void gwy_container_set_object (GwyContainer *container, GQuark key, GObject *value);
Stores an object into container, identified by key.
The container claims ownership on the object, i.e. its reference count is incremented.
The object must implement GwySerializable interface to allow serialization of the container. It also has to implement GwyWatchable interface to allow watching of value changes.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | An object as GObject. |
GObject* gwy_container_get_object (GwyContainer *container, GQuark key);
Returns the object in container identified by key.
The returned object doesn't have its reference count increased, use g_object_ref() if you want to access it even when container may cease to exist.
container: | A GwyContainer. |
key: | A GQuark key. |
Returns : | The object as GObject. |
gboolean gwy_container_gis_object (GwyContainer *container, GQuark key, GObject **value);
Get-if-set an object from container.
The object eventually stored in value doesn't have its reference count increased, use g_object_ref() if you want to access it even when container may cease to exist.
container: | A GwyContainer. |
key: | A GQuark key. |
value: | Pointer to the object pointer to update. |
Returns : | TRUE if v was actually updated, FALSE when there is no such object in the container. |
#define gwy_container_value_type_by_name(c,n) gwy_container_value_type(c,g_quark_try_string(n))
Gets the type of value in container c identified by name n.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
#define gwy_container_contains_by_name(c,n) gwy_container_contains(c,g_quark_try_string(n))
Expands to TRUE if container c contains a value identified by name n.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
#define gwy_container_get_value_by_name(c,n) gwy_container_get_value(c,g_quark_try_string(n))
Gets the value in container c identified by name n.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
#define gwy_container_remove_by_name(c,n) gwy_container_remove(c,g_quark_try_string(n))
Removes a value identified by name n from container c.
Expands to TRUE if there was such a value and was removed.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
#define gwy_container_rename_by_name(c,n,nn,f) gwy_container_rename(c,g_quark_try_string(n),g_quark_from_string(nn),f)
Makes a value in container c identified by name n to be identified by new name nn.
See gwy_container_rename() for details.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
nn: | A nul-terminated name (id). |
f: | Whether to delete existing value at newkey. |
#define gwy_container_set_boolean_by_name(c,n,v) gwy_container_set_boolean(c,g_quark_from_string(n),v)
Stores a boolean into container c, identified by name n.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | A boolean. |
#define gwy_container_get_boolean_by_name(c,n) gwy_container_get_boolean(c,g_quark_try_string(n))
Gets the boolean in container c identified by name n.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
#define gwy_container_gis_boolean_by_name(c,n,v) gwy_container_gis_boolean(c,g_quark_from_string(n),v)
Get-if-set a boolean from c.
Expands to TRUE if value was actually updated, FALSE when there is no such boolean in the container.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | Pointer to the boolean to update. |
#define gwy_container_set_uchar_by_name(c,n,v) gwy_container_set_uchar(c,g_quark_from_string(n),v)
Stores an unsigned character into container c, identified by name n.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | An unsigned character. |
#define gwy_container_get_uchar_by_name(c,n) gwy_container_get_uchar(c,g_quark_try_string(n))
Gets the unsigned character in container c identified by name n.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
#define gwy_container_gis_uchar_by_name(c,n,v) gwy_container_gis_uchar(c,g_quark_from_string(n),v)
Get-if-set an unsigned char from c.
Expands to TRUE if value was actually updated, FALSE when there is no such unsigned char in the container.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | Pointer to the unsigned char to update. |
#define gwy_container_set_int32_by_name(c,n,v) gwy_container_set_int32(c,g_quark_from_string(n),v)
Stores a 32bit integer into container c, identified by name n.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | A 32bit integer. |
#define gwy_container_get_int32_by_name(c,n) gwy_container_get_int32(c,g_quark_try_string(n))
Gets the 32bit integer in container c identified by name n.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
#define gwy_container_gis_int32_by_name(c,n,v) gwy_container_gis_int32(c,g_quark_from_string(n),v)
Get-if-set a 32bit integer from c.
Expands to TRUE if value was actually updated, FALSE when there is no such 32bit integer in the container.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | Pointer to the 32bit integer to update. |
#define gwy_container_set_int64_by_name(c,n,v) gwy_container_set_int64(c,g_quark_from_string(n),v)
Stores a 64bit integer into container c, identified by name n.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | A 64bit integer. |
#define gwy_container_get_int64_by_name(c,n) gwy_container_get_int64(c,g_quark_try_string(n))
Gets the 64bit integer in container c identified by name n.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
#define gwy_container_gis_int64_by_name(c,n,v) gwy_container_gis_int64(c,g_quark_from_string(n),v)
Get-if-set a 64bit integer from c.
Expands to TRUE if value was actually updated, FALSE when there is no such 64bit integer in the container.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | Pointer to the 64bit integer to update. |
#define gwy_container_set_double_by_name(c,n,v) gwy_container_set_double(c,g_quark_from_string(n),v)
Stores a double into container c, identified by name n.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | A double integer. |
#define gwy_container_get_double_by_name(c,n) gwy_container_get_double(c,g_quark_try_string(n))
Gets the double in container c identified by name n.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
#define gwy_container_gis_double_by_name(c,n,v) gwy_container_gis_double(c,g_quark_from_string(n),v)
Get-if-set a double from c.
Expands to TRUE if value was actually updated, FALSE when there is no such double in the container.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | Pointer to the double to update. |
#define gwy_container_set_string_by_name(c,n,v) gwy_container_set_string(c,g_quark_from_string(n),v)
Stores a string into container c, identified by name n.
The container takes ownership of the string, so it can't be used on static strings, use g_strdup() to duplicate them first.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | A nul-terminated string. |
#define gwy_container_get_string_by_name(c,n) gwy_container_get_string(c,g_quark_try_string(n))
Gets the string in container c identified by name n.
The returned string must be treated as constant and never freed or modified.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
#define gwy_container_gis_string_by_name(c,n,v) gwy_container_gis_string(c,g_quark_from_string(n),v)
Get-if-set a string from c.
The string eventually stored in v must be treated as constant and never freed or modified.
Expands to TRUE if value was actually updated, FALSE when there is no such string in the container.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | Pointer to the string pointer to update. |
#define gwy_container_set_object_by_name(c,n,v) gwy_container_set_object(c,g_quark_from_string(n),v)
Stores an object into container c, identified by name n.
See gwy_container_set_object() for details.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | An object as GObject. |
#define gwy_container_get_object_by_name(c,n) gwy_container_get_object(c,g_quark_try_string(n))
Gets the object in container c identified by name n.
The returned object doesn't have its reference count increased, use g_object_ref() if you want to access it even when container may cease to exist.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
#define gwy_container_gis_object_by_name(c,n,v) gwy_container_gis_object(c,g_quark_from_string(n),v)
Get-if-set an object from c.
The object eventually stored in value doesn't have its reference count increased, use g_object_ref() if you want to access it even when container may cease to exist.
Expands to TRUE if value was actually updated, FALSE when there is no such object in the container.
c: | A GwyContainer. |
n: | A nul-terminated name (id). |
v: | Pointer to the object pointer to update. |
<< GwySerializable | gwymacros >> |