Regenerate, restoring full UpCast functionality.
[girtod.git] / gtk2 / json.d
blobcecc327a606908e9a73141789ae9bc4d89d09490
1 // *** DO NOT EDIT ***
2 // Automatically generated from "/usr/share/gir-1.0/Json-1.0.gir"
4 module Json;
5 public import gtk2.glib2;
6 alias gtk2.glib2 GLib2;
7 public import gtk2.gobject2;
8 alias gtk2.gobject2 GObject2;
9 public import gtk2.gio2;
10 alias gtk2.gio2 Gio2;
12 // package: "json-glib-1.0";
13 // C header: "json-glib/json-glib.h";
15 // c:symbol-prefixes: ["json"]
16 // c:identifier-prefixes: ["Json"]
18 // module Json;
21 // A JSON array type. The contents of the #JsonArray structure are private
22 // and should only be accessed by the provided API
23 struct Array {
25 // Creates a new #JsonArray.
26 // RETURNS: the newly created #JsonArray
27 static Array* /*new*/ new_()() nothrow {
28 return json_array_new();
30 static auto opCall()() {
31 return json_array_new();
34 // Creates a new #JsonArray with @n_elements slots already allocated.
35 // RETURNS: the newly created #JsonArray
36 // <n_elements>: number of slots to pre-allocate
37 static Array* /*new*/ sized_new()(uint n_elements) nothrow {
38 return json_array_sized_new(n_elements);
40 static auto opCall()(uint n_elements) {
41 return json_array_sized_new(n_elements);
44 // VERSION: 0.8
45 // Conveniently adds an array into @array. The @array takes ownership
46 // of the newly added #JsonArray
47 //
48 // See also: json_array_add_element(), json_node_take_array()
49 // <value>: a #JsonArray
50 void add_array_element(AT0)(AT0 /*Array*/ value) nothrow {
51 json_array_add_array_element(&this, UpCast!(Array*)(value));
54 // VERSION: 0.8
55 // Conveniently adds a boolean @value into @array
56 //
57 // See also: json_array_add_element(), json_node_set_boolean()
58 // <value>: a boolean value
59 void add_boolean_element()(int value) nothrow {
60 json_array_add_boolean_element(&this, value);
63 // VERSION: 0.8
64 // Conveniently adds a floating point @value into @array
65 //
66 // See also: json_array_add_element(), json_node_set_double()
67 // <value>: a floating point value
68 void add_double_element()(double value) nothrow {
69 json_array_add_double_element(&this, value);
72 // Appends @node inside @array. The array will take ownership of the
73 // #JsonNode.
74 // <node>: a #JsonNode
75 void add_element(AT0)(AT0 /*Node*/ node) nothrow {
76 json_array_add_element(&this, UpCast!(Node*)(node));
79 // VERSION: 0.8
80 // Conveniently adds an integer @value into @array
81 //
82 // See also: json_array_add_element(), json_node_set_int()
83 // <value>: an integer value
84 void add_int_element()(long value) nothrow {
85 json_array_add_int_element(&this, value);
88 // VERSION: 0.8
89 // Conveniently adds a null element into @array
90 //
91 // See also: json_array_add_element(), %JSON_NODE_NULL
92 void add_null_element()() nothrow {
93 json_array_add_null_element(&this);
96 // VERSION: 0.8
97 // Conveniently adds an object into @array. The @array takes ownership
98 // of the newly added #JsonObject
99 //
100 // See also: json_array_add_element(), json_node_take_object()
101 // <value>: a #JsonObject
102 void add_object_element(AT0)(AT0 /*Object*/ value) nothrow {
103 json_array_add_object_element(&this, UpCast!(Object*)(value));
106 // VERSION: 0.8
107 // Conveniently adds a string @value into @array
109 // See also: json_array_add_element(), json_node_set_string()
110 // <value>: a string value
111 void add_string_element(AT0)(AT0 /*char*/ value) nothrow {
112 json_array_add_string_element(&this, toCString!(char*)(value));
115 // VERSION: 0.6
116 // Retrieves a copy of the #JsonNode containing the value of the
117 // element at @index_ inside a #JsonArray
119 // index. Use json_node_free() when done.
120 // RETURNS: a copy of the #JsonNode at the requested
121 // <index_>: the index of the element to retrieve
122 Node* /*new*/ dup_element()(uint index_) nothrow {
123 return json_array_dup_element(&this, index_);
126 // VERSION: 0.8
127 // Iterates over all elements of @array and calls @func on
128 // each one of them.
130 // It is safe to change the value of a #JsonNode of the @array
131 // from within the iterator @func, but it is not safe to add or
132 // remove elements from the @array.
133 // <func>: the function to be called on each element
134 // <data>: data to be passed to the function
135 void foreach_element(AT0)(ArrayForeach func, AT0 /*void*/ data) nothrow {
136 json_array_foreach_element(&this, func, UpCast!(void*)(data));
139 // VERSION: 0.8
140 // Conveniently retrieves the array from the element at @index_
141 // inside @array
143 // See also: json_array_get_element(), json_node_get_array()
144 // RETURNS: the array
145 // <index_>: the index of the element to retrieve
146 Array* get_array_element()(uint index_) nothrow {
147 return json_array_get_array_element(&this, index_);
150 // VERSION: 0.8
151 // Conveniently retrieves the boolean value of the element at @index_
152 // inside @array
154 // See also: json_array_get_element(), json_node_get_boolean()
155 // RETURNS: the integer value
156 // <index_>: the index of the element to retrieve
157 int get_boolean_element()(uint index_) nothrow {
158 return json_array_get_boolean_element(&this, index_);
161 // VERSION: 0.8
162 // Conveniently retrieves the floating point value of the element at
163 // @index_ inside @array
165 // See also: json_array_get_element(), json_node_get_double()
166 // RETURNS: the floating point value
167 // <index_>: the index of the element to retrieve
168 double get_double_element()(uint index_) nothrow {
169 return json_array_get_double_element(&this, index_);
172 // Retrieves the #JsonNode containing the value of the element at @index_
173 // inside a #JsonArray.
174 // RETURNS: a pointer to the #JsonNode at the requested index
175 // <index_>: the index of the element to retrieve
176 Node* get_element()(uint index_) nothrow {
177 return json_array_get_element(&this, index_);
180 // Gets the elements of a #JsonArray as a list of #JsonNode<!-- -->s.
182 // containing the elements of the array. The contents of the list are
183 // owned by the array and should never be modified or freed. Use
184 // g_list_free() on the returned list when done using it
185 // RETURNS: a #GList
186 GLib2.List* /*new container*/ get_elements()() nothrow {
187 return json_array_get_elements(&this);
190 // VERSION: 0.8
191 // Conveniently retrieves the integer value of the element at @index_
192 // inside @array
194 // See also: json_array_get_element(), json_node_get_int()
195 // RETURNS: the integer value
196 // <index_>: the index of the element to retrieve
197 long get_int_element()(uint index_) nothrow {
198 return json_array_get_int_element(&this, index_);
201 // Retrieves the length of a #JsonArray
202 // RETURNS: the length of the array
203 uint get_length()() nothrow {
204 return json_array_get_length(&this);
207 // VERSION: 0.8
208 // Conveniently retrieves whether the element at @index_ is set to null
210 // See also: json_array_get_element(), JSON_NODE_TYPE(), %JSON_NODE_NULL
211 // RETURNS: %TRUE if the element is null
212 // <index_>: the index of the element to retrieve
213 int get_null_element()(uint index_) nothrow {
214 return json_array_get_null_element(&this, index_);
217 // VERSION: 0.8
218 // Conveniently retrieves the object from the element at @index_
219 // inside @array
221 // See also: json_array_get_element(), json_node_get_object()
222 // RETURNS: the object
223 // <index_>: the index of the element to retrieve
224 Object* get_object_element()(uint index_) nothrow {
225 return json_array_get_object_element(&this, index_);
228 // VERSION: 0.8
229 // Conveniently retrieves the string value of the element at @index_
230 // inside @array
232 // See also: json_array_get_element(), json_node_get_string()
234 // the #JsonArray and should not be modified or freed
235 // RETURNS: the string value; the returned string is owned by
236 // <index_>: the index of the element to retrieve
237 char* get_string_element()(uint index_) nothrow {
238 return json_array_get_string_element(&this, index_);
241 // Increase by one the reference count of a #JsonArray.
243 // increased by one.
244 // RETURNS: the passed #JsonArray, with the reference count
245 Array* /*new*/ ref_()() nothrow {
246 return json_array_ref(&this);
249 // Removes the #JsonNode inside @array at @index_ freeing its allocated
250 // resources.
251 // <index_>: the position of the element to be removed
252 void remove_element()(uint index_) nothrow {
253 json_array_remove_element(&this, index_);
256 // Decreases by one the reference count of a #JsonArray. If the
257 // reference count reaches zero, the array is destroyed and all
258 // its allocated resources are freed.
259 void unref()() nothrow {
260 json_array_unref(&this);
265 // VERSION: 0.8
266 // The function to be passed to json_array_foreach_element(). You
267 // should not add or remove elements to and from @array within
268 // this function. It is safe to change the value of @element_node.
269 // <array>: the iterated #JsonArray
270 // <index_>: the index of the element
271 // <element_node>: a #JsonNode containing the value at @index_
272 // <user_data>: data passed to the function
273 extern (C) alias void function (Array* array, uint index_, Node* element_node, void* user_data) nothrow ArrayForeach;
276 // Unintrospectable callback: BoxedDeserializeFunc() / ()
277 // VERSION: 0.10
278 // Deserializes the contents of the passed #JsonNode into a #GBoxed
279 // RETURNS: the newly created boxed type
280 // <node>: a #JsonNode
281 extern (C) alias void* function (Node* node) nothrow BoxedDeserializeFunc;
284 // VERSION: 0.10
285 // Serializes the passed #GBoxed and stores it inside a #JsonNode
286 // RETURNS: the newly created #JsonNode
287 // <boxed>: a #GBoxed
288 extern (C) alias Node* /*new*/ function (const(void)* boxed) nothrow BoxedSerializeFunc;
291 // The <structname>JsonBuilder</structname> structure contains only
292 // private data and shouls be accessed using the provided API
293 struct Builder /* : GObject.Object */ /* Version 0.12 */ {
294 alias parent_instance this;
295 alias parent_instance super_;
296 alias parent_instance object;
297 GObject2.Object parent_instance;
298 private BuilderPrivate* priv;
301 // Creates a new #JsonBuilder. You can use this object to generate a
302 // JSON tree and obtain the root #JsonNode<!-- -->s.
303 // RETURNS: the newly created #JsonBuilder instance
304 static Builder* /*new*/ new_()() nothrow {
305 return json_builder_new();
307 static auto opCall()() {
308 return json_builder_new();
311 // If called after json_builder_set_member_name(), sets @value as member of the
312 // most recent opened object, otherwise @value is added as element of the most
313 // recent opened array.
315 // See also: json_builder_add_value()
316 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
317 // <value>: the value of the member or element
318 Builder* add_boolean_value()(int value) nothrow {
319 return json_builder_add_boolean_value(&this, value);
322 // If called after json_builder_set_member_name(), sets @value as member of the
323 // most recent opened object, otherwise @value is added as element of the most
324 // recent opened array.
326 // See also: json_builder_add_value()
327 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
328 // <value>: the value of the member or element
329 Builder* add_double_value()(double value) nothrow {
330 return json_builder_add_double_value(&this, value);
333 // If called after json_builder_set_member_name(), sets @value as member of the
334 // most recent opened object, otherwise @value is added as element of the most
335 // recent opened array.
337 // See also: json_builder_add_value()
338 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
339 // <value>: the value of the member or element
340 Builder* add_int_value()(long value) nothrow {
341 return json_builder_add_int_value(&this, value);
344 // If called after json_builder_set_member_name(), sets null as member of the
345 // most recent opened object, otherwise null is added as element of the most
346 // recent opened array.
348 // See also: json_builder_add_value()
349 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
350 Builder* add_null_value()() nothrow {
351 return json_builder_add_null_value(&this);
354 // If called after json_builder_set_member_name(), sets @value as member of the
355 // most recent opened object, otherwise @value is added as element of the most
356 // recent opened array.
358 // See also: json_builder_add_value()
359 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
360 // <value>: the value of the member or element
361 Builder* add_string_value(AT0)(AT0 /*char*/ value) nothrow {
362 return json_builder_add_string_value(&this, toCString!(char*)(value));
365 // If called after json_builder_set_member_name(), sets @node as member of the
366 // most recent opened object, otherwise @node is added as element of the most
367 // recent opened array.
368 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
369 // <node>: the value of the member or element
370 Builder* add_value(AT0)(AT0 /*Node*/ node) nothrow {
371 return json_builder_add_value(&this, UpCast!(Node*)(node));
374 // Opens a subarray inside the given @builder. When done adding members to
375 // the subarray, json_builder_end_array() must be called.
377 // Can be called for first or only if the call is associated to an object member
378 // or an array element.
379 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
380 Builder* begin_array()() nothrow {
381 return json_builder_begin_array(&this);
384 // Opens a subobject inside the given @builder. When done adding members to
385 // the subobject, json_builder_end_object() must be called.
387 // Can be called for first or only if the call is associated to an object member
388 // or an array element.
389 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
390 Builder* begin_object()() nothrow {
391 return json_builder_begin_object(&this);
394 // Closes the subarray inside the given @builder that was opened by the most
395 // recent call to json_builder_begin_array().
397 // Cannot be called after json_builder_set_member_name().
398 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
399 Builder* end_array()() nothrow {
400 return json_builder_end_array(&this);
403 // Closes the subobject inside the given @builder that was opened by the most
404 // recent call to json_builder_begin_object().
406 // Cannot be called after json_builder_set_member_name().
407 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
408 Builder* end_object()() nothrow {
409 return json_builder_end_object(&this);
412 // Returns the root of the current constructed tree, if the build is complete
413 // (ie: all opened objects, object members and arrays are being closed).
415 // Free the returned value with json_node_free().
416 // RETURNS: the #JsonNode, or %NULL if the build is not complete.
417 Node* /*new*/ get_root()() nothrow {
418 return json_builder_get_root(&this);
420 // Resets the state of the @builder back to its initial state.
421 void reset()() nothrow {
422 json_builder_reset(&this);
425 // Set the name of the next member in an object. The next call must add a value,
426 // open an object or an array.
428 // Can be called only if the call is associated to an object.
429 // RETURNS: the #JsonBuilder, or %NULL if the call was inconsistent
430 // <member_name>: the name of the member
431 Builder* set_member_name(AT0)(AT0 /*char*/ member_name) nothrow {
432 return json_builder_set_member_name(&this, toCString!(char*)(member_name));
437 // The <structname>JsonBuilder</structname> structure contains only
438 // private data
439 struct BuilderClass /* Version 0.12 */ {
440 private GObject2.ObjectClass parent_class;
441 extern (C) void function () nothrow _json_reserved1;
442 extern (C) void function () nothrow _json_reserved2;
445 struct BuilderPrivate {
449 // JSON data streams generator. The contents of the #JsonGenerator structure
450 // are private and should only be accessed via the provided API.
451 struct Generator /* : GObject.Object */ {
452 alias parent_instance this;
453 alias parent_instance super_;
454 alias parent_instance object;
455 GObject2.Object parent_instance;
456 private GeneratorPrivate* priv;
459 // Creates a new #JsonGenerator. You can use this object to generate a
460 // JSON data stream starting from a data object model composed by
461 // #JsonNode<!-- -->s.
462 // RETURNS: the newly created #JsonGenerator instance
463 static Generator* /*new*/ new_()() nothrow {
464 return json_generator_new();
466 static auto opCall()() {
467 return json_generator_new();
470 // VERSION: 0.14
471 // Retrieves the value set using json_generator_set_indent().
472 // RETURNS: the number of repetitions per indentation level
473 uint get_indent()() nothrow {
474 return json_generator_get_indent(&this);
477 // VERSION: 0.14
478 // Retrieves the value set using json_generator_set_indent_char().
479 // RETURNS: the character to be used when indenting
480 dchar get_indent_char()() nothrow {
481 return json_generator_get_indent_char(&this);
484 // VERSION: 0.14
485 // Retrieves the value set using json_generator_set_pretty().
487 // %FALSE otherwise
488 // RETURNS: %TRUE if the generated JSON should be pretty-printed, and
489 int get_pretty()() nothrow {
490 return json_generator_get_pretty(&this);
493 // VERSION: 0.14
494 // Retrieves a pointer to the root #JsonNode set using
495 // json_generator_set_root().
497 // is owned by the #JsonGenerator and it should not be freed
498 // RETURNS: a #JsonNode, or %NULL. The returned node
499 Node* get_root()() nothrow {
500 return json_generator_get_root(&this);
503 // VERSION: 0.14
504 // Sets the number of repetitions for each indentation level.
505 // <indent_level>: the number of repetitions of the indentation character that should be applied when pretty printing
506 void set_indent()(uint indent_level) nothrow {
507 json_generator_set_indent(&this, indent_level);
510 // VERSION: 0.14
511 // Sets the character to be used when indenting
512 // <indent_char>: a Unicode character to be used when indenting
513 void set_indent_char()(dchar indent_char) nothrow {
514 json_generator_set_indent_char(&this, indent_char);
517 // VERSION: 0.14
518 // Sets whether the generated JSON should be pretty printed, using the
519 // indentation character specified in the #JsonGenerator:indent-char
520 // property and the spacing specified in #JsonGenerator:indent property.
521 // <is_pretty>: whether the generated string should be pretty printed
522 void set_pretty()(int is_pretty) nothrow {
523 json_generator_set_pretty(&this, is_pretty);
526 // Sets @node as the root of the JSON data stream to be serialized by
527 // the #JsonGenerator.
529 // <note>The node is copied by the generator object, so it can be safely
530 // freed after calling this function.</note>
531 // <node>: a #JsonNode
532 void set_root(AT0)(AT0 /*Node*/ node) nothrow {
533 json_generator_set_root(&this, UpCast!(Node*)(node));
536 // Generates a JSON data stream from @generator and returns it as a
537 // buffer.
539 // Use g_free() to free the allocated resources.
540 // RETURNS: a newly allocated buffer holding a JSON data stream.
541 // <length>: return location for the length of the returned buffer, or %NULL
542 char* /*new*/ to_data(AT0)(/*out*/ AT0 /*size_t*/ length) nothrow {
543 return json_generator_to_data(&this, UpCast!(size_t*)(length));
546 // Creates a JSON data stream and puts it inside @filename, overwriting the
547 // current file contents. This operation is atomic.
548 // RETURNS: %TRUE if saving was successful.
549 // <filename>: path to the target file
550 int to_file(AT0, AT1)(AT0 /*char*/ filename, AT1 /*GLib2.Error**/ error=null) nothrow {
551 return json_generator_to_file(&this, toCString!(char*)(filename), UpCast!(GLib2.Error**)(error));
554 // VERSION: 0.12
555 // Outputs JSON data and streams it (synchronously) to @stream.
557 // on failure. In case of error, the #GError will be filled accordingly
558 // RETURNS: %TRUE if the write operation was successful, and %FALSE
559 // <stream>: a #GOutputStream
560 // <cancellable>: a #GCancellable, or %NULL
561 int to_stream(AT0, AT1, AT2)(AT0 /*Gio2.OutputStream*/ stream, AT1 /*Gio2.Cancellable*/ cancellable, AT2 /*GLib2.Error**/ error=null) nothrow {
562 return json_generator_to_stream(&this, UpCast!(Gio2.OutputStream*)(stream), UpCast!(Gio2.Cancellable*)(cancellable), UpCast!(GLib2.Error**)(error));
566 // #JsonGenerator class
567 struct GeneratorClass {
568 private GObject2.ObjectClass parent_class;
569 extern (C) void function () nothrow _json_reserved1;
570 extern (C) void function () nothrow _json_reserved2;
571 extern (C) void function () nothrow _json_reserved3;
572 extern (C) void function () nothrow _json_reserved4;
575 struct GeneratorPrivate {
579 // A generic container of JSON data types. The contents of the #JsonNode
580 // structure are private and should only be accessed via the provided
581 // functions and never directly.
582 struct Node {
584 // Creates a new #JsonNode of @type.
585 // RETURNS: the newly created #JsonNode
586 // <type>: a #JsonNodeType
587 static Node* /*new*/ new_()(NodeType type) nothrow {
588 return json_node_new(type);
590 static auto opCall()(NodeType type) {
591 return json_node_new(type);
594 // Copies @node. If the node contains complex data types then the reference
595 // count of the objects is increased.
596 // RETURNS: the copied #JsonNode
597 Node* /*new*/ copy()() nothrow {
598 return json_node_copy(&this);
601 // Retrieves the #JsonArray stored inside a #JsonNode and returns it
602 // with its reference count increased by one.
604 // count increased.
605 // RETURNS: the #JsonArray with its reference
606 Array* /*new*/ dup_array()() nothrow {
607 return json_node_dup_array(&this);
610 // Retrieves the #JsonObject inside @node. The reference count of
611 // the returned object is increased.
612 // RETURNS: the #JsonObject
613 Object* /*new*/ dup_object()() nothrow {
614 return json_node_dup_object(&this);
617 // Gets a copy of the string value stored inside a #JsonNode
619 // of the #JsonNode contents. Use g_free() to free the allocated resources
620 // RETURNS: a newly allocated string containing a copy
621 char* /*new*/ dup_string()() nothrow {
622 return json_node_dup_string(&this);
624 // Frees the resources allocated by @node.
625 void free()() nothrow {
626 json_node_free(&this);
629 // Retrieves the #JsonArray stored inside a #JsonNode
630 // RETURNS: the #JsonArray
631 Array* get_array()() nothrow {
632 return json_node_get_array(&this);
635 // Gets the boolean value stored inside a #JsonNode
636 // RETURNS: a boolean value.
637 int get_boolean()() nothrow {
638 return json_node_get_boolean(&this);
641 // Gets the double value stored inside a #JsonNode
642 // RETURNS: a double value.
643 double get_double()() nothrow {
644 return json_node_get_double(&this);
647 // Gets the integer value stored inside a #JsonNode
648 // RETURNS: an integer value.
649 long get_int()() nothrow {
650 return json_node_get_int(&this);
653 // VERSION: 0.8
654 // Retrieves the #JsonNodeType of @node
655 // RETURNS: the type of the node
656 NodeType get_node_type()() nothrow {
657 return json_node_get_node_type(&this);
660 // Retrieves the #JsonObject stored inside a #JsonNode
661 // RETURNS: the #JsonObject
662 Object* get_object()() nothrow {
663 return json_node_get_object(&this);
666 // Retrieves the parent #JsonNode of @node.
668 // the root node
669 // RETURNS: the parent node, or %NULL if @node is
670 Node* get_parent()() nothrow {
671 return json_node_get_parent(&this);
674 // Gets the string value stored inside a #JsonNode
675 // RETURNS: a string value.
676 char* get_string()() nothrow {
677 return json_node_get_string(&this);
680 // Retrieves a value from a #JsonNode and copies into @value. When done
681 // using it, call g_value_unset() on the #GValue.
682 // <value>: return location for an uninitialized value
683 void get_value(AT0)(/*out*/ AT0 /*GObject2.Value*/ value) nothrow {
684 json_node_get_value(&this, UpCast!(GObject2.Value*)(value));
687 // VERSION: 0.4
688 // Returns the #GType of the payload of the node.
689 // RETURNS: a #GType for the payload.
690 Type get_value_type()() nothrow {
691 return json_node_get_value_type(&this);
694 // VERSION: 0.8
695 // Checks whether @node is a %JSON_NODE_NULL
697 // <note>A null node is not the same as a %NULL #JsonNode</note>
698 // RETURNS: %TRUE if the node is null
699 int is_null()() nothrow {
700 return json_node_is_null(&this);
703 // Sets @array inside @node and increases the #JsonArray reference count
704 // <array>: a #JsonArray
705 void set_array(AT0)(AT0 /*Array*/ array) nothrow {
706 json_node_set_array(&this, UpCast!(Array*)(array));
709 // Sets @value as the boolean content of the @node, replacing any existing
710 // content.
711 // <value>: a boolean value
712 void set_boolean()(int value) nothrow {
713 json_node_set_boolean(&this, value);
716 // Sets @value as the double content of the @node, replacing any existing
717 // content.
718 // <value>: a double value
719 void set_double()(double value) nothrow {
720 json_node_set_double(&this, value);
723 // Sets @value as the integer content of the @node, replacing any existing
724 // content.
725 // <value>: an integer value
726 void set_int()(long value) nothrow {
727 json_node_set_int(&this, value);
730 // Sets @objects inside @node. The reference count of @object is increased.
731 // <object>: a #JsonObject
732 void set_object(AT0)(AT0 /*Object*/ object) nothrow {
733 json_node_set_object(&this, UpCast!(Object*)(object));
736 // VERSION: 0.8
737 // Sets the parent #JsonNode of @node
738 // <parent>: the parent #JsonNode of @node
739 void set_parent(AT0)(AT0 /*Node*/ parent) nothrow {
740 json_node_set_parent(&this, UpCast!(Node*)(parent));
743 // Sets @value as the string content of the @node, replacing any existing
744 // content.
745 // <value>: a string value
746 void set_string(AT0)(AT0 /*char*/ value) nothrow {
747 json_node_set_string(&this, toCString!(char*)(value));
750 // Sets @value inside @node. The passed #GValue is copied into the #JsonNode
751 // <value>: the #GValue to set
752 void set_value(AT0)(AT0 /*GObject2.Value*/ value) nothrow {
753 json_node_set_value(&this, UpCast!(GObject2.Value*)(value));
756 // Sets @array into @node without increasing the #JsonArray reference count.
757 // <array>: a #JsonArray
758 void take_array(AT0)(AT0 /*Array*/ array) nothrow {
759 json_node_take_array(&this, UpCast!(Array*)(array));
762 // Sets @object inside @node. The reference count of @object is not increased.
763 // <object>: a #JsonObject
764 void take_object(AT0)(AT0 /*Object*/ object) nothrow {
765 json_node_take_object(&this, UpCast!(Object*)(object));
768 // Retrieves the user readable name of the data type contained by @node.
770 // is owned by the node and should never be modified or freed
771 // RETURNS: a string containing the name of the type. The returned string
772 char* type_name()() nothrow {
773 return json_node_type_name(&this);
777 // Indicates the content of a #JsonNode.
778 enum NodeType {
779 OBJECT = 0,
780 ARRAY = 1,
781 VALUE = 2,
782 NULL = 3
785 // A JSON object type. The contents of the #JsonObject structure are private
786 // and should only be accessed by the provided API
787 struct Object {
789 // Creates a new #JsonObject, an JSON object type representation.
790 // RETURNS: the newly created #JsonObject
791 static Object* /*new*/ new_()() nothrow {
792 return json_object_new();
794 static auto opCall()() {
795 return json_object_new();
798 // DEPRECATED (v0.8) method: add_member - Use json_object_set_member() instead
799 // Adds a member named @member_name and containing @node into a #JsonObject.
800 // The object will take ownership of the #JsonNode.
802 // This function will return if the @object already contains a member
803 // @member_name.
804 // <member_name>: the name of the member
805 // <node>: the value of the member
806 void add_member(AT0, AT1)(AT0 /*char*/ member_name, AT1 /*Node*/ node) nothrow {
807 json_object_add_member(&this, toCString!(char*)(member_name), UpCast!(Node*)(node));
810 // VERSION: 0.6
811 // Retrieves a copy of the #JsonNode containing the value of @member_name
812 // inside a #JsonObject
814 // object member or %NULL. Use json_node_free() when done.
815 // RETURNS: a copy of the node for the requested
816 // <member_name>: the name of the JSON object member to access
817 Node* /*new*/ dup_member(AT0)(AT0 /*char*/ member_name) nothrow {
818 return json_object_dup_member(&this, toCString!(char*)(member_name));
821 // VERSION: 0.8
822 // Iterates over all members of @object and calls @func on
823 // each one of them.
825 // It is safe to change the value of a #JsonNode of the @object
826 // from within the iterator @func, but it is not safe to add or
827 // remove members from the @object.
828 // <func>: the function to be called on each member
829 // <data>: data to be passed to the function
830 void foreach_member(AT0)(ObjectForeach func, AT0 /*void*/ data) nothrow {
831 json_object_foreach_member(&this, func, UpCast!(void*)(data));
834 // VERSION: 0.8
835 // Convenience function that retrieves the array
836 // stored in @member_name of @object
838 // See also: json_object_get_member()
839 // RETURNS: the array inside the object's member
840 // <member_name>: the name of the member
841 Array* get_array_member(AT0)(AT0 /*char*/ member_name) nothrow {
842 return json_object_get_array_member(&this, toCString!(char*)(member_name));
845 // VERSION: 0.8
846 // Convenience function that retrieves the boolean value
847 // stored in @member_name of @object
849 // See also: json_object_get_member()
850 // RETURNS: the boolean value of the object's member
851 // <member_name>: the name of the member
852 int get_boolean_member(AT0)(AT0 /*char*/ member_name) nothrow {
853 return json_object_get_boolean_member(&this, toCString!(char*)(member_name));
856 // VERSION: 0.8
857 // Convenience function that retrieves the floating point value
858 // stored in @member_name of @object
860 // See also: json_object_get_member()
861 // RETURNS: the floating point value of the object's member
862 // <member_name>: the name of the member
863 double get_double_member(AT0)(AT0 /*char*/ member_name) nothrow {
864 return json_object_get_double_member(&this, toCString!(char*)(member_name));
867 // VERSION: 0.8
868 // Convenience function that retrieves the integer value
869 // stored in @member_name of @object
871 // See also: json_object_get_member()
872 // RETURNS: the integer value of the object's member
873 // <member_name>: the name of the member
874 long get_int_member(AT0)(AT0 /*char*/ member_name) nothrow {
875 return json_object_get_int_member(&this, toCString!(char*)(member_name));
878 // Retrieves the #JsonNode containing the value of @member_name inside
879 // a #JsonObject.
881 // member, or %NULL
882 // RETURNS: a pointer to the node for the requested object
883 // <member_name>: the name of the JSON object member to access
884 Node* get_member(AT0)(AT0 /*char*/ member_name) nothrow {
885 return json_object_get_member(&this, toCString!(char*)(member_name));
888 // Retrieves all the names of the members of a #JsonObject. You can
889 // obtain the value for each member using json_object_get_member().
891 // of member names. The content of the list is owned by the #JsonObject
892 // and should never be modified or freed. When you have finished using
893 // the returned list, use g_list_free() to free the resources it has
894 // allocated.
895 // RETURNS: a #GList
896 GLib2.List* /*new container*/ get_members()() nothrow {
897 return json_object_get_members(&this);
900 // VERSION: 0.8
901 // Convenience function that checks whether the value
902 // stored in @member_name of @object is null
904 // See also: json_object_get_member()
905 // RETURNS: %TRUE if the value is null
906 // <member_name>: the name of the member
907 int get_null_member(AT0)(AT0 /*char*/ member_name) nothrow {
908 return json_object_get_null_member(&this, toCString!(char*)(member_name));
911 // VERSION: 0.8
912 // Convenience function that retrieves the object
913 // stored in @member_name of @object
915 // See also: json_object_get_member()
916 // RETURNS: the object inside the object's member
917 // <member_name>: the name of the member
918 Object* get_object_member(AT0)(AT0 /*char*/ member_name) nothrow {
919 return json_object_get_object_member(&this, toCString!(char*)(member_name));
922 // Retrieves the number of members of a #JsonObject.
923 // RETURNS: the number of members
924 uint get_size()() nothrow {
925 return json_object_get_size(&this);
928 // VERSION: 0.8
929 // Convenience function that retrieves the string value
930 // stored in @member_name of @object
932 // See also: json_object_get_member()
933 // RETURNS: the string value of the object's member
934 // <member_name>: the name of the member
935 char* get_string_member(AT0)(AT0 /*char*/ member_name) nothrow {
936 return json_object_get_string_member(&this, toCString!(char*)(member_name));
939 // Retrieves all the values of the members of a #JsonObject.
941 // #JsonNode<!-- -->s. The content of the list is owned by the #JsonObject
942 // and should never be modified or freed. When you have finished using the
943 // returned list, use g_list_free() to free the resources it has allocated.
944 // RETURNS: a #GList of
945 GLib2.List* /*new container*/ get_values()() nothrow {
946 return json_object_get_values(&this);
949 // Checks whether @object has a member named @member_name.
950 // RETURNS: %TRUE if the JSON object has the requested member
951 // <member_name>: the name of a JSON object member
952 int has_member(AT0)(AT0 /*char*/ member_name) nothrow {
953 return json_object_has_member(&this, toCString!(char*)(member_name));
956 // Increase by one the reference count of a #JsonObject.
958 // increased by one.
959 // RETURNS: the passed #JsonObject, with the reference count
960 Object* /*new*/ ref_()() nothrow {
961 return json_object_ref(&this);
964 // Removes @member_name from @object, freeing its allocated resources.
965 // <member_name>: the name of the member to remove
966 void remove_member(AT0)(AT0 /*char*/ member_name) nothrow {
967 json_object_remove_member(&this, toCString!(char*)(member_name));
970 // VERSION: 0.8
971 // Convenience function for setting an array @value of
972 // @member_name inside @object.
974 // The @object will take ownership of the passed #JsonArray
976 // See also: json_object_set_member()
977 // <member_name>: the name of the member
978 // <value>: the value of the member
979 void set_array_member(AT0, AT1)(AT0 /*char*/ member_name, AT1 /*Array*/ value) nothrow {
980 json_object_set_array_member(&this, toCString!(char*)(member_name), UpCast!(Array*)(value));
983 // VERSION: 0.8
984 // Convenience function for setting a boolean @value of
985 // @member_name inside @object.
987 // See also: json_object_set_member()
988 // <member_name>: the name of the member
989 // <value>: the value of the member
990 void set_boolean_member(AT0)(AT0 /*char*/ member_name, int value) nothrow {
991 json_object_set_boolean_member(&this, toCString!(char*)(member_name), value);
994 // VERSION: 0.8
995 // Convenience function for setting a floating point @value
996 // of @member_name inside @object.
998 // See also: json_object_set_member()
999 // <member_name>: the name of the member
1000 // <value>: the value of the member
1001 void set_double_member(AT0)(AT0 /*char*/ member_name, double value) nothrow {
1002 json_object_set_double_member(&this, toCString!(char*)(member_name), value);
1005 // VERSION: 0.8
1006 // Convenience function for setting an integer @value of
1007 // @member_name inside @object.
1009 // See also: json_object_set_member()
1010 // <member_name>: the name of the member
1011 // <value>: the value of the member
1012 void set_int_member(AT0)(AT0 /*char*/ member_name, long value) nothrow {
1013 json_object_set_int_member(&this, toCString!(char*)(member_name), value);
1016 // VERSION: 0.8
1017 // Sets @node as the value of @member_name inside @object.
1019 // If @object already contains a member called @member_name then
1020 // the member's current value is overwritten. Otherwise, a new
1021 // member is added to @object.
1022 // <member_name>: the name of the member
1023 // <node>: the value of the member
1024 void set_member(AT0, AT1)(AT0 /*char*/ member_name, AT1 /*Node*/ node) nothrow {
1025 json_object_set_member(&this, toCString!(char*)(member_name), UpCast!(Node*)(node));
1028 // VERSION: 0.8
1029 // Convenience function for setting a null @value of
1030 // @member_name inside @object.
1032 // See also: json_object_set_member()
1033 // <member_name>: the name of the member
1034 void set_null_member(AT0)(AT0 /*char*/ member_name) nothrow {
1035 json_object_set_null_member(&this, toCString!(char*)(member_name));
1038 // VERSION: 0.8
1039 // Convenience function for setting an object @value of
1040 // @member_name inside @object.
1042 // The @object will take ownership of the passed #JsonObject
1044 // See also: json_object_set_member()
1045 // <member_name>: the name of the member
1046 // <value>: the value of the member
1047 void set_object_member(AT0, AT1)(AT0 /*char*/ member_name, AT1 /*Object*/ value) nothrow {
1048 json_object_set_object_member(&this, toCString!(char*)(member_name), UpCast!(Object*)(value));
1051 // VERSION: 0.8
1052 // Convenience function for setting a string @value of
1053 // @member_name inside @object.
1055 // See also: json_object_set_member()
1056 // <member_name>: the name of the member
1057 // <value>: the value of the member
1058 void set_string_member(AT0, AT1)(AT0 /*char*/ member_name, AT1 /*char*/ value) nothrow {
1059 json_object_set_string_member(&this, toCString!(char*)(member_name), toCString!(char*)(value));
1062 // Decreases by one the reference count of a #JsonObject. If the
1063 // reference count reaches zero, the object is destroyed and all
1064 // its allocated resources are freed.
1065 void unref()() nothrow {
1066 json_object_unref(&this);
1071 // VERSION: 0.8
1072 // The function to be passed to json_object_foreach_member(). You
1073 // should not add or remove members to and from @object within
1074 // this function. It is safe to change the value of @member_node.
1075 // <object>: the iterated #JsonObject
1076 // <member_name>: the name of the member
1077 // <member_node>: a #JsonNode containing the @member_name value
1078 // <user_data>: data passed to the function
1079 extern (C) alias void function (Object* object, char* member_name, Node* member_node, void* user_data) nothrow ObjectForeach;
1082 // JSON data streams parser. The contents of the #JsonParser structure are
1083 // private and should only be accessed via the provided API.
1084 struct Parser /* : GObject.Object */ {
1085 alias parent_instance this;
1086 alias parent_instance super_;
1087 alias parent_instance object;
1088 GObject2.Object parent_instance;
1089 private ParserPrivate* priv;
1092 // Creates a new #JsonParser instance. You can use the #JsonParser to
1093 // load a JSON stream from either a file or a buffer and then walk the
1094 // hierarchy using the data types API.
1096 // to release all the memory it allocates.
1097 // RETURNS: the newly created #JsonParser. Use g_object_unref()
1098 static Parser* /*new*/ new_()() nothrow {
1099 return json_parser_new();
1101 static auto opCall()() {
1102 return json_parser_new();
1104 static GLib2.Quark error_quark()() nothrow {
1105 return json_parser_error_quark();
1108 // Retrieves the line currently parsed, starting from 1.
1110 // This function has defined behaviour only while parsing; calling this
1111 // function from outside the signal handlers emitted by #JsonParser will
1112 // yield 0.
1113 // RETURNS: the currently parsed line, or 0.
1114 uint get_current_line()() nothrow {
1115 return json_parser_get_current_line(&this);
1118 // Retrieves the current position inside the current line, starting
1119 // from 0.
1121 // This function has defined behaviour only while parsing; calling this
1122 // function from outside the signal handlers emitted by #JsonParser will
1123 // yield 0.
1124 // RETURNS: the position in the current line, or 0.
1125 uint get_current_pos()() nothrow {
1126 return json_parser_get_current_pos(&this);
1129 // Retrieves the top level node from the parsed JSON stream.
1131 // node is owned by the #JsonParser and should never be modified
1132 // or freed.
1133 // RETURNS: the root #JsonNode . The returned
1134 Node* get_root()() nothrow {
1135 return json_parser_get_root(&this);
1138 // VERSION: 0.4
1139 // A JSON data stream might sometimes contain an assignment, like:
1141 // |[
1142 // var _json_data = { "member_name" : [ ...
1143 // ]|
1145 // even though it would technically constitute a violation of the RFC.
1147 // #JsonParser will ignore the left hand identifier and parse the right
1148 // hand value of the assignment. #JsonParser will record, though, the
1149 // existence of the assignment in the data stream and the variable name
1150 // used.
1152 // @variable_name is not %NULL it will be set to the name of the variable
1153 // used in the assignment. The string is owned by #JsonParser and should
1154 // never be modified or freed.
1155 // RETURNS: %TRUE if there was an assignment, %FALSE otherwise. If
1156 // <variable_name>: Return location for the variable name, or %NULL
1157 int has_assignment(AT0)(/*out*/ AT0 /*char**/ variable_name=null) nothrow {
1158 return json_parser_has_assignment(&this, toCString!(char**)(variable_name));
1161 // Loads a JSON stream from a buffer and parses it. You can call this function
1162 // multiple times with the same #JsonParser object, but the contents of the
1163 // parser will be destroyed each time.
1165 // of error, @error is set accordingly and %FALSE is returned
1166 // RETURNS: %TRUE if the buffer was succesfully parser. In case
1167 // <data>: the buffer to parse
1168 // <length>: the length of the buffer, or -1
1169 int load_from_data(AT0, AT1)(AT0 /*char*/ data, ssize_t length, AT1 /*GLib2.Error**/ error=null) nothrow {
1170 return json_parser_load_from_data(&this, toCString!(char*)(data), length, UpCast!(GLib2.Error**)(error));
1173 // Loads a JSON stream from the content of @filename and parses it. See
1174 // json_parser_load_from_data().
1176 // In case of error, @error is set accordingly and %FALSE is returned
1177 // RETURNS: %TRUE if the file was successfully loaded and parsed.
1178 // <filename>: the path for the file to parse
1179 int load_from_file(AT0, AT1)(AT0 /*char*/ filename, AT1 /*GLib2.Error**/ error=null) nothrow {
1180 return json_parser_load_from_file(&this, toCString!(char*)(filename), UpCast!(GLib2.Error**)(error));
1183 // VERSION: 0.12
1184 // Loads the contents of an input stream and parses them.
1186 // If @cancellable is not %NULL, then the operation can be cancelled by
1187 // triggering the @cancellable object from another thread. If the
1188 // operation was cancelled, the error %G_IO_ERROR_CANCELLED will be set
1189 // on the passed @error.
1191 // parsed, and %FALSE otherwise
1192 // RETURNS: %TRUE if the data stream was successfully read and
1193 // <stream>: an open #GInputStream
1194 // <cancellable>: a #GCancellable, or %NULL
1195 int load_from_stream(AT0, AT1, AT2)(AT0 /*Gio2.InputStream*/ stream, AT1 /*Gio2.Cancellable*/ cancellable, AT2 /*GLib2.Error**/ error=null) nothrow {
1196 return json_parser_load_from_stream(&this, UpCast!(Gio2.InputStream*)(stream), UpCast!(Gio2.Cancellable*)(cancellable), UpCast!(GLib2.Error**)(error));
1199 // VERSION: 0.12
1200 // Asynchronously reads the contents of @stream.
1202 // For more details, see json_parser_load_from_stream() which is the
1203 // synchronous version of this call.
1205 // When the operation is finished, @callback will be called. You should
1206 // then call json_parser_load_from_stream_finish() to get the result
1207 // of the operation.
1208 // <stream>: a #GInputStream
1209 // <cancellable>: a #GCancellable, or %NULL
1210 // <callback>: a #GAsyncReadyCallback to call when the request is satisfied
1211 // <user_data>: the data to pass to @callback
1212 void load_from_stream_async(AT0, AT1, AT2)(AT0 /*Gio2.InputStream*/ stream, AT1 /*Gio2.Cancellable*/ cancellable, Gio2.AsyncReadyCallback callback, AT2 /*void*/ user_data) nothrow {
1213 json_parser_load_from_stream_async(&this, UpCast!(Gio2.InputStream*)(stream), UpCast!(Gio2.Cancellable*)(cancellable), callback, UpCast!(void*)(user_data));
1216 // VERSION: 0.12
1217 // Finishes an asynchronous stream loading started with
1218 // json_parser_load_from_stream_async().
1220 // and parsed, and %FALSE otherwise. In case of error, the #GError will be
1221 // filled accordingly.
1222 // RETURNS: %TRUE if the content of the stream was successfully retrieves
1223 // <result>: a #GAsyncResult
1224 int load_from_stream_finish(AT0, AT1)(AT0 /*Gio2.AsyncResult*/ result, AT1 /*GLib2.Error**/ error=null) nothrow {
1225 return json_parser_load_from_stream_finish(&this, UpCast!(Gio2.AsyncResult*)(result), UpCast!(GLib2.Error**)(error));
1228 // The ::array-element signal is emitted each time the #JsonParser
1229 // has successfully parsed a single element of a #JsonArray. The
1230 // array and element index are passed to the signal handlers.
1231 // <array>: a #JsonArray
1232 // <index_>: the index of the newly parsed element
1233 extern (C) alias static void function (Parser* this_, Array* array, int index_, void* user_data=null) nothrow signal_array_element;
1235 ulong signal_connect(string name, CB)(CB cb, void* data=null, ConnectFlags cf=cast(ConnectFlags)0) {
1236 return super_.signal_connect!name(cb, data, cf);
1239 ulong signal_connect(string name:"array-element", CB/*:signal_array_element*/)
1240 (CB cb, void* data=null, ConnectFlags cf=cast(ConnectFlags)0)
1241 if (is(typeof(cb)==signal_array_element)||_ttmm!(CB, signal_array_element)()) {
1242 return signal_connect_data!()(&this, cast(char*)"array-element",
1243 cast(GObject2.Callback)cb, data, null, cf);
1246 // The ::array-end signal is emitted each time the #JsonParser
1247 // has successfully parsed an entire #JsonArray
1248 // <array>: the parsed #JsonArray
1249 extern (C) alias static void function (Parser* this_, Array* array, void* user_data=null) nothrow signal_array_end;
1250 ulong signal_connect(string name:"array-end", CB/*:signal_array_end*/)
1251 (CB cb, void* data=null, ConnectFlags cf=cast(ConnectFlags)0)
1252 if (is(typeof(cb)==signal_array_end)||_ttmm!(CB, signal_array_end)()) {
1253 return signal_connect_data!()(&this, cast(char*)"array-end",
1254 cast(GObject2.Callback)cb, data, null, cf);
1257 // The ::array-start signal is emitted each time the #JsonParser
1258 // starts parsing a #JsonArray
1259 extern (C) alias static void function (Parser* this_, void* user_data=null) nothrow signal_array_start;
1260 ulong signal_connect(string name:"array-start", CB/*:signal_array_start*/)
1261 (CB cb, void* data=null, ConnectFlags cf=cast(ConnectFlags)0)
1262 if (is(typeof(cb)==signal_array_start)||_ttmm!(CB, signal_array_start)()) {
1263 return signal_connect_data!()(&this, cast(char*)"array-start",
1264 cast(GObject2.Callback)cb, data, null, cf);
1267 // The ::error signal is emitted each time a #JsonParser encounters
1268 // an error in a JSON stream.
1269 // <error>: a pointer to the #GError
1270 extern (C) alias static void function (Parser* this_, void* error, void* user_data=null) nothrow signal_error;
1271 ulong signal_connect(string name:"error", CB/*:signal_error*/)
1272 (CB cb, void* data=null, ConnectFlags cf=cast(ConnectFlags)0)
1273 if (is(typeof(cb)==signal_error)||_ttmm!(CB, signal_error)()) {
1274 return signal_connect_data!()(&this, cast(char*)"error",
1275 cast(GObject2.Callback)cb, data, null, cf);
1278 // The ::object-end signal is emitted each time the #JsonParser
1279 // has successfully parsed an entire #JsonObject.
1280 // <object>: the parsed #JsonObject
1281 extern (C) alias static void function (Parser* this_, Object* object, void* user_data=null) nothrow signal_object_end;
1282 ulong signal_connect(string name:"object-end", CB/*:signal_object_end*/)
1283 (CB cb, void* data=null, ConnectFlags cf=cast(ConnectFlags)0)
1284 if (is(typeof(cb)==signal_object_end)||_ttmm!(CB, signal_object_end)()) {
1285 return signal_connect_data!()(&this, cast(char*)"object-end",
1286 cast(GObject2.Callback)cb, data, null, cf);
1289 // The ::object-member signal is emitted each time the #JsonParser
1290 // has successfully parsed a single member of a #JsonObject. The
1291 // object and member are passed to the signal handlers.
1292 // <object>: a #JsonObject
1293 // <member_name>: the name of the newly parsed member
1294 extern (C) alias static void function (Parser* this_, Object* object, char* member_name, void* user_data=null) nothrow signal_object_member;
1295 ulong signal_connect(string name:"object-member", CB/*:signal_object_member*/)
1296 (CB cb, void* data=null, ConnectFlags cf=cast(ConnectFlags)0)
1297 if (is(typeof(cb)==signal_object_member)||_ttmm!(CB, signal_object_member)()) {
1298 return signal_connect_data!()(&this, cast(char*)"object-member",
1299 cast(GObject2.Callback)cb, data, null, cf);
1302 // The ::object-start signal is emitted each time the #JsonParser
1303 // starts parsing a #JsonObject.
1304 extern (C) alias static void function (Parser* this_, void* user_data=null) nothrow signal_object_start;
1305 ulong signal_connect(string name:"object-start", CB/*:signal_object_start*/)
1306 (CB cb, void* data=null, ConnectFlags cf=cast(ConnectFlags)0)
1307 if (is(typeof(cb)==signal_object_start)||_ttmm!(CB, signal_object_start)()) {
1308 return signal_connect_data!()(&this, cast(char*)"object-start",
1309 cast(GObject2.Callback)cb, data, null, cf);
1312 // The ::parse-end signal is emitted when the parser successfully
1313 // finished parsing a JSON data stream
1314 extern (C) alias static void function (Parser* this_, void* user_data=null) nothrow signal_parse_end;
1315 ulong signal_connect(string name:"parse-end", CB/*:signal_parse_end*/)
1316 (CB cb, void* data=null, ConnectFlags cf=cast(ConnectFlags)0)
1317 if (is(typeof(cb)==signal_parse_end)||_ttmm!(CB, signal_parse_end)()) {
1318 return signal_connect_data!()(&this, cast(char*)"parse-end",
1319 cast(GObject2.Callback)cb, data, null, cf);
1322 // The ::parse-start signal is emitted when the parser began parsing
1323 // a JSON data stream.
1324 extern (C) alias static void function (Parser* this_, void* user_data=null) nothrow signal_parse_start;
1325 ulong signal_connect(string name:"parse-start", CB/*:signal_parse_start*/)
1326 (CB cb, void* data=null, ConnectFlags cf=cast(ConnectFlags)0)
1327 if (is(typeof(cb)==signal_parse_start)||_ttmm!(CB, signal_parse_start)()) {
1328 return signal_connect_data!()(&this, cast(char*)"parse-start",
1329 cast(GObject2.Callback)cb, data, null, cf);
1333 // #JsonParser class.
1334 struct ParserClass {
1335 private GObject2.ObjectClass parent_class;
1336 extern (C) void function (Parser* parser) nothrow parse_start;
1337 extern (C) void function (Parser* parser) nothrow object_start;
1338 extern (C) void function (Parser* parser, Object* object, char* member_name) nothrow object_member;
1339 extern (C) void function (Parser* parser, Object* object) nothrow object_end;
1340 extern (C) void function (Parser* parser) nothrow array_start;
1341 extern (C) void function (Parser* parser, Array* array, int index_) nothrow array_element;
1342 extern (C) void function (Parser* parser, Array* array) nothrow array_end;
1343 extern (C) void function (Parser* parser) nothrow parse_end;
1344 extern (C) void function (Parser* parser, GLib2.Error* error) nothrow error;
1345 extern (C) void function () nothrow _json_reserved1;
1346 extern (C) void function () nothrow _json_reserved2;
1347 extern (C) void function () nothrow _json_reserved3;
1348 extern (C) void function () nothrow _json_reserved4;
1349 extern (C) void function () nothrow _json_reserved5;
1350 extern (C) void function () nothrow _json_reserved6;
1351 extern (C) void function () nothrow _json_reserved7;
1352 extern (C) void function () nothrow _json_reserved8;
1356 // Error enumeration for #JsonParser
1358 // This enumeration can be extended at later date
1359 enum ParserError {
1360 PARSE = 0,
1361 TRAILING_COMMA = 1,
1362 MISSING_COMMA = 2,
1363 MISSING_COLON = 3,
1364 INVALID_BAREWORD = 4,
1365 UNKNOWN = 5
1367 struct ParserPrivate {
1371 // The <structname>JsonPath</structname> structure is an opaque object
1372 // whose members cannot be directly accessed except through the provided
1373 // API.
1374 struct Path /* : GObject.Object */ /* Version 0.14 */ {
1375 alias method_parent this;
1376 alias method_parent super_;
1377 alias method_parent object;
1378 GObject2.Object method_parent;
1381 // VERSION: 0.14
1382 // Creates a new #JsonPath instance.
1384 // Once created, the #JsonPath object should be used with json_path_compile()
1385 // and json_path_match().
1387 // g_object_unref() to free the allocated resources when done
1388 // RETURNS: the newly created #JsonPath instance. Use
1389 static Path* /*new*/ new_()() nothrow {
1390 return json_path_new();
1392 static auto opCall()() {
1393 return json_path_new();
1395 static GLib2.Quark error_quark()() nothrow {
1396 return json_path_error_quark();
1399 // VERSION: 0.14
1400 // Queries a JSON tree using a JSONPath expression.
1402 // This function is a simple wrapper around json_path_new(),
1403 // json_path_compile() and json_path_match(). It implicitly
1404 // creates a #JsonPath instance, compiles @expression and
1405 // matches it against the JSON tree pointed by @root.
1407 // %JSON_NODE_ARRAY containing an array of matching #JsonNode<!-- -->s.
1408 // Use json_node_free() when done
1409 // RETURNS: a newly-created #JsonNode of type
1410 // <expression>: a JSONPath expression
1411 // <root>: the root of a JSON tree
1412 static Node* /*new*/ query(AT0, AT1, AT2)(AT0 /*char*/ expression, AT1 /*Node*/ root, AT2 /*GLib2.Error**/ error=null) nothrow {
1413 return json_path_query(toCString!(char*)(expression), UpCast!(Node*)(root), UpCast!(GLib2.Error**)(error));
1416 // VERSION: 0.14
1417 // Validates and decomposes @expression.
1419 // A JSONPath expression must be compiled before calling json_path_match().
1421 // the %JSON_PATH_ERROR domain and a code from the #JsonPathError
1422 // enumeration, and %FALSE will be returned
1423 // RETURNS: %TRUE on success; on error, @error will be set with
1424 // <expression>: a JSONPath expression
1425 int compile(AT0, AT1)(AT0 /*char*/ expression, AT1 /*GLib2.Error**/ error=null) nothrow {
1426 return json_path_compile(&this, toCString!(char*)(expression), UpCast!(GLib2.Error**)(error));
1429 // VERSION: 0.14
1430 // Matches the JSON tree pointed by @root using the expression compiled
1431 // into the #JsonPath.
1433 // The matching #JsonNode<!-- -->s will be copied into a #JsonArray and
1434 // returned wrapped in a #JsonNode.
1436 // %JSON_NODE_ARRAY containing an array of matching #JsonNode<!-- -->s.
1437 // Use json_node_free() when done
1438 // RETURNS: a newly-created #JsonNode of type
1439 // <root>: a #JsonNode
1440 Node* /*new*/ match(AT0)(AT0 /*Node*/ root) nothrow {
1441 return json_path_match(&this, UpCast!(Node*)(root));
1446 // The <structname>JsonPathClass</structname> structure is an opaque
1447 // object class whose members cannot be directly accessed.
1448 struct PathClass /* Version 0.14 */ {
1451 // Error code enumeration for the %JSON_PATH_ERROR domain.
1452 enum PathError /* Version 0.14 */ {
1453 PATH_ERROR_INVALID_QUERY = 0
1456 // The <structname>JsonReader</structname> structure contains only
1457 // private data and should only be accessed using the provided API
1458 struct Reader /* : GObject.Object */ /* Version 0.12 */ {
1459 alias parent_instance this;
1460 alias parent_instance super_;
1461 alias parent_instance object;
1462 GObject2.Object parent_instance;
1463 private ReaderPrivate* priv;
1466 // VERSION: 0.12
1467 // Creates a new #JsonReader. You can use this object to read the contents of
1468 // the JSON tree starting from @node
1470 // release the allocated resources when done
1471 // RETURNS: the newly created #JsonReader. Use g_object_unref() to
1472 // <node>: a #JsonNode, or %NULL
1473 static Reader* /*new*/ new_(AT0)(AT0 /*Node*/ node=null) nothrow {
1474 return json_reader_new(UpCast!(Node*)(node));
1476 static auto opCall(AT0)(AT0 /*Node*/ node=null) {
1477 return json_reader_new(UpCast!(Node*)(node));
1479 static GLib2.Quark error_quark()() nothrow {
1480 return json_reader_error_quark();
1483 // VERSION: 0.12
1484 // Counts the elements of the current position, if @reader is
1485 // positioned on an array
1487 // the #JsonReader is set in an error state
1488 // RETURNS: the number of elements, or -1. In case of failure
1489 int count_elements()() nothrow {
1490 return json_reader_count_elements(&this);
1493 // VERSION: 0.12
1494 // Counts the members of the current position, if @reader is
1495 // positioned on an object
1497 // the #JsonReader is set in an error state
1498 // RETURNS: the number of members, or -1. In case of failure
1499 int count_members()() nothrow {
1500 return json_reader_count_members(&this);
1503 // VERSION: 0.12
1504 // Moves the cursor back to the previous node after being positioned
1505 // inside an array
1507 // This function resets the error state of @reader, if any was set
1508 void end_element()() nothrow {
1509 json_reader_end_element(&this);
1512 // VERSION: 0.12
1513 // Moves the cursor back to the previous node after being positioned
1514 // inside an object
1516 // This function resets the error state of @reader, if any was set
1517 void end_member()() nothrow {
1518 json_reader_end_member(&this);
1521 // VERSION: 0.12
1522 // Retrieves the boolean value of the current position of @reader
1523 // RETURNS: the boolean value
1524 int get_boolean_value()() nothrow {
1525 return json_reader_get_boolean_value(&this);
1528 // VERSION: 0.12
1529 // Retrieves the floating point value of the current position of @reader
1530 // RETURNS: the floating point value
1531 double get_double_value()() nothrow {
1532 return json_reader_get_double_value(&this);
1535 // VERSION: 0.12
1536 // Retrieves the #GError currently set on @reader, if the #JsonReader
1537 // is in error state
1538 // RETURNS: the pointer to the error, or %NULL
1539 GLib2.Error* get_error()() nothrow {
1540 return json_reader_get_error(&this);
1543 // VERSION: 0.12
1544 // Retrieves the integer value of the current position of @reader
1545 // RETURNS: the integer value
1546 long get_int_value()() nothrow {
1547 return json_reader_get_int_value(&this);
1550 // VERSION: 0.14
1551 // Retrieves the name of the current member.
1552 // RETURNS: the name of the member, or %NULL
1553 char* get_member_name()() nothrow {
1554 return json_reader_get_member_name(&this);
1557 // VERSION: 0.12
1558 // Checks whether the value of the current position of @reader is 'null'
1559 // RETURNS: %TRUE if 'null' is set, and %FALSE otherwise
1560 int get_null_value()() nothrow {
1561 return json_reader_get_null_value(&this);
1564 // VERSION: 0.12
1565 // Retrieves the string value of the current position of @reader
1566 // RETURNS: the string value
1567 char* get_string_value()() nothrow {
1568 return json_reader_get_string_value(&this);
1571 // VERSION: 0.12
1572 // Retrieves the #JsonNode of the current position of @reader
1574 // is owned by the #JsonReader and it should not be modified or freed
1575 // directly
1576 // RETURNS: a #JsonNode, or %NULL. The returned node
1577 Node* get_value()() nothrow {
1578 return json_reader_get_value(&this);
1581 // VERSION: 0.12
1582 // Checks whether the @reader is currently on an array
1584 // otherwise
1585 // RETURNS: %TRUE if the #JsonReader is on an array, and %FALSE
1586 int is_array()() nothrow {
1587 return json_reader_is_array(&this);
1590 // VERSION: 0.12
1591 // Checks whether the @reader is currently on an object
1593 // otherwise
1594 // RETURNS: %TRUE if the #JsonReader is on an object, and %FALSE
1595 int is_object()() nothrow {
1596 return json_reader_is_object(&this);
1599 // VERSION: 0.12
1600 // Checks whether the @reader is currently on a value
1602 // otherwise
1603 // RETURNS: %TRUE if the #JsonReader is on a value, and %FALSE
1604 int is_value()() nothrow {
1605 return json_reader_is_value(&this);
1608 // VERSION: 0.14
1609 // Retrieves a list of member names from the current position, if @reader
1610 // is positioned on an object.
1612 // array of strings holding the members name. Use g_strfreev() when
1613 // done.
1614 // RETURNS: a newly allocated, %NULL-terminated
1615 char** /*new*/ list_members()() nothrow {
1616 return json_reader_list_members(&this);
1619 // VERSION: 0.12
1620 // Advances the cursor of @reader to the element @index_ of the array
1621 // or the object at the current position.
1623 // You can use the json_reader_get_value* family of functions to retrieve
1624 // the value of the element; for instance:
1626 // |[
1627 // json_reader_read_element (reader, 0);
1628 // int_value = json_reader_get_int_value (reader);
1629 // ]|
1631 // After reading the value, json_reader_end_element() should be called to
1632 // reposition the cursor inside the #JsonReader, e.g.:
1634 // |[
1635 // json_reader_read_element (reader, 1);
1636 // str_value = json_reader_get_string_value (reader);
1637 // json_reader_end_element (reader);
1639 // json_reader_read_element (reader, 2);
1640 // str_value = json_reader_get_string_value (reader);
1641 // json_reader_end_element (reader);
1642 // ]|
1644 // If @reader is not currently on an array or an object, or if the @index_ is
1645 // bigger than the size of the array or the object, the #JsonReader will be
1646 // put in an error state until json_reader_end_element() is called.
1647 // RETURNS: %TRUE on success, and %FALSE otherwise
1648 // <index_>: the index of the element
1649 int read_element()(uint index_) nothrow {
1650 return json_reader_read_element(&this, index_);
1653 // VERSION: 0.12
1654 // Advances the cursor of @reader to the @member_name of the object at the
1655 // current position.
1657 // You can use the json_reader_get_value* family of functions to retrieve
1658 // the value of the member; for instance:
1660 // |[
1661 // json_reader_read_member (reader, "width");
1662 // width = json_reader_get_int_value (reader);
1663 // ]|
1665 // After reading the value, json_reader_end_member() should be called to
1666 // reposition the cursor inside the #JsonReader, e.g.:
1668 // |[
1669 // json_reader_read_member (reader, "author");
1670 // author = json_reader_get_string_value (reader);
1671 // json_reader_end_element (reader);
1673 // json_reader_read_element (reader, "title");
1674 // title = json_reader_get_string_value (reader);
1675 // json_reader_end_element (reader);
1676 // ]|
1678 // If @reader is not currently on an object, or if the @member_name is not
1679 // defined in the object, the #JsonReader will be put in an error state until
1680 // json_reader_end_member() is called.
1681 // RETURNS: %TRUE on success, and %FALSE otherwise
1682 // <member_name>: the name of the member to read
1683 int read_member(AT0)(AT0 /*char*/ member_name) nothrow {
1684 return json_reader_read_member(&this, toCString!(char*)(member_name));
1687 // VERSION: 0.12
1688 // Sets the root #JsonNode to be read by @reader. The @reader will take
1689 // a copy of @root
1691 // If another #JsonNode is currently set as root, it will be replaced.
1692 // <root>: a #JsonNode
1693 void set_root(AT0)(AT0 /*Node*/ root=null) nothrow {
1694 json_reader_set_root(&this, UpCast!(Node*)(root));
1699 // The <structname>JsonReaderClass</structname> structure contains only
1700 // private data
1701 struct ReaderClass /* Version 0.12 */ {
1702 private GObject2.ObjectClass parent_class;
1703 extern (C) void function () nothrow _json_padding0;
1704 extern (C) void function () nothrow _json_padding1;
1705 extern (C) void function () nothrow _json_padding2;
1706 extern (C) void function () nothrow _json_padding3;
1707 extern (C) void function () nothrow _json_padding4;
1710 // Error codes enumeration for #JsonReader errors
1711 enum ReaderError /* Version 0.12 */ {
1712 NO_ARRAY = 0,
1713 INVALID_INDEX = 1,
1714 NO_OBJECT = 2,
1715 INVALID_MEMBER = 3,
1716 INVALID_NODE = 4,
1717 NO_VALUE = 5,
1718 INVALID_TYPE = 6
1720 struct ReaderPrivate {
1723 struct Serializable /* Interface */ {
1724 mixin template __interface__() {
1725 // VERSION: 0.10
1726 // Calls the default implementation of the #JsonSerializable
1727 // deserialize_property() virtual function
1729 // This function can be used inside a custom implementation
1730 // of the deserialize_property() virtual function in lieu of:
1732 // |[
1733 // JsonSerializable *iface;
1734 // gboolean res;
1736 // iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE);
1737 // res = iface->deserialize_property (serializable, property_name,
1738 // value,
1739 // pspec,
1740 // property_node);
1741 // ]|
1742 // RETURNS: %TRUE if the property was successfully deserialized.
1743 // <property_name>: the name of the property
1744 // <value>: a pointer to an uninitialized #GValue
1745 // <pspec>: a #GParamSpec
1746 // <property_node>: a #JsonNode containing the serialized property
1747 int default_deserialize_property(AT0, AT1, AT2, AT3)(AT0 /*char*/ property_name, AT1 /*GObject2.Value*/ value, AT2 /*GObject2.ParamSpec*/ pspec, AT3 /*Node*/ property_node) nothrow {
1748 return json_serializable_default_deserialize_property(cast(Serializable*)&this, toCString!(char*)(property_name), UpCast!(GObject2.Value*)(value), UpCast!(GObject2.ParamSpec*)(pspec), UpCast!(Node*)(property_node));
1751 // VERSION: 0.10
1752 // Calls the default implementation of the #JsonSerializable
1753 // serialize_property() virtual function
1755 // This function can be used inside a custom implementation
1756 // of the serialize_property() virtual function in lieu of:
1758 // |[
1759 // JsonSerializable *iface;
1760 // JsonNode *node;
1762 // iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE);
1763 // node = iface->serialize_property (serializable, property_name,
1764 // value,
1765 // pspec);
1766 // ]|
1768 // property
1769 // RETURNS: a #JsonNode containing the serialized
1770 // <property_name>: the name of the property
1771 // <value>: the value of the property
1772 // <pspec>: a #GParamSpec
1773 Node* /*new*/ default_serialize_property(AT0, AT1, AT2)(AT0 /*char*/ property_name, AT1 /*GObject2.Value*/ value, AT2 /*GObject2.ParamSpec*/ pspec) nothrow {
1774 return json_serializable_default_serialize_property(cast(Serializable*)&this, toCString!(char*)(property_name), UpCast!(GObject2.Value*)(value), UpCast!(GObject2.ParamSpec*)(pspec));
1777 // Asks a #JsonSerializable implementation to deserialize the
1778 // property contained inside @property_node into @value.
1779 // RETURNS: %TRUE if the property was successfully deserialized.
1780 // <property_name>: the name of the property
1781 // <value>: a pointer to an uninitialized #GValue
1782 // <pspec>: a #GParamSpec
1783 // <property_node>: a #JsonNode containing the serialized property
1784 int deserialize_property(AT0, AT1, AT2, AT3)(AT0 /*char*/ property_name, /*out*/ AT1 /*GObject2.Value*/ value, AT2 /*GObject2.ParamSpec*/ pspec, AT3 /*Node*/ property_node) nothrow {
1785 return json_serializable_deserialize_property(cast(Serializable*)&this, toCString!(char*)(property_name), UpCast!(GObject2.Value*)(value), UpCast!(GObject2.ParamSpec*)(pspec), UpCast!(Node*)(property_node));
1788 // VERSION: 0.14
1789 // FIXME
1791 // or %NULL if no property was found
1792 // RETURNS: the #GParamSpec for the property
1793 // <name>: the name of the property
1794 GObject2.ParamSpec* find_property(AT0)(AT0 /*char*/ name) nothrow {
1795 return json_serializable_find_property(cast(Serializable*)&this, toCString!(char*)(name));
1797 void get_property(AT0, AT1)(AT0 /*GObject2.ParamSpec*/ pspec, AT1 /*GObject2.Value*/ value) nothrow {
1798 json_serializable_get_property(cast(Serializable*)&this, UpCast!(GObject2.ParamSpec*)(pspec), UpCast!(GObject2.Value*)(value));
1801 // VERSION: 0.14
1802 // FIXME
1804 // of #GParamSpec. Use g_free() to free the array when done.
1805 // RETURNS: an array
1806 // <n_pspecs>: return location for the length of the array of #GParamSpec returned by the function
1807 GObject2.ParamSpec** /*new container*/ list_properties(AT0)(/*out*/ AT0 /*uint*/ n_pspecs) nothrow {
1808 return json_serializable_list_properties(cast(Serializable*)&this, UpCast!(uint*)(n_pspecs));
1811 // Asks a #JsonSerializable implementation to serialize a #GObject
1812 // property into a #JsonNode object.
1813 // RETURNS: a #JsonNode containing the serialized property
1814 // <property_name>: the name of the property
1815 // <value>: the value of the property
1816 // <pspec>: a #GParamSpec
1817 Node* /*new*/ serialize_property(AT0, AT1, AT2)(AT0 /*char*/ property_name, AT1 /*GObject2.Value*/ value, AT2 /*GObject2.ParamSpec*/ pspec) nothrow {
1818 return json_serializable_serialize_property(cast(Serializable*)&this, toCString!(char*)(property_name), UpCast!(GObject2.Value*)(value), UpCast!(GObject2.ParamSpec*)(pspec));
1820 void set_property(AT0, AT1)(AT0 /*GObject2.ParamSpec*/ pspec, AT1 /*GObject2.Value*/ value) nothrow {
1821 json_serializable_set_property(cast(Serializable*)&this, UpCast!(GObject2.ParamSpec*)(pspec), UpCast!(GObject2.Value*)(value));
1824 mixin __interface__;
1828 // Interface that allows serializing and deserializing #GObject<!-- -->s
1829 // with properties storing complex data types. The json_serialize_gobject()
1830 // function will check if the passed #GObject implements this interface,
1831 // so it can also be used to override the default property serialization
1832 // sequence.
1833 struct SerializableIface {
1834 private GObject2.TypeInterface g_iface;
1836 // RETURNS: a #JsonNode containing the serialized property
1837 // <property_name>: the name of the property
1838 // <value>: the value of the property
1839 // <pspec>: a #GParamSpec
1840 extern (C) Node* /*new*/ function (Serializable* serializable, char* property_name, GObject2.Value* value, GObject2.ParamSpec* pspec) nothrow serialize_property;
1842 // RETURNS: %TRUE if the property was successfully deserialized.
1843 // <property_name>: the name of the property
1844 // <value>: a pointer to an uninitialized #GValue
1845 // <pspec>: a #GParamSpec
1846 // <property_node>: a #JsonNode containing the serialized property
1847 extern (C) int function (Serializable* serializable, char* property_name, /*out*/ GObject2.Value* value, GObject2.ParamSpec* pspec, Node* property_node) nothrow deserialize_property;
1849 // RETURNS: the #GParamSpec for the property
1850 // <name>: the name of the property
1851 extern (C) GObject2.ParamSpec* function (Serializable* serializable, char* name) nothrow find_property;
1852 // Unintrospectable functionp: list_properties() / ()
1853 extern (C) GObject2.ParamSpec** function (Serializable* serializable, uint* n_pspecs) nothrow list_properties;
1854 extern (C) void function (Serializable* serializable, GObject2.ParamSpec* pspec, GObject2.Value* value) nothrow set_property;
1855 extern (C) void function (Serializable* serializable, GObject2.ParamSpec* pspec, GObject2.Value* value) nothrow get_property;
1859 // VERSION: 0.10
1860 // Checks whether it is possible to deserialize a #GBoxed of
1861 // type @gboxed_type from a #JsonNode of type @node_type
1862 // RETURNS: %TRUE if the type can be deserialized, %FALSE otherwise
1863 // <gboxed_type>: a boxed type
1864 // <node_type>: a #JsonNode type
1865 static int boxed_can_deserialize()(Type gboxed_type, NodeType node_type) nothrow {
1866 return json_boxed_can_deserialize(gboxed_type, node_type);
1870 // VERSION: 0.10
1871 // Checks whether it is possible to serialize a #GBoxed of
1872 // type @gboxed_type into a #JsonNode. The type of the
1873 // #JsonNode is placed inside @node_type if the function
1874 // returns %TRUE and it's undefined otherwise.
1876 // and %FALSE otherwise.
1877 // RETURNS: %TRUE if the type can be serialized,
1878 // <gboxed_type>: a boxed type
1879 // <node_type>: the #JsonNode type to which the boxed type can be serialized into
1880 static int boxed_can_serialize(AT0)(Type gboxed_type, /*out*/ AT0 /*NodeType*/ node_type) nothrow {
1881 return json_boxed_can_serialize(gboxed_type, UpCast!(NodeType*)(node_type));
1885 // VERSION: 0.10
1886 // Deserializes @node into a #GBoxed of @gboxed_type
1888 // g_boxed_free() to release the resources allocated by this
1889 // function
1890 // RETURNS: the newly allocated #GBoxed. Use
1891 // <gboxed_type>: a boxed type
1892 // <node>: a #JsonNode
1893 static void* /*new*/ boxed_deserialize(AT0)(Type gboxed_type, AT0 /*Node*/ node) nothrow {
1894 return json_boxed_deserialize(gboxed_type, UpCast!(Node*)(node));
1898 // Unintrospectable function: boxed_register_deserialize_func() / json_boxed_register_deserialize_func()
1899 // VERSION: 0.10
1900 // Registers a deserialization function for a #GBoxed of type @gboxed_type
1901 // from a #JsonNode of type @node_type
1902 // <gboxed_type>: a boxed type
1903 // <node_type>: a node type
1904 // <deserialize_func>: deserialization function for @boxed_type from a #JsonNode of type @node_type
1905 static void boxed_register_deserialize_func()(Type gboxed_type, NodeType node_type, BoxedDeserializeFunc deserialize_func) nothrow {
1906 json_boxed_register_deserialize_func(gboxed_type, node_type, deserialize_func);
1910 // Unintrospectable function: boxed_register_serialize_func() / json_boxed_register_serialize_func()
1911 // VERSION: 0.10
1912 // Registers a serialization function for a #GBoxed of type @gboxed_type
1913 // to a #JsonNode of type @node_type
1914 // <gboxed_type>: a boxed type
1915 // <node_type>: a node type
1916 // <serialize_func>: serialization function for @boxed_type into a #JsonNode of type @node_type
1917 static void boxed_register_serialize_func()(Type gboxed_type, NodeType node_type, BoxedSerializeFunc serialize_func) nothrow {
1918 json_boxed_register_serialize_func(gboxed_type, node_type, serialize_func);
1922 // VERSION: 0.10
1923 // Serializes @boxed, a pointer to a #GBoxed of type @gboxed_type,
1924 // into a #JsonNode
1926 // boxed type, or %NULL if serialization either failed or was not possible
1927 // RETURNS: a #JsonNode with the serialization of the
1928 // <gboxed_type>: a boxed type
1929 // <boxed>: a pointer to a #GBoxed of type @gboxed_type
1930 static Node* /*new*/ boxed_serialize(AT0)(Type gboxed_type, AT0 /*const(void)*/ boxed) nothrow {
1931 return json_boxed_serialize(gboxed_type, UpCast!(const(void)*)(boxed));
1935 // VERSION: 0.4
1936 // DEPRECATED (v0.10) function: construct_gobject - Use json_gobject_from_data() instead
1937 // Deserializes a JSON data stream and creates the corresponding
1938 // #GObject class. If @gtype implements the #JsonSerializableIface
1939 // interface, it will be asked to deserialize all the JSON members
1940 // into the respective properties; otherwise, the default implementation
1941 // will be used to translate the compatible JSON native types.
1943 // Note: the JSON data stream must be an object declaration.
1944 // RETURNS: a #GObject or %NULL
1945 // <gtype>: the #GType of object to construct
1946 // <data>: a JSON data stream
1947 // <length>: length of the data stream
1948 static GObject2.Object* /*new*/ construct_gobject(AT0, AT1)(Type gtype, AT0 /*char*/ data, size_t length, AT1 /*GLib2.Error**/ error=null) nothrow {
1949 return json_construct_gobject(gtype, toCString!(char*)(data), length, UpCast!(GLib2.Error**)(error));
1953 // VERSION: 0.10
1954 // Creates a new #GObject of type @gtype, and constructs it
1955 // using the members of the passed #JsonObject
1957 // instance. Use g_object_unref() to free the resources
1958 // allocated by this function
1959 // RETURNS: The newly created #GObject
1960 // <gtype>: the type of the #GObject to create
1961 // <node>: a #JsonNode of type %JSON_NODE_OBJECT describing the instance of type @gtype
1962 static GObject2.Object* /*new*/ gobject_deserialize(AT0)(Type gtype, AT0 /*Node*/ node) nothrow {
1963 return json_gobject_deserialize(gtype, UpCast!(Node*)(node));
1967 // VERSION: 0.10
1968 // Deserializes a JSON data stream and creates the corresponding
1969 // #GObject class. If @gtype implements the #JsonSerializableIface
1970 // interface, it will be asked to deserialize all the JSON members
1971 // into the respective properties; otherwise, the default implementation
1972 // will be used to translate the compatible JSON native types.
1974 // Note: the JSON data stream must be an object declaration.
1975 // RETURNS: a #GObject or %NULL
1976 // <gtype>: the #GType of object to construct
1977 // <data>: a JSON data stream
1978 // <length>: length of the data stream, or -1 if it is NUL-terminated
1979 static GObject2.Object* /*new*/ gobject_from_data(AT0, AT1)(Type gtype, AT0 /*char*/ data, ssize_t length, AT1 /*GLib2.Error**/ error=null) nothrow {
1980 return json_gobject_from_data(gtype, toCString!(char*)(data), length, UpCast!(GLib2.Error**)(error));
1984 // VERSION: 0.10
1985 // Creates a #JsonNode representing the passed #GObject
1986 // instance. Each member of the returned JSON object will
1987 // map to a property of the #GObject
1989 // of type %JSON_NODE_OBJECT. Use json_node_free() to free
1990 // the resources allocated by this function
1991 // RETURNS: the newly created #JsonNode
1992 // <gobject>: a #GObject
1993 static Node* /*new*/ gobject_serialize(AT0)(AT0 /*GObject2.Object*/ gobject) nothrow {
1994 return json_gobject_serialize(UpCast!(GObject2.Object*)(gobject));
1998 // VERSION: 0.10
1999 // Serializes a #GObject into a JSON data stream, iterating recursively
2000 // over each property.
2002 // If @gobject implements the #JsonSerializableIface interface, it will
2003 // be asked to serialize all its properties; otherwise, the default
2004 // implementation will be use to translate the compatible types into
2005 // JSON native types.
2006 // RETURNS: a JSON data stream representing the passed #GObject
2007 // <gobject>: a #GObject
2008 // <length>: return value for the length of the buffer, or %NULL
2009 static char* /*new*/ gobject_to_data(AT0, AT1)(AT0 /*GObject2.Object*/ gobject, /*out*/ AT1 /*size_t*/ length) nothrow {
2010 return json_gobject_to_data(UpCast!(GObject2.Object*)(gobject), UpCast!(size_t*)(length));
2014 // VERSION: 0.14
2015 // Converts a JSON data structure to a GVariant value using @signature to
2016 // resolve ambiguous data types. If no error occurs, the resulting #GVariant
2017 // is guaranteed to conform to @signature.
2019 // If @signature is not %NULL but does not represent a valid GVariant type
2020 // string, %NULL is returned and error is set to %G_IO_ERROR_INVALID_ARGUMENT.
2021 // If a @signature is provided but the JSON structure cannot be mapped to it,
2022 // %NULL is returned and error is set to %G_IO_ERROR_INVALID_DATA.
2023 // If @signature is %NULL, the conversion is done based strictly on the types
2024 // in the JSON nodes.
2026 // @signature, or %NULL on error
2027 // RETURNS: A newly created #GVariant compliant with
2028 // <json_node>: A #JsonNode to convert
2029 // <signature>: A valid #GVariant type string, or %NULL
2030 static GLib2.Variant* /*new*/ gvariant_deserialize(AT0, AT1, AT2)(AT0 /*Node*/ json_node, AT1 /*char*/ signature, AT2 /*GLib2.Error**/ error=null) nothrow {
2031 return json_gvariant_deserialize(UpCast!(Node*)(json_node), toCString!(char*)(signature), UpCast!(GLib2.Error**)(error));
2035 // VERSION: 0.14
2036 // Converts a JSON string to a #GVariant value. This method works exactly
2037 // like json_gvariant_deserialize(), but takes a JSON encoded string instead.
2038 // The string is first converted to a #JsonNode using #JsonParser, and then
2039 // json_gvariant_deserialize() is called.
2041 // @signature, or %NULL on error
2042 // RETURNS: A newly created #GVariant compliant with
2043 // <json>: A JSON data string
2044 // <length>: The length of @json, or -1 if %NULL-terminated
2045 // <signature>: A valid #GVariant type string, or %NULL
2046 static GLib2.Variant* /*new*/ gvariant_deserialize_data(AT0, AT1, AT2)(AT0 /*char*/ json, ssize_t length, AT1 /*char*/ signature, AT2 /*GLib2.Error**/ error=null) nothrow {
2047 return json_gvariant_deserialize_data(toCString!(char*)(json), length, toCString!(char*)(signature), UpCast!(GLib2.Error**)(error));
2051 // VERSION: 0.14
2052 // Converts @variant to a JSON tree.
2054 // JSON data structure obtained from @variant
2055 // RETURNS: A #JsonNode representing the root of the
2056 // <variant>: A #GVariant to convert
2057 static Node* /*new*/ gvariant_serialize(AT0)(AT0 /*GLib2.Variant*/ variant) nothrow {
2058 return json_gvariant_serialize(UpCast!(GLib2.Variant*)(variant));
2062 // VERSION: 0.14
2063 // Converts @variant to its JSON encoded string representation. This method
2064 // is actually a helper function. It uses json_gvariant_serialize() to obtain the
2065 // JSON tree, and then #JsonGenerator to stringify it.
2067 // @variant
2068 // RETURNS: The JSON encoded string corresponding to
2069 // <variant>: A #GVariant to convert
2070 // <length>: Return location for the length of the returned string, or %NULL
2071 static char* /*new*/ gvariant_serialize_data(AT0, AT1)(AT0 /*GLib2.Variant*/ variant, /*out*/ AT1 /*size_t*/ length=null) nothrow {
2072 return json_gvariant_serialize_data(UpCast!(GLib2.Variant*)(variant), UpCast!(size_t*)(length));
2076 // DEPRECATED (v0.10) function: serialize_gobject - Use json_gobject_to_data() instead
2077 // Serializes a #GObject into a JSON data stream. If @gobject implements
2078 // the #JsonSerializableIface interface, it will be asked to serizalize all
2079 // its properties; otherwise, the default implementation will be use to
2080 // translate the compatible types into JSON native types.
2081 // RETURNS: a JSON data stream representing the passed #GObject
2082 // <gobject>: a #GObject
2083 // <length>: return value for the length of the buffer, or %NULL
2084 static char* /*new*/ serialize_gobject(AT0, AT1)(AT0 /*GObject2.Object*/ gobject, /*out*/ AT1 /*size_t*/ length) nothrow {
2085 return json_serialize_gobject(UpCast!(GObject2.Object*)(gobject), UpCast!(size_t*)(length));
2089 // C prototypes:
2091 extern (C) {
2092 Array* /*new*/ json_array_new() nothrow;
2093 Array* /*new*/ json_array_sized_new(uint n_elements) nothrow;
2094 void json_array_add_array_element(Array* this_, Array* value) nothrow;
2095 void json_array_add_boolean_element(Array* this_, int value) nothrow;
2096 void json_array_add_double_element(Array* this_, double value) nothrow;
2097 void json_array_add_element(Array* this_, Node* node) nothrow;
2098 void json_array_add_int_element(Array* this_, long value) nothrow;
2099 void json_array_add_null_element(Array* this_) nothrow;
2100 void json_array_add_object_element(Array* this_, Object* value) nothrow;
2101 void json_array_add_string_element(Array* this_, char* value) nothrow;
2102 Node* /*new*/ json_array_dup_element(Array* this_, uint index_) nothrow;
2103 void json_array_foreach_element(Array* this_, ArrayForeach func, void* data) nothrow;
2104 Array* json_array_get_array_element(Array* this_, uint index_) nothrow;
2105 int json_array_get_boolean_element(Array* this_, uint index_) nothrow;
2106 double json_array_get_double_element(Array* this_, uint index_) nothrow;
2107 Node* json_array_get_element(Array* this_, uint index_) nothrow;
2108 GLib2.List* /*new container*/ json_array_get_elements(Array* this_) nothrow;
2109 long json_array_get_int_element(Array* this_, uint index_) nothrow;
2110 uint json_array_get_length(Array* this_) nothrow;
2111 int json_array_get_null_element(Array* this_, uint index_) nothrow;
2112 Object* json_array_get_object_element(Array* this_, uint index_) nothrow;
2113 char* json_array_get_string_element(Array* this_, uint index_) nothrow;
2114 Array* /*new*/ json_array_ref(Array* this_) nothrow;
2115 void json_array_remove_element(Array* this_, uint index_) nothrow;
2116 void json_array_unref(Array* this_) nothrow;
2117 Builder* /*new*/ json_builder_new() nothrow;
2118 Builder* json_builder_add_boolean_value(Builder* this_, int value) nothrow;
2119 Builder* json_builder_add_double_value(Builder* this_, double value) nothrow;
2120 Builder* json_builder_add_int_value(Builder* this_, long value) nothrow;
2121 Builder* json_builder_add_null_value(Builder* this_) nothrow;
2122 Builder* json_builder_add_string_value(Builder* this_, char* value) nothrow;
2123 Builder* json_builder_add_value(Builder* this_, Node* node) nothrow;
2124 Builder* json_builder_begin_array(Builder* this_) nothrow;
2125 Builder* json_builder_begin_object(Builder* this_) nothrow;
2126 Builder* json_builder_end_array(Builder* this_) nothrow;
2127 Builder* json_builder_end_object(Builder* this_) nothrow;
2128 Node* /*new*/ json_builder_get_root(Builder* this_) nothrow;
2129 void json_builder_reset(Builder* this_) nothrow;
2130 Builder* json_builder_set_member_name(Builder* this_, char* member_name) nothrow;
2131 Generator* /*new*/ json_generator_new() nothrow;
2132 uint json_generator_get_indent(Generator* this_) nothrow;
2133 dchar json_generator_get_indent_char(Generator* this_) nothrow;
2134 int json_generator_get_pretty(Generator* this_) nothrow;
2135 Node* json_generator_get_root(Generator* this_) nothrow;
2136 void json_generator_set_indent(Generator* this_, uint indent_level) nothrow;
2137 void json_generator_set_indent_char(Generator* this_, dchar indent_char) nothrow;
2138 void json_generator_set_pretty(Generator* this_, int is_pretty) nothrow;
2139 void json_generator_set_root(Generator* this_, Node* node) nothrow;
2140 char* /*new*/ json_generator_to_data(Generator* this_, /*out*/ size_t* length) nothrow;
2141 int json_generator_to_file(Generator* this_, char* filename, GLib2.Error** error) nothrow;
2142 int json_generator_to_stream(Generator* this_, Gio2.OutputStream* stream, Gio2.Cancellable* cancellable, GLib2.Error** error) nothrow;
2143 Node* /*new*/ json_node_new(NodeType type) nothrow;
2144 Node* /*new*/ json_node_copy(Node* this_) nothrow;
2145 Array* /*new*/ json_node_dup_array(Node* this_) nothrow;
2146 Object* /*new*/ json_node_dup_object(Node* this_) nothrow;
2147 char* /*new*/ json_node_dup_string(Node* this_) nothrow;
2148 void json_node_free(Node* this_) nothrow;
2149 Array* json_node_get_array(Node* this_) nothrow;
2150 int json_node_get_boolean(Node* this_) nothrow;
2151 double json_node_get_double(Node* this_) nothrow;
2152 long json_node_get_int(Node* this_) nothrow;
2153 NodeType json_node_get_node_type(Node* this_) nothrow;
2154 Object* json_node_get_object(Node* this_) nothrow;
2155 Node* json_node_get_parent(Node* this_) nothrow;
2156 char* json_node_get_string(Node* this_) nothrow;
2157 void json_node_get_value(Node* this_, /*out*/ GObject2.Value* value) nothrow;
2158 Type json_node_get_value_type(Node* this_) nothrow;
2159 int json_node_is_null(Node* this_) nothrow;
2160 void json_node_set_array(Node* this_, Array* array) nothrow;
2161 void json_node_set_boolean(Node* this_, int value) nothrow;
2162 void json_node_set_double(Node* this_, double value) nothrow;
2163 void json_node_set_int(Node* this_, long value) nothrow;
2164 void json_node_set_object(Node* this_, Object* object) nothrow;
2165 void json_node_set_parent(Node* this_, Node* parent) nothrow;
2166 void json_node_set_string(Node* this_, char* value) nothrow;
2167 void json_node_set_value(Node* this_, GObject2.Value* value) nothrow;
2168 void json_node_take_array(Node* this_, Array* array) nothrow;
2169 void json_node_take_object(Node* this_, Object* object) nothrow;
2170 char* json_node_type_name(Node* this_) nothrow;
2171 Object* /*new*/ json_object_new() nothrow;
2172 void json_object_add_member(Object* this_, char* member_name, Node* node) nothrow;
2173 Node* /*new*/ json_object_dup_member(Object* this_, char* member_name) nothrow;
2174 void json_object_foreach_member(Object* this_, ObjectForeach func, void* data) nothrow;
2175 Array* json_object_get_array_member(Object* this_, char* member_name) nothrow;
2176 int json_object_get_boolean_member(Object* this_, char* member_name) nothrow;
2177 double json_object_get_double_member(Object* this_, char* member_name) nothrow;
2178 long json_object_get_int_member(Object* this_, char* member_name) nothrow;
2179 Node* json_object_get_member(Object* this_, char* member_name) nothrow;
2180 GLib2.List* /*new container*/ json_object_get_members(Object* this_) nothrow;
2181 int json_object_get_null_member(Object* this_, char* member_name) nothrow;
2182 Object* json_object_get_object_member(Object* this_, char* member_name) nothrow;
2183 uint json_object_get_size(Object* this_) nothrow;
2184 char* json_object_get_string_member(Object* this_, char* member_name) nothrow;
2185 GLib2.List* /*new container*/ json_object_get_values(Object* this_) nothrow;
2186 int json_object_has_member(Object* this_, char* member_name) nothrow;
2187 Object* /*new*/ json_object_ref(Object* this_) nothrow;
2188 void json_object_remove_member(Object* this_, char* member_name) nothrow;
2189 void json_object_set_array_member(Object* this_, char* member_name, Array* value) nothrow;
2190 void json_object_set_boolean_member(Object* this_, char* member_name, int value) nothrow;
2191 void json_object_set_double_member(Object* this_, char* member_name, double value) nothrow;
2192 void json_object_set_int_member(Object* this_, char* member_name, long value) nothrow;
2193 void json_object_set_member(Object* this_, char* member_name, Node* node) nothrow;
2194 void json_object_set_null_member(Object* this_, char* member_name) nothrow;
2195 void json_object_set_object_member(Object* this_, char* member_name, Object* value) nothrow;
2196 void json_object_set_string_member(Object* this_, char* member_name, char* value) nothrow;
2197 void json_object_unref(Object* this_) nothrow;
2198 Parser* /*new*/ json_parser_new() nothrow;
2199 GLib2.Quark json_parser_error_quark() nothrow;
2200 uint json_parser_get_current_line(Parser* this_) nothrow;
2201 uint json_parser_get_current_pos(Parser* this_) nothrow;
2202 Node* json_parser_get_root(Parser* this_) nothrow;
2203 int json_parser_has_assignment(Parser* this_, /*out*/ char** variable_name=null) nothrow;
2204 int json_parser_load_from_data(Parser* this_, char* data, ssize_t length, GLib2.Error** error) nothrow;
2205 int json_parser_load_from_file(Parser* this_, char* filename, GLib2.Error** error) nothrow;
2206 int json_parser_load_from_stream(Parser* this_, Gio2.InputStream* stream, Gio2.Cancellable* cancellable, GLib2.Error** error) nothrow;
2207 void json_parser_load_from_stream_async(Parser* this_, Gio2.InputStream* stream, Gio2.Cancellable* cancellable, Gio2.AsyncReadyCallback callback, void* user_data) nothrow;
2208 int json_parser_load_from_stream_finish(Parser* this_, Gio2.AsyncResult* result, GLib2.Error** error) nothrow;
2209 Path* /*new*/ json_path_new() nothrow;
2210 GLib2.Quark json_path_error_quark() nothrow;
2211 Node* /*new*/ json_path_query(char* expression, Node* root, GLib2.Error** error) nothrow;
2212 int json_path_compile(Path* this_, char* expression, GLib2.Error** error) nothrow;
2213 Node* /*new*/ json_path_match(Path* this_, Node* root) nothrow;
2214 Reader* /*new*/ json_reader_new(Node* node=null) nothrow;
2215 GLib2.Quark json_reader_error_quark() nothrow;
2216 int json_reader_count_elements(Reader* this_) nothrow;
2217 int json_reader_count_members(Reader* this_) nothrow;
2218 void json_reader_end_element(Reader* this_) nothrow;
2219 void json_reader_end_member(Reader* this_) nothrow;
2220 int json_reader_get_boolean_value(Reader* this_) nothrow;
2221 double json_reader_get_double_value(Reader* this_) nothrow;
2222 GLib2.Error* json_reader_get_error(Reader* this_) nothrow;
2223 long json_reader_get_int_value(Reader* this_) nothrow;
2224 char* json_reader_get_member_name(Reader* this_) nothrow;
2225 int json_reader_get_null_value(Reader* this_) nothrow;
2226 char* json_reader_get_string_value(Reader* this_) nothrow;
2227 Node* json_reader_get_value(Reader* this_) nothrow;
2228 int json_reader_is_array(Reader* this_) nothrow;
2229 int json_reader_is_object(Reader* this_) nothrow;
2230 int json_reader_is_value(Reader* this_) nothrow;
2231 char** /*new*/ json_reader_list_members(Reader* this_) nothrow;
2232 int json_reader_read_element(Reader* this_, uint index_) nothrow;
2233 int json_reader_read_member(Reader* this_, char* member_name) nothrow;
2234 void json_reader_set_root(Reader* this_, Node* root=null) nothrow;
2235 int json_serializable_default_deserialize_property(Serializable* this_, char* property_name, GObject2.Value* value, GObject2.ParamSpec* pspec, Node* property_node) nothrow;
2236 Node* /*new*/ json_serializable_default_serialize_property(Serializable* this_, char* property_name, GObject2.Value* value, GObject2.ParamSpec* pspec) nothrow;
2237 int json_serializable_deserialize_property(Serializable* this_, char* property_name, /*out*/ GObject2.Value* value, GObject2.ParamSpec* pspec, Node* property_node) nothrow;
2238 GObject2.ParamSpec* json_serializable_find_property(Serializable* this_, char* name) nothrow;
2239 void json_serializable_get_property(Serializable* this_, GObject2.ParamSpec* pspec, GObject2.Value* value) nothrow;
2240 GObject2.ParamSpec** /*new container*/ json_serializable_list_properties(Serializable* this_, /*out*/ uint* n_pspecs) nothrow;
2241 Node* /*new*/ json_serializable_serialize_property(Serializable* this_, char* property_name, GObject2.Value* value, GObject2.ParamSpec* pspec) nothrow;
2242 void json_serializable_set_property(Serializable* this_, GObject2.ParamSpec* pspec, GObject2.Value* value) nothrow;
2243 int json_boxed_can_deserialize(Type gboxed_type, NodeType node_type) nothrow;
2244 int json_boxed_can_serialize(Type gboxed_type, /*out*/ NodeType* node_type) nothrow;
2245 void* /*new*/ json_boxed_deserialize(Type gboxed_type, Node* node) nothrow;
2246 void json_boxed_register_deserialize_func(Type gboxed_type, NodeType node_type, BoxedDeserializeFunc deserialize_func) nothrow;
2247 void json_boxed_register_serialize_func(Type gboxed_type, NodeType node_type, BoxedSerializeFunc serialize_func) nothrow;
2248 Node* /*new*/ json_boxed_serialize(Type gboxed_type, const(void)* boxed) nothrow;
2249 GObject2.Object* /*new*/ json_construct_gobject(Type gtype, char* data, size_t length, GLib2.Error** error) nothrow;
2250 GObject2.Object* /*new*/ json_gobject_deserialize(Type gtype, Node* node) nothrow;
2251 GObject2.Object* /*new*/ json_gobject_from_data(Type gtype, char* data, ssize_t length, GLib2.Error** error) nothrow;
2252 Node* /*new*/ json_gobject_serialize(GObject2.Object* gobject) nothrow;
2253 char* /*new*/ json_gobject_to_data(GObject2.Object* gobject, /*out*/ size_t* length) nothrow;
2254 GLib2.Variant* /*new*/ json_gvariant_deserialize(Node* json_node, char* signature, GLib2.Error** error) nothrow;
2255 GLib2.Variant* /*new*/ json_gvariant_deserialize_data(char* json, ssize_t length, char* signature, GLib2.Error** error) nothrow;
2256 Node* /*new*/ json_gvariant_serialize(GLib2.Variant* variant) nothrow;
2257 char* /*new*/ json_gvariant_serialize_data(GLib2.Variant* variant, /*out*/ size_t* length=null) nothrow;
2258 char* /*new*/ json_serialize_gobject(GObject2.Object* gobject, /*out*/ size_t* length) nothrow;