### Class

# GObject ParamSpec

#### Description

    abstract class GObject.ParamSpec : GObject.TypeInstance
    {
      name: const gchar*,
      flags: GParamFlags,
      value_type: GType,
      owner_type: GType
    }

`GParamSpec` encapsulates the metadata required to specify parameters, such as `GObject` properties.

## Parameter names

A property name consists of one or more segments consisting of ASCII letters and digits, separated by either the `-` or `_` character. The first character of a property name must be a letter. These are the same rules as for signal naming (see `g_signal_new()`).

When creating and looking up a `GParamSpec`, either separator can be used, but they cannot be mixed. Using `-` is considerably more efficient, and is the ‘canonical form’. Using `_` is discouraged.

#### Descendants

- GParamSpecBoolean
- GParamSpecBoxed
- GParamSpecChar
- GParamSpecDouble
- GParamSpecEnum
- GParamSpecFlags
- GParamSpecFloat
- GParamSpecGType
- GParamSpecInt
- GParamSpecInt64
- GParamSpecLong
- GParamSpecObject
- GParamSpecOverride
- GParamSpecParam
- GParamSpecPointer
- GParamSpecString
- GParamSpecUChar
- GParamSpecUInt
- GParamSpecUInt64
- GParamSpecULong
- GParamSpecUnichar
- GParamSpecValueArray
- GParamSpecVariant

#### Functions

###### g_param_spec_internal

Creates a new `GParamSpec` instance.

###### g_param_spec_is_valid_name

Validate a property name for a `GParamSpec`. This can be useful for dynamically-generated properties which need to be validated at run-time before actually trying to create them.

since: 2.66

#### Instance methods

###### g_param_spec_get_blurb

Get the short description of a `GParamSpec`.

###### g_param_spec_get_default_value

Gets the default value of `pspec` as a pointer to a `GValue`.

since: 2.38

###### g_param_spec_get_name

Get the name of a `GParamSpec`.

###### g_param_spec_get_name_quark

Gets the GQuark for the name.

since: 2.46

###### g_param_spec_get_nick

Get the nickname of a `GParamSpec`.

###### g_param_spec_get_qdata

Gets back user data pointers stored via g_param_spec_set_qdata().

###### g_param_spec_get_redirect_target

If the paramspec redirects operations to another paramspec, returns that paramspec. Redirect is used typically for providing a new implementation of a property in a derived type while preserving all the properties from the parent type. Redirection is established by creating a property of type `GParamSpecOverride`. See `g_object_class_override_property()` for an example of the use of this capability.

since: 2.4

###### g_param_spec_ref

Increments the reference count of `pspec`.

###### g_param_spec_ref_sink

Convenience function to ref and sink a `GParamSpec`.

since: 2.10

###### g_param_spec_set_qdata

Sets an opaque, named pointer on a `GParamSpec`. The name is specified through a `GQuark` (retrieved e.g. via g_quark_from_static_string()), and the pointer can be gotten back from the `pspec` with g_param_spec_get_qdata(). Setting a previously set user data pointer, overrides (frees) the old pointer set, using `NULL` as pointer essentially removes the data stored.

###### g_param_spec_set_qdata_full

This function works like g_param_spec_set_qdata(), but in addition, a `void (*destroy) (gpointer)` function may be specified which is called with `data` as argument when the `pspec` is finalized, or the data is being overwritten by a call to `g_param_spec_set_qdata()` with the same `quark`.

###### g_param_spec_sink

The initial reference count of a newly created `GParamSpec` is 1, even though no one has explicitly called `g_param_spec_ref()` on it yet. So the initial reference count is flagged as “floating”, until someone calls `g_param_spec_ref (pspec); g_param_spec_sink (pspec);` in sequence on it, taking over the initial reference count (thus ending up with a `pspec` that has a reference count of 1 still, but is not flagged “floating” anymore).

###### g_param_spec_steal_qdata

Gets back user data pointers stored via `g_param_spec_set_qdata()` and removes the `data` from `pspec` without invoking its `destroy()` function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier.

###### g_param_spec_unref

Decrements the reference count of a `pspec`.

#### Class structure

    struct GObjectParamSpecClass {
      GTypeClass g_type_class;
      GType value_type;
      void (* finalize) (
        GParamSpec* pspec
      );
      void (* value_set_default) (
        GParamSpec* pspec,
        GValue* value
      );
      gboolean (* value_validate) (
        GParamSpec* pspec,
        GValue* value
      );
      gint (* values_cmp) (
        GParamSpec* pspec,
        const GValue* value1,
        const GValue* value2
      );
      gboolean (* value_is_valid) (
        GParamSpec* pspec,
        const GValue* value
      );

    }

The class structure for the GParamSpec type. Normally, GParamSpec classes are filled by g_param_type_register_static().

###### Class members

`g_type_class: GTypeClass`

  The parent class.

`value_type: GType`

  The `GValue` type for this parameter.

`finalize: void (* finalize) ( GParamSpec* pspec )`

  The instance finalization function (optional), should chain up to the finalize method of the parent class.

`value_set_default: void (* value_set_default) ( GParamSpec* pspec, GValue* value )`

  Resets a `value` to the default value for this type (recommended, the default is g_value_reset()), see g_param_value_set_default().

`value_validate: gboolean (* value_validate) ( GParamSpec* pspec, GValue* value )`

  Ensures that the contents of `value` comply with the specifications set out by this type (optional), see g_param_value_validate().

`values_cmp: gint (* values_cmp) ( GParamSpec* pspec, const GValue* value1, const GValue* value2 )`

  Compares `value1` with `value2` according to this type (recommended, the default is memcmp()), see g_param_values_cmp().

`value_is_valid: gboolean (* value_is_valid) ( GParamSpec* pspec, const GValue* value )`

  Checks if contents of `value` comply with the specifications set out by this type, without modifying the value. This vfunc is optional. If it isn’t set, GObject will use `value_validate`. Since 2.74.

#### Virtual methods

###### GObject.ParamSpecClass.finalize

The instance finalization function (optional), should chain up to the finalize method of the parent class.

###### GObject.ParamSpecClass.value_is_valid

Checks if contents of `value` comply with the specifications set out by this type, without modifying the value. This vfunc is optional. If it isn’t set, GObject will use `value_validate`. Since 2.74.

###### GObject.ParamSpecClass.value_set_default

Resets a `value` to the default value for this type (recommended, the default is g_value_reset()), see g_param_value_set_default().

###### GObject.ParamSpecClass.value_validate

Ensures that the contents of `value` comply with the specifications set out by this type (optional), see g_param_value_validate().

###### GObject.ParamSpecClass.values_cmp

Compares `value1` with `value2` according to this type (recommended, the default is memcmp()), see g_param_values_cmp().