mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-04 10:16:17 +01:00
merge GVariantType
GVariantType is the type system for GVariant
This commit is contained in:
parent
11d4e59712
commit
0ccb288da1
@ -119,6 +119,7 @@ synchronize their operation.
|
||||
<xi:include href="xml/relations.xml" />
|
||||
<xi:include href="xml/caches.xml" />
|
||||
<xi:include href="xml/allocators.xml" />
|
||||
<xi:include href="xml/gvarianttype.xml"/>
|
||||
</chapter>
|
||||
|
||||
<chapter id="tools">
|
||||
|
@ -2701,6 +2701,74 @@ g_test_log_buffer_pop
|
||||
g_test_log_msg_free
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<TITLE>GVariantType</TITLE>
|
||||
<FILE>gvarianttype</FILE>
|
||||
GVariantType
|
||||
G_VARIANT_TYPE_BOOLEAN
|
||||
G_VARIANT_TYPE_BYTE
|
||||
G_VARIANT_TYPE_INT16
|
||||
G_VARIANT_TYPE_UINT16
|
||||
G_VARIANT_TYPE_INT32
|
||||
G_VARIANT_TYPE_UINT32
|
||||
G_VARIANT_TYPE_INT64
|
||||
G_VARIANT_TYPE_UINT64
|
||||
G_VARIANT_TYPE_HANDLE
|
||||
G_VARIANT_TYPE_DOUBLE
|
||||
G_VARIANT_TYPE_STRING
|
||||
G_VARIANT_TYPE_OBJECT_PATH
|
||||
G_VARIANT_TYPE_SIGNATURE
|
||||
G_VARIANT_TYPE_VARIANT
|
||||
G_VARIANT_TYPE_ANY
|
||||
G_VARIANT_TYPE_BASIC
|
||||
G_VARIANT_TYPE_MAYBE
|
||||
G_VARIANT_TYPE_ARRAY
|
||||
G_VARIANT_TYPE_TUPLE
|
||||
G_VARIANT_TYPE_UNIT
|
||||
G_VARIANT_TYPE_DICT_ENTRY
|
||||
G_VARIANT_TYPE_DICTIONARY
|
||||
|
||||
<SUBSECTION>
|
||||
G_VARIANT_TYPE
|
||||
g_variant_type_free
|
||||
g_variant_type_copy
|
||||
g_variant_type_new
|
||||
|
||||
<SUBSECTION>
|
||||
g_variant_type_string_is_valid
|
||||
g_variant_type_string_scan
|
||||
g_variant_type_get_string_length
|
||||
g_variant_type_peek_string
|
||||
g_variant_type_dup_string
|
||||
|
||||
<SUBSECTION>
|
||||
g_variant_type_is_definite
|
||||
g_variant_type_is_container
|
||||
g_variant_type_is_basic
|
||||
g_variant_type_is_maybe
|
||||
g_variant_type_is_array
|
||||
g_variant_type_is_tuple
|
||||
g_variant_type_is_dict_entry
|
||||
|
||||
<SUBSECTION>
|
||||
g_variant_type_hash
|
||||
g_variant_type_equal
|
||||
g_variant_type_is_subtype_of
|
||||
|
||||
<SUBSECTION>
|
||||
g_variant_type_new_maybe
|
||||
g_variant_type_new_array
|
||||
g_variant_type_new_tuple
|
||||
g_variant_type_new_dict_entry
|
||||
|
||||
<SUBSECTION>
|
||||
g_variant_type_element
|
||||
g_variant_type_n_items
|
||||
g_variant_type_first
|
||||
g_variant_type_next
|
||||
g_variant_type_key
|
||||
g_variant_type_value
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>ghostutils</FILE>
|
||||
|
@ -171,6 +171,7 @@ libglib_2_0_la_SOURCES = \
|
||||
gunicodeprivate.h \
|
||||
gurifuncs.c \
|
||||
gutils.c \
|
||||
gvarianttype.c \
|
||||
gdebug.h \
|
||||
gprintf.c \
|
||||
gprintfint.h
|
||||
@ -248,6 +249,7 @@ glibsubinclude_HEADERS = \
|
||||
gunicode.h \
|
||||
gurifuncs.h \
|
||||
gutils.h \
|
||||
gvarianttype.h \
|
||||
gwin32.h \
|
||||
gprintf.h
|
||||
|
||||
|
@ -85,6 +85,7 @@
|
||||
#include <glib/gunicode.h>
|
||||
#include <glib/gurifuncs.h>
|
||||
#include <glib/gutils.h>
|
||||
#include <glib/gvarianttype.h>
|
||||
#ifdef G_PLATFORM_WIN32
|
||||
#include <glib/gwin32.h>
|
||||
#endif
|
||||
|
@ -1644,6 +1644,40 @@ g_match_info_fetch_all
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__G_VARIANT_TYPE_H__)
|
||||
#if IN_FILE(__G_VARIANT_TYPE_C__)
|
||||
g_variant_type_string_is_valid
|
||||
g_variant_type_string_scan
|
||||
g_variant_type_free
|
||||
g_variant_type_copy
|
||||
g_variant_type_new
|
||||
g_variant_type_get_string_length
|
||||
g_variant_type_peek_string
|
||||
g_variant_type_dup_string
|
||||
g_variant_type_is_definite
|
||||
g_variant_type_is_container
|
||||
g_variant_type_is_basic
|
||||
g_variant_type_is_maybe
|
||||
g_variant_type_is_array
|
||||
g_variant_type_is_tuple
|
||||
g_variant_type_is_dict_entry
|
||||
g_variant_type_hash
|
||||
g_variant_type_equal
|
||||
g_variant_type_is_subtype_of
|
||||
g_variant_type_element
|
||||
g_variant_type_first
|
||||
g_variant_type_next
|
||||
g_variant_type_n_items
|
||||
g_variant_type_key
|
||||
g_variant_type_value
|
||||
g_variant_type_new_array
|
||||
g_variant_type_new_maybe
|
||||
g_variant_type_new_tuple
|
||||
g_variant_type_new_dict_entry
|
||||
g_variant_type_checked_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__G_WIN32_H__)
|
||||
#if IN_FILE(__G_WIN32_H__)
|
||||
#ifdef G_OS_WIN32
|
||||
|
1495
glib/gvarianttype.c
Normal file
1495
glib/gvarianttype.c
Normal file
File diff suppressed because it is too large
Load Diff
282
glib/gvarianttype.h
Normal file
282
glib/gvarianttype.h
Normal file
@ -0,0 +1,282 @@
|
||||
/*
|
||||
* Copyright © 2007, 2008 Ryan Lortie
|
||||
* Copyright © 2009, 2010 Codethink Limited
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the licence, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Ryan Lortie <desrt@desrt.ca>
|
||||
*/
|
||||
|
||||
#ifndef __G_VARIANT_TYPE_H__
|
||||
#define __G_VARIANT_TYPE_H__
|
||||
|
||||
#include <glib/gmessages.h>
|
||||
#include <glib/gtypes.h>
|
||||
|
||||
typedef struct _GVariantType GVariantType;
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_BOOLEAN:
|
||||
*
|
||||
* The type of a value that can be either %TRUE or %FALSE.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_BOOLEAN ((const GVariantType *) "b")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_BYTE:
|
||||
*
|
||||
* The type of an integer value that can range from 0 to 255.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_BYTE ((const GVariantType *) "y")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_INT16:
|
||||
*
|
||||
* The type of an integer value that can range from -32768 to 32767.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_INT16 ((const GVariantType *) "n")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_UINT16:
|
||||
*
|
||||
* The type of an integer value that can range from 0 to 65535.
|
||||
* There were about this many people living in Toronto in the 1870s.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_UINT16 ((const GVariantType *) "q")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_INT32:
|
||||
*
|
||||
* The type of an integer value that can range from -2147483648 to
|
||||
* 2147483647.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_INT32 ((const GVariantType *) "i")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_UINT32:
|
||||
*
|
||||
* The type of an integer value that can range from 0 to 4294967295.
|
||||
* That's one number for everyone who was around in the late 1970s.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_UINT32 ((const GVariantType *) "u")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_INT64:
|
||||
*
|
||||
* The type of an integer value that can range from
|
||||
* -9223372036854775808 to 9223372036854775807.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_INT64 ((const GVariantType *) "x")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_UINT64:
|
||||
*
|
||||
* The type of an integer value that can range from 0 to
|
||||
* 18446744073709551616. That's a really big number, but a Rubik's
|
||||
* cube can have a bit more than twice as many possible positions.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_UINT64 ((const GVariantType *) "t")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_DOUBLE:
|
||||
*
|
||||
* The type of a double precision IEEE754 floating point number.
|
||||
* These guys go up to about 1.80e308 (plus and minus) but miss out on
|
||||
* some numbers in between. In any case, that's far greater than the
|
||||
* estimated number of fundamental particles in the observable
|
||||
* universe.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_DOUBLE ((const GVariantType *) "d")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_STRING:
|
||||
*
|
||||
* The type of a string. "" is a string. %NULL is not a string.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_STRING ((const GVariantType *) "s")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_OBJECT_PATH:
|
||||
*
|
||||
* The type of a DBus object reference. These are strings of a
|
||||
* specific format used to identify objects at a given destination on
|
||||
* the bus.
|
||||
*
|
||||
* If you are not interacting with DBus, then there is no reason to make
|
||||
* use of this type. If you are, then the DBus specification contains a
|
||||
* precise description of valid object paths.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_OBJECT_PATH ((const GVariantType *) "o")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_SIGNATURE:
|
||||
*
|
||||
* The type of a DBus type signature. These are strings of a specific
|
||||
* format used as type signatures for DBus methods and messages.
|
||||
*
|
||||
* If you are not interacting with DBus, then there is no reason to make
|
||||
* use of this type. If you are, then the DBus specification contains a
|
||||
* precise description of valid signature strings.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_SIGNATURE ((const GVariantType *) "g")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_VARIANT:
|
||||
*
|
||||
* The type of a box that contains any other value (including another
|
||||
* variant).
|
||||
**/
|
||||
#define G_VARIANT_TYPE_VARIANT ((const GVariantType *) "v")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_HANDLE:
|
||||
*
|
||||
* The type of a 32bit signed integer value, that by convention, is used
|
||||
* as an index into an array of file descriptors that are sent alongside
|
||||
* a DBus message.
|
||||
*
|
||||
* If you are not interacting with DBus, then there is no reason to make
|
||||
* use of this type.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_HANDLE ((const GVariantType *) "h")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_UNIT:
|
||||
*
|
||||
* The empty tuple type. Has only one instance. Known also as "triv"
|
||||
* or "void".
|
||||
**/
|
||||
#define G_VARIANT_TYPE_UNIT ((const GVariantType *) "()")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_ANY:
|
||||
*
|
||||
* An indefinite type that is a supertype of every type (including
|
||||
* itself).
|
||||
**/
|
||||
#define G_VARIANT_TYPE_ANY ((const GVariantType *) "*")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_BASIC:
|
||||
*
|
||||
* An indefinite type that is a supertype of every basic (ie:
|
||||
* non-container) type.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_BASIC ((const GVariantType *) "?")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_MAYBE:
|
||||
*
|
||||
* An indefinite type that is a supertype of every maybe type.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_MAYBE ((const GVariantType *) "m*")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_ARRAY:
|
||||
*
|
||||
* An indefinite type that is a supertype of every array type.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_ARRAY ((const GVariantType *) "a*")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_TUPLE:
|
||||
*
|
||||
* An indefinite type that is a supertype of every tuple type,
|
||||
* regardless of the number of items in the tuple.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_TUPLE ((const GVariantType *) "r")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_DICT_ENTRY:
|
||||
*
|
||||
* An indefinite type that is a supertype of every dictionary entry
|
||||
* type.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_DICT_ENTRY ((const GVariantType *) "{?*}")
|
||||
|
||||
/**
|
||||
* G_VARIANT_TYPE_DICTIONARY:
|
||||
*
|
||||
* An indefinite type that is a supertype of every dictionary type --
|
||||
* that is, any array type that has an element type equal to any
|
||||
* dictionary entry type.
|
||||
**/
|
||||
#define G_VARIANT_TYPE_DICTIONARY ((const GVariantType *) "a{?*}")
|
||||
|
||||
#ifndef G_DISABLE_CHECKS
|
||||
# define G_VARIANT_TYPE(str) (g_variant_type_checked_ ((str)))
|
||||
#else
|
||||
# define G_VARIANT_TYPE(str) ((const GVariantType *) (str))
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* type string checking */
|
||||
gboolean g_variant_type_string_is_valid (const gchar *type_string);
|
||||
gboolean g_variant_type_string_scan (const gchar *string,
|
||||
const gchar *limit,
|
||||
const gchar **endptr);
|
||||
|
||||
/* create/destroy */
|
||||
void g_variant_type_free (GVariantType *type);
|
||||
GVariantType * g_variant_type_copy (const GVariantType *type);
|
||||
GVariantType * g_variant_type_new (const gchar *type_string);
|
||||
|
||||
/* getters */
|
||||
gsize g_variant_type_get_string_length (const GVariantType *type);
|
||||
const gchar * g_variant_type_peek_string (const GVariantType *type);
|
||||
gchar * g_variant_type_dup_string (const GVariantType *type);
|
||||
|
||||
/* classification */
|
||||
gboolean g_variant_type_is_definite (const GVariantType *type);
|
||||
gboolean g_variant_type_is_container (const GVariantType *type);
|
||||
gboolean g_variant_type_is_basic (const GVariantType *type);
|
||||
gboolean g_variant_type_is_maybe (const GVariantType *type);
|
||||
gboolean g_variant_type_is_array (const GVariantType *type);
|
||||
gboolean g_variant_type_is_tuple (const GVariantType *type);
|
||||
gboolean g_variant_type_is_dict_entry (const GVariantType *type);
|
||||
|
||||
/* for hash tables */
|
||||
guint g_variant_type_hash (gconstpointer type);
|
||||
gboolean g_variant_type_equal (gconstpointer type1,
|
||||
gconstpointer type2);
|
||||
|
||||
/* subtypes */
|
||||
gboolean g_variant_type_is_subtype_of (const GVariantType *type,
|
||||
const GVariantType *supertype);
|
||||
|
||||
/* type iterator interface */
|
||||
const GVariantType * g_variant_type_element (const GVariantType *type);
|
||||
const GVariantType * g_variant_type_first (const GVariantType *type);
|
||||
const GVariantType * g_variant_type_next (const GVariantType *type);
|
||||
gsize g_variant_type_n_items (const GVariantType *type);
|
||||
const GVariantType * g_variant_type_key (const GVariantType *type);
|
||||
const GVariantType * g_variant_type_value (const GVariantType *type);
|
||||
|
||||
/* constructors */
|
||||
GVariantType * g_variant_type_new_array (const GVariantType *element);
|
||||
GVariantType * g_variant_type_new_maybe (const GVariantType *element);
|
||||
GVariantType * g_variant_type_new_tuple (const GVariantType * const *items,
|
||||
gint length);
|
||||
GVariantType * g_variant_type_new_dict_entry (const GVariantType *key,
|
||||
const GVariantType *value);
|
||||
|
||||
/*< private >*/
|
||||
const GVariantType * g_variant_type_checked_ (const gchar *);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __G_VARIANT_TYPE_H__ */
|
Loading…
Reference in New Issue
Block a user