Blame docs/reference/glib/html/glib-Quarks.html

Packit ae235b
Packit ae235b
<html>
Packit ae235b
<head>
Packit ae235b
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Packit ae235b
<title>Quarks: GLib Reference Manual</title>
Packit ae235b
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
Packit ae235b
<link rel="home" href="index.html" title="GLib Reference Manual">
Packit ae235b
<link rel="up" href="glib-data-types.html" title="GLib Data Types">
Packit ae235b
<link rel="prev" href="glib-N-ary-Trees.html" title="N-ary Trees">
Packit ae235b
<link rel="next" href="glib-Keyed-Data-Lists.html" title="Keyed Data Lists">
Packit ae235b
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
Packit ae235b
<link rel="stylesheet" href="style.css" type="text/css">
Packit ae235b
</head>
Packit ae235b
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit ae235b
Packit ae235b
Packit ae235b
Top  | 
Packit ae235b
                  Description
Packit ae235b
Packit ae235b
Home
Packit ae235b
Up
Packit ae235b
Prev
Packit ae235b
Next
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Quarks

Packit ae235b

Quarks — a 2-way association between a string and a

Packit ae235b
    unique integer identifier

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
#define
Packit ae235b
Packit ae235b
G_DEFINE_QUARK()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GQuark
Packit ae235b
Packit ae235b
Packit ae235b
g_quark_from_string ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GQuark
Packit ae235b
Packit ae235b
Packit ae235b
g_quark_from_static_string ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
const gchar *
Packit ae235b
Packit ae235b
Packit ae235b
g_quark_to_string ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GQuark
Packit ae235b
Packit ae235b
Packit ae235b
g_quark_try_string ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
const gchar *
Packit ae235b
Packit ae235b
Packit ae235b
g_intern_string ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
const gchar *
Packit ae235b
Packit ae235b
Packit ae235b
g_intern_static_string ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
typedef
Packit ae235b
GQuark
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Includes

Packit ae235b
#include <gmodule.h>
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Description

Packit ae235b

Quarks are associations between strings and integer identifiers.

Packit ae235b
Given either the string or the GQuark identifier it is possible to
Packit ae235b
retrieve the other.

Packit ae235b

Quarks are used for both datasets and

Packit ae235b
keyed data lists.

Packit ae235b

To create a new quark from a string, use g_quark_from_string() or

Packit ae235b
g_quark_from_static_string().

Packit ae235b

To find the string corresponding to a given GQuark, use

Packit ae235b
g_quark_to_string().

Packit ae235b

To find the GQuark corresponding to a given string, use

Packit ae235b
g_quark_try_string().

Packit ae235b

Another use for the string pool maintained for the quark functions

Packit ae235b
is string interning, using g_intern_string() or
Packit ae235b
g_intern_static_string(). An interned string is a canonical
Packit ae235b
representation for a string. One important advantage of interned
Packit ae235b
strings is that they can be compared for equality by a simple
Packit ae235b
pointer comparison, rather than using strcmp().

Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b

G_DEFINE_QUARK()

Packit ae235b
#define             G_DEFINE_QUARK(QN, q_n)
Packit ae235b

A convenience macro which defines a function returning the

Packit ae235b
GQuark for the name QN
Packit ae235b
. The function will be named
Packit ae235b
q_n_quark()
Packit ae235b
.

Packit ae235b

Note that the quark name will be stringified automatically

Packit ae235b
in the macro, so you shouldn't use double quotes.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

QN

Packit ae235b

the name to return a GQuark for

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

q_n

Packit ae235b

prefix for the function name

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Since: 2.34

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_quark_from_string ()

Packit ae235b
GQuark
Packit ae235b
g_quark_from_string (const gchar *string);
Packit ae235b

Gets the GQuark identifying the given string. If the string does

Packit ae235b
not currently have an associated GQuark, a new GQuark is created,
Packit ae235b
using a copy of the string.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

string

Packit ae235b

a string.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the GQuark identifying the string, or 0 if string

Packit ae235b
is NULL

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_quark_from_static_string ()

Packit ae235b
GQuark
Packit ae235b
g_quark_from_static_string (const gchar *string);
Packit ae235b

Gets the GQuark identifying the given (static) string. If the

Packit ae235b
string does not currently have an associated GQuark, a new GQuark
Packit ae235b
is created, linked to the given string.

Packit ae235b

Note that this function is identical to g_quark_from_string() except

Packit ae235b
that if a new GQuark is created the string itself is used rather
Packit ae235b
than a copy. This saves memory, but can only be used if the string
Packit ae235b
will continue to exist until the program terminates. It can be used
Packit ae235b
with statically allocated strings in the main program, but not with
Packit ae235b
statically allocated memory in dynamically loaded modules, if you
Packit ae235b
expect to ever unload the module again (e.g. do not use this
Packit ae235b
function in GTK+ theme engines).

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

string

Packit ae235b

a string.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the GQuark identifying the string, or 0 if string

Packit ae235b
is NULL

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_quark_to_string ()

Packit ae235b
const gchar *
Packit ae235b
g_quark_to_string (GQuark quark);
Packit ae235b

Gets the string associated with the given GQuark.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

quark

Packit ae235b

a GQuark.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the string associated with the GQuark

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_quark_try_string ()

Packit ae235b
GQuark
Packit ae235b
g_quark_try_string (const gchar *string);
Packit ae235b

Gets the GQuark associated with the given string, or 0 if string is

Packit ae235b
NULL or it has no associated GQuark.

Packit ae235b

If you want the GQuark to be created if it doesn't already exist,

Packit ae235b
use g_quark_from_string() or g_quark_from_static_string().

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

string

Packit ae235b

a string.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the GQuark associated with the string, or 0 if string

Packit ae235b
is
Packit ae235b
NULL or there is no GQuark associated with it

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_intern_string ()

Packit ae235b
const gchar *
Packit ae235b
g_intern_string (const gchar *string);
Packit ae235b

Returns a canonical representation for string

Packit ae235b
. Interned strings
Packit ae235b
can be compared for equality by comparing the pointers, instead of
Packit ae235b
using strcmp().

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

string

Packit ae235b

a string.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

a canonical representation for the string

Packit ae235b
Packit ae235b

Since: 2.10

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_intern_static_string ()

Packit ae235b
const gchar *
Packit ae235b
g_intern_static_string (const gchar *string);
Packit ae235b

Returns a canonical representation for string

Packit ae235b
. Interned strings
Packit ae235b
can be compared for equality by comparing the pointers, instead of
Packit ae235b
using strcmp(). g_intern_static_string() does not copy the string,
Packit ae235b
therefore string
Packit ae235b
 must not be freed or modified.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

string

Packit ae235b

a static string.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

a canonical representation for the string

Packit ae235b
Packit ae235b

Since: 2.10

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b

GQuark

Packit ae235b
typedef guint32 GQuark;
Packit ae235b
Packit ae235b

A GQuark is a non-zero integer which uniquely identifies a

Packit ae235b
particular string. A GQuark value of zero is associated to NULL.

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Generated by GTK-Doc V1.27
Packit ae235b
</body>
Packit ae235b
</html>