summaryrefslogtreecommitdiff
path: root/contrib/json-glib-1.0.vapi
blob: fb13b6515bd4a3c91c79f1d4a71e9cada6da1ecf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* json-glib-1.0.vapi: Vala bindings for JSON-GLib
 *
 * Copyright (C) 2007  OpenedHand Ltd.
 *
 * 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.1 of the License, 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., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301  USA
 *
 * Author: Emmanuele Bassi  <ebassi@openedhand.com>
 */

[Import ()]
[CCode (cprefix = "Json", lower_case_cprefix = "json_", cheader_filename = "json-glib/json-glib.h")]
namespace Json {
        [CCode (ref_function = "json_object_ref", unref_function = "json_object_unref")]
        public class Object : GLib.Boxed {
                [CCode (cname = "json_object_new")]
                public Object ();
                public void add_member (string! name, Json.Node# node);
                public bool has_member (string! name);
                public weak Json.Node get_member (string! name);
                public Json.Node dup_member (string! name);
                public GLib.List<string> get_members ();
                public GLib.List<weak Json.Node> get_values ();
                public void remove_member (string! name);
                public uint get_size ();
        }

        [CCode (ref_function = "json_array_ref", unref_function = "json_array_unref")]
        public class Array : GLib.Boxed {
                [CCode (cname = "json_array_new")]
                public Array ();
                [CCode (cname = "json_array_sized_new")]
                public Array.sized (uint reserved_size);
                public void add_element (Json.Node# node);
                public weak Json.Node get_element (uint index_);
                public Json.Node dup_element (uint index_);
                public GLib.List<weak Json.Node> get_elements ();
                public void remove_element (uint index_);
                public uint get_length ();
        }

        [CCode (cprefix = "JSON_NODE_", cheader_filename = "json-glib/json-types.h")]
        public enum NodeType {
                OBJECT,
                ARRAY,
                VALUE,
                NULL
        }

        [CCode (copy_function = "json_node_copy", free_function = "json_node_free", type_id = "JSON_TYPE_NODE")]
        public class Node : GLib.Boxed {
                [CCode (cname = "JSON_NODE_TYPE")]
                public NodeType type ();
                public Node (NodeType type);
                public Node copy ();
                public GLib.Type get_value_type ();
                public void set_object (Json.Object v_object);
                public void take_object (Json.Object# v_object);
                public weak Json.Object get_object ();
                public Json.Object dup_object ();
                public void set_array (Json.Array v_array);
                public void take_array (Json.Array# v_array);
                public weak Json.Array get_array ();
                public Json.Array dup_array ();
                public void set_string (string value);
                public weak string get_string ();
                public string dup_string ();
                public void set_int (int value);
                public int get_int ();
                public void set_double (double value);
                public double get_double ();
                public void set_boolean (bool value);
                public bool get_boolean ();
                public weak Json.Node get_parent ();
                public weak string type_name ();
        }

        [CCode (cprefix = "JSON_PARSER_ERROR_", cheader_filename = "json-glib/json-parser.h")]
        public enum ParserError {
                PARSE,
                UNKNOWN
        }

        [CCode (cheader_filename = "json-glib/json-parser.h")]
        public class Parser : GLib.Object {
                public weak uint current_line { get; }
                public weak uint current_pos { get; }
                public Parser ();
                public bool load_from_file (string filename) throws ParserError;
                public bool load_from_data (string buffer, ulong length) throws ParserError;
                public weak Json.Node get_root ();
                public bool has_assingment (out string variable_name);
                public signal void parse_start ();
                public signal void parse_end ();
                public signal void object_start ();
                public signal void object_member (Json.Object object, string name);
                public signal void object_end (Json.Object object);
                public signal void array_start ();
                public signal void array_element (Json.Array array, uint index_);
                public signal void array_end (Json.Array array);
                public signal void error (GLib.Error error);
        }

        [CCode (cheader_filename = "json-glib/json-generator.h")]
        public class Generator : GLib.Object {
                [NoAccessorMethod]
                public weak bool pretty { get; set; }
                [NoAccessorMethod]
                public weak unichar indent_char { get; set; }
                public Json.Node root { set; }
                public Generator ();
                public string to_data (out ulong length);
                public bool to_file (string! filename) throws GLib.FileError;
                public void set_root (Json.Node node);
        }

        [CCode (cheader_filename = "json-glib/json-gobject.h")]
        public interface Serializable : GLib.Object {
                public abstract Json.Node serialize_property (string property_name, GLib.Value val, GLib.ParamSpec pspec);
                public abstract bool deserialize_property (string property_name, ref GLib.Value val, GLib.ParamSpec pspec, Json.Node node);
        }

        [CCode (cheader_filename = "json-glib/json-gobject.h")]
        public static GLib.Object construct_gobject (GLib.Type g_type, string! data, ulong length = -1);
        [CCode (cheader_filename = "json-glib/json-gobject.h")]
        public static string serialize_gobject (GLib.Object g_object, out ulong length = null);
}