1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gstreamer.Structure;
26 
27 private import glib.ConstructionException;
28 private import glib.Date;
29 private import glib.Str;
30 private import glib.c.functions;
31 private import gobject.ObjectG;
32 private import gobject.Value;
33 private import gobject.ValueArray;
34 private import gstreamer.DateTime;
35 private import gstreamer.c.functions;
36 public  import gstreamer.c.types;
37 private import gtkd.Loader;
38 
39 
40 /**
41  * A #GstStructure is a collection of key/value pairs. The keys are expressed as
42  * GQuarks and the values can be of any GType.
43  * 
44  * In addition to the key/value pairs, a #GstStructure also has a name. The name
45  * starts with a letter and can be filled by letters, numbers and any of
46  * "/-_.:".
47  * 
48  * #GstStructure is used by various GStreamer subsystems to store information in
49  * a flexible and extensible way. A #GstStructure does not have a refcount
50  * because it usually is part of a higher level object such as #GstCaps,
51  * #GstMessage, #GstEvent, #GstQuery. It provides a means to enforce mutability
52  * using the refcount of the parent with the gst_structure_set_parent_refcount()
53  * method.
54  * 
55  * A #GstStructure can be created with gst_structure_new_empty() or
56  * gst_structure_new(), which both take a name and an optional set of key/value
57  * pairs along with the types of the values.
58  * 
59  * Field values can be changed with gst_structure_set_value() or
60  * gst_structure_set().
61  * 
62  * Field values can be retrieved with gst_structure_get_value() or the more
63  * convenient gst_structure_get_*() functions.
64  * 
65  * Fields can be removed with gst_structure_remove_field() or
66  * gst_structure_remove_fields().
67  * 
68  * Strings in structures must be ASCII or UTF-8 encoded. Other encodings are not
69  * allowed. Strings may be %NULL however.
70  * 
71  * ## The serialization format
72  * 
73  * GstStructure serialization format serialize the GstStructure name,
74  * keys/GType/values in a comma separated list with the structure name as first
75  * field without value followed by separated key/value pairs in the form
76  * `key=value`, for example:
77  * 
78  * ```
79  * a-structure, key=value
80  * ````
81  * 
82  * The values type will be inferred if not explicitly specified with the
83  * `(GTypeName)value` syntax, for example the following struct will have one
84  * field called 'is-string' which has the string 'true' as a value:
85  * 
86  * ```
87  * a-struct, field-is-string=(string)true, field-is-boolean=true
88  * ```
89  * 
90  * *Note*: without specifying `(string), `field-is-string` type would have been
91  * inferred as boolean.
92  * 
93  * *Note*: we specified `(string)` as a type even if `gchararray` is the actual
94  * GType name as for convenience some well known types have been aliased or
95  * abbreviated.
96  * 
97  * To avoid specifying the type, you can give some hints to the "type system".
98  * For example to specify a value as a double, you should add a decimal (ie. `1`
99  * is an `int` while `1.0` is a `double`).
100  * 
101  * *Note*: when a structure is serialized with #gst_structure_to_string, all
102  * values are explicitly typed.
103  * 
104  * Some types have special delimiters:
105  * 
106  * - [GstValueArray](GST_TYPE_ARRAY) are inside curly brackets (`{` and `}`).
107  * For example `a-structure, array={1, 2, 3}`
108  * - Ranges are inside brackets (`[` and `]`). For example `a-structure,
109  * range=[1, 6, 2]` 1 being the min value, 6 the maximum and 2 the step. To
110  * specify a #GST_TYPE_INT64_RANGE you need to explicitly specify it like:
111  * `a-structure, a-int64-range=(gint64) [1, 5]`
112  * - [GstValueList](GST_TYPE_LIST) are inside "less and greater than" (`<` and
113  * `>`). For example `a-structure, list=<1, 2, 3>
114  * 
115  * Structures are delimited either by a null character `\0` or a semicolumn `;`
116  * the latter allowing to store multiple structures in the same string (see
117  * #GstCaps).
118  * 
119  * Quotes are used as "default" delimiters and can be used around any types that
120  * don't use other delimiters (for example `a-struct, i=(int)"1"`). They are use
121  * to allow adding spaces or special characters (such as delimiters,
122  * semicolumns, etc..) inside strings and you can use backslashes `\` to escape
123  * characters inside them, for example:
124  * 
125  * ```
126  * a-struct, special="\"{[(;)]}\" can be used inside quotes"
127  * ```
128  * 
129  * They also allow for nested structure, such as:
130  * 
131  * ```
132  * a-struct, nested=(GstStructure)"nested-struct, nested=true"
133  * ```
134  * 
135  * > *Note*: Be aware that the current #GstCaps / #GstStructure serialization
136  * > into string has limited support for nested #GstCaps / #GstStructure fields.
137  * > It can only support one level of nesting. Using more levels will lead to
138  * > unexpected behavior when using serialization features, such as
139  * > gst_caps_to_string() or gst_value_serialize() and their counterparts.
140  */
141 public class Structure
142 {
143 	/** the main Gtk struct */
144 	protected GstStructure* gstStructure;
145 	protected bool ownedRef;
146 
147 	/** Get the main Gtk struct */
148 	public GstStructure* getStructureStruct(bool transferOwnership = false)
149 	{
150 		if (transferOwnership)
151 			ownedRef = false;
152 		return gstStructure;
153 	}
154 
155 	/** the main Gtk struct as a void* */
156 	protected void* getStruct()
157 	{
158 		return cast(void*)gstStructure;
159 	}
160 
161 	/**
162 	 * Sets our main struct and passes it to the parent class.
163 	 */
164 	public this (GstStructure* gstStructure, bool ownedRef = false)
165 	{
166 		this.gstStructure = gstStructure;
167 		this.ownedRef = ownedRef;
168 	}
169 
170 	~this ()
171 	{
172 		if ( Linker.isLoaded(LIBRARY_GSTREAMER) && ownedRef )
173 			gst_structure_free(gstStructure);
174 	}
175 
176 	public static Structure fromString(string name)
177 	{
178 		auto p = gst_structure_new_from_string(Str.toStringz(name));
179 
180 		if(p is null)
181 		{
182 			throw new ConstructionException("null returned by gst_structure_new_from_string(Str.toStringz(name))");
183 		}
184 
185 		return new Structure(cast(GstStructure*)p); //, true);
186 	}
187 
188 	/**
189 	 */
190 
191 	/** */
192 	public static GType getType()
193 	{
194 		return gst_structure_get_type();
195 	}
196 
197 	/**
198 	 * Creates a #GstStructure from a string representation.
199 	 * If end is not %NULL, a pointer to the place inside the given string
200 	 * where parsing ended will be returned.
201 	 *
202 	 * Free-function: gst_structure_free
203 	 *
204 	 * Params:
205 	 *     string_ = a string representation of a #GstStructure.
206 	 *     end = pointer to store the end of the string in.
207 	 *
208 	 * Returns: a new #GstStructure or %NULL
209 	 *     when the string could not be parsed. Free with
210 	 *     gst_structure_free() after use.
211 	 *
212 	 * Throws: ConstructionException GTK+ fails to create the object.
213 	 */
214 	public this(string string_, out string end)
215 	{
216 		char* outend = null;
217 
218 		auto __p = gst_structure_from_string(Str.toStringz(string_), &outend);
219 
220 		if(__p is null)
221 		{
222 			throw new ConstructionException("null returned by from_string");
223 		}
224 
225 		end = Str.toString(outend);
226 
227 		this(cast(GstStructure*) __p);
228 	}
229 
230 	/**
231 	 * Creates a new, empty #GstStructure with the given @name.
232 	 *
233 	 * See gst_structure_set_name() for constraints on the @name parameter.
234 	 *
235 	 * Free-function: gst_structure_free
236 	 *
237 	 * Params:
238 	 *     name = name of new structure
239 	 *
240 	 * Returns: a new, empty #GstStructure
241 	 *
242 	 * Throws: ConstructionException GTK+ fails to create the object.
243 	 */
244 	public this(string name)
245 	{
246 		auto __p = gst_structure_new_empty(Str.toStringz(name));
247 
248 		if(__p is null)
249 		{
250 			throw new ConstructionException("null returned by new_empty");
251 		}
252 
253 		this(cast(GstStructure*) __p);
254 	}
255 
256 	/**
257 	 * Creates a new, empty #GstStructure with the given name as a GQuark.
258 	 *
259 	 * Free-function: gst_structure_free
260 	 *
261 	 * Params:
262 	 *     quark = name of new structure
263 	 *
264 	 * Returns: a new, empty #GstStructure
265 	 *
266 	 * Throws: ConstructionException GTK+ fails to create the object.
267 	 */
268 	public this(GQuark quark)
269 	{
270 		auto __p = gst_structure_new_id_empty(quark);
271 
272 		if(__p is null)
273 		{
274 			throw new ConstructionException("null returned by new_id_empty");
275 		}
276 
277 		this(cast(GstStructure*) __p);
278 	}
279 
280 	/**
281 	 * Creates a new #GstStructure with the given @name.  Structure fields
282 	 * are set according to the varargs in a manner similar to
283 	 * gst_structure_new().
284 	 *
285 	 * See gst_structure_set_name() for constraints on the @name parameter.
286 	 *
287 	 * Free-function: gst_structure_free
288 	 *
289 	 * Params:
290 	 *     name = name of new structure
291 	 *     firstfield = name of first field to set
292 	 *     varargs = variable argument list
293 	 *
294 	 * Returns: a new #GstStructure
295 	 *
296 	 * Throws: ConstructionException GTK+ fails to create the object.
297 	 */
298 	public this(string name, string firstfield, void* varargs)
299 	{
300 		auto __p = gst_structure_new_valist(Str.toStringz(name), Str.toStringz(firstfield), varargs);
301 
302 		if(__p is null)
303 		{
304 			throw new ConstructionException("null returned by new_valist");
305 		}
306 
307 		this(cast(GstStructure*) __p);
308 	}
309 
310 	/**
311 	 * Tries intersecting @struct1 and @struct2 and reports whether the result
312 	 * would not be empty.
313 	 *
314 	 * Params:
315 	 *     struct2 = a #GstStructure
316 	 *
317 	 * Returns: %TRUE if intersection would not be empty
318 	 */
319 	public bool canIntersect(Structure struct2)
320 	{
321 		return gst_structure_can_intersect(gstStructure, (struct2 is null) ? null : struct2.getStructureStruct()) != 0;
322 	}
323 
324 	/**
325 	 * Duplicates a #GstStructure and all its fields and values.
326 	 *
327 	 * Free-function: gst_structure_free
328 	 *
329 	 * Returns: a new #GstStructure.
330 	 */
331 	public Structure copy()
332 	{
333 		auto __p = gst_structure_copy(gstStructure);
334 
335 		if(__p is null)
336 		{
337 			return null;
338 		}
339 
340 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) __p, true);
341 	}
342 
343 	/**
344 	 * Calls the provided function once for each field in the #GstStructure. In
345 	 * contrast to gst_structure_foreach(), the function may modify the fields.
346 	 * In contrast to gst_structure_map_in_place(), the field is removed from
347 	 * the structure if %FALSE is returned from the function.
348 	 * The structure must be mutable.
349 	 *
350 	 * Params:
351 	 *     func = a function to call for each field
352 	 *     userData = private data
353 	 *
354 	 * Since: 1.6
355 	 */
356 	public void filterAndMapInPlace(GstStructureFilterMapFunc func, void* userData)
357 	{
358 		gst_structure_filter_and_map_in_place(gstStructure, func, userData);
359 	}
360 
361 	/**
362 	 * Fixate all values in @structure using gst_value_fixate().
363 	 * @structure will be modified in-place and should be writable.
364 	 */
365 	public void fixate()
366 	{
367 		gst_structure_fixate(gstStructure);
368 	}
369 
370 	/**
371 	 * Fixates a #GstStructure by changing the given field with its fixated value.
372 	 *
373 	 * Params:
374 	 *     fieldName = a field in @structure
375 	 *
376 	 * Returns: %TRUE if the structure field could be fixated
377 	 */
378 	public bool fixateField(string fieldName)
379 	{
380 		return gst_structure_fixate_field(gstStructure, Str.toStringz(fieldName)) != 0;
381 	}
382 
383 	/**
384 	 * Fixates a #GstStructure by changing the given @field_name field to the given
385 	 * @target boolean if that field is not fixed yet.
386 	 *
387 	 * Params:
388 	 *     fieldName = a field in @structure
389 	 *     target = the target value of the fixation
390 	 *
391 	 * Returns: %TRUE if the structure could be fixated
392 	 */
393 	public bool fixateFieldBoolean(string fieldName, bool target)
394 	{
395 		return gst_structure_fixate_field_boolean(gstStructure, Str.toStringz(fieldName), target) != 0;
396 	}
397 
398 	/**
399 	 * Fixates a #GstStructure by changing the given field to the nearest
400 	 * double to @target that is a subset of the existing field.
401 	 *
402 	 * Params:
403 	 *     fieldName = a field in @structure
404 	 *     target = the target value of the fixation
405 	 *
406 	 * Returns: %TRUE if the structure could be fixated
407 	 */
408 	public bool fixateFieldNearestDouble(string fieldName, double target)
409 	{
410 		return gst_structure_fixate_field_nearest_double(gstStructure, Str.toStringz(fieldName), target) != 0;
411 	}
412 
413 	/**
414 	 * Fixates a #GstStructure by changing the given field to the nearest
415 	 * fraction to @target_numerator/@target_denominator that is a subset
416 	 * of the existing field.
417 	 *
418 	 * Params:
419 	 *     fieldName = a field in @structure
420 	 *     targetNumerator = The numerator of the target value of the fixation
421 	 *     targetDenominator = The denominator of the target value of the fixation
422 	 *
423 	 * Returns: %TRUE if the structure could be fixated
424 	 */
425 	public bool fixateFieldNearestFraction(string fieldName, int targetNumerator, int targetDenominator)
426 	{
427 		return gst_structure_fixate_field_nearest_fraction(gstStructure, Str.toStringz(fieldName), targetNumerator, targetDenominator) != 0;
428 	}
429 
430 	/**
431 	 * Fixates a #GstStructure by changing the given field to the nearest
432 	 * integer to @target that is a subset of the existing field.
433 	 *
434 	 * Params:
435 	 *     fieldName = a field in @structure
436 	 *     target = the target value of the fixation
437 	 *
438 	 * Returns: %TRUE if the structure could be fixated
439 	 */
440 	public bool fixateFieldNearestInt(string fieldName, int target)
441 	{
442 		return gst_structure_fixate_field_nearest_int(gstStructure, Str.toStringz(fieldName), target) != 0;
443 	}
444 
445 	/**
446 	 * Fixates a #GstStructure by changing the given @field_name field to the given
447 	 * @target string if that field is not fixed yet.
448 	 *
449 	 * Params:
450 	 *     fieldName = a field in @structure
451 	 *     target = the target value of the fixation
452 	 *
453 	 * Returns: %TRUE if the structure could be fixated
454 	 */
455 	public bool fixateFieldString(string fieldName, string target)
456 	{
457 		return gst_structure_fixate_field_string(gstStructure, Str.toStringz(fieldName), Str.toStringz(target)) != 0;
458 	}
459 
460 	alias foreac = foreach_;
461 	/**
462 	 * Calls the provided function once for each field in the #GstStructure. The
463 	 * function must not modify the fields. Also see gst_structure_map_in_place()
464 	 * and gst_structure_filter_and_map_in_place().
465 	 *
466 	 * Params:
467 	 *     func = a function to call for each field
468 	 *     userData = private data
469 	 *
470 	 * Returns: %TRUE if the supplied function returns %TRUE For each of the fields,
471 	 *     %FALSE otherwise.
472 	 */
473 	public bool foreach_(GstStructureForeachFunc func, void* userData)
474 	{
475 		return gst_structure_foreach(gstStructure, func, userData) != 0;
476 	}
477 
478 	/**
479 	 * Frees a #GstStructure and all its fields and values. The structure must not
480 	 * have a parent when this function is called.
481 	 */
482 	public void free()
483 	{
484 		gst_structure_free(gstStructure);
485 		ownedRef = false;
486 	}
487 
488 	/**
489 	 * This is useful in language bindings where unknown #GValue types are not
490 	 * supported. This function will convert the %GST_TYPE_ARRAY into a newly
491 	 * allocated #GValueArray and return it through @array. Be aware that this is
492 	 * slower then getting the #GValue directly.
493 	 *
494 	 * Params:
495 	 *     fieldname = the name of a field
496 	 *     array = a pointer to a #GValueArray
497 	 *
498 	 * Returns: %TRUE if the value could be set correctly. If there was no field
499 	 *     with @fieldname or the existing field did not contain a %GST_TYPE_ARRAY,
500 	 *     this function returns %FALSE.
501 	 *
502 	 * Since: 1.12
503 	 */
504 	public bool getArray(string fieldname, out ValueArray array)
505 	{
506 		GValueArray* outarray = null;
507 
508 		auto __p = gst_structure_get_array(gstStructure, Str.toStringz(fieldname), &outarray) != 0;
509 
510 		array = ObjectG.getDObject!(ValueArray)(outarray);
511 
512 		return __p;
513 	}
514 
515 	/**
516 	 * Sets the boolean pointed to by @value corresponding to the value of the
517 	 * given field.  Caller is responsible for making sure the field exists
518 	 * and has the correct type.
519 	 *
520 	 * Params:
521 	 *     fieldname = the name of a field
522 	 *     value = a pointer to a #gboolean to set
523 	 *
524 	 * Returns: %TRUE if the value could be set correctly. If there was no field
525 	 *     with @fieldname or the existing field did not contain a boolean, this
526 	 *     function returns %FALSE.
527 	 */
528 	public bool getBoolean(string fieldname, out bool value)
529 	{
530 		int outvalue;
531 
532 		auto __p = gst_structure_get_boolean(gstStructure, Str.toStringz(fieldname), &outvalue) != 0;
533 
534 		value = (outvalue == 1);
535 
536 		return __p;
537 	}
538 
539 	/**
540 	 * Sets the clock time pointed to by @value corresponding to the clock time
541 	 * of the given field.  Caller is responsible for making sure the field exists
542 	 * and has the correct type.
543 	 *
544 	 * Params:
545 	 *     fieldname = the name of a field
546 	 *     value = a pointer to a #GstClockTime to set
547 	 *
548 	 * Returns: %TRUE if the value could be set correctly. If there was no field
549 	 *     with @fieldname or the existing field did not contain a #GstClockTime, this
550 	 *     function returns %FALSE.
551 	 */
552 	public bool getClockTime(string fieldname, out GstClockTime value)
553 	{
554 		return gst_structure_get_clock_time(gstStructure, Str.toStringz(fieldname), &value) != 0;
555 	}
556 
557 	/**
558 	 * Sets the date pointed to by @value corresponding to the date of the
559 	 * given field.  Caller is responsible for making sure the field exists
560 	 * and has the correct type.
561 	 *
562 	 * On success @value will point to a newly-allocated copy of the date which
563 	 * should be freed with g_date_free() when no longer needed (note: this is
564 	 * inconsistent with e.g. gst_structure_get_string() which doesn't return a
565 	 * copy of the string).
566 	 *
567 	 * Params:
568 	 *     fieldname = the name of a field
569 	 *     value = a pointer to a #GDate to set
570 	 *
571 	 * Returns: %TRUE if the value could be set correctly. If there was no field
572 	 *     with @fieldname or the existing field did not contain a data, this function
573 	 *     returns %FALSE.
574 	 */
575 	public bool getDate(string fieldname, out Date value)
576 	{
577 		GDate* outvalue = null;
578 
579 		auto __p = gst_structure_get_date(gstStructure, Str.toStringz(fieldname), &outvalue) != 0;
580 
581 		value = new Date(outvalue);
582 
583 		return __p;
584 	}
585 
586 	/**
587 	 * Sets the datetime pointed to by @value corresponding to the datetime of the
588 	 * given field. Caller is responsible for making sure the field exists
589 	 * and has the correct type.
590 	 *
591 	 * On success @value will point to a reference of the datetime which
592 	 * should be unreffed with gst_date_time_unref() when no longer needed
593 	 * (note: this is inconsistent with e.g. gst_structure_get_string()
594 	 * which doesn't return a copy of the string).
595 	 *
596 	 * Params:
597 	 *     fieldname = the name of a field
598 	 *     value = a pointer to a #GstDateTime to set
599 	 *
600 	 * Returns: %TRUE if the value could be set correctly. If there was no field
601 	 *     with @fieldname or the existing field did not contain a data, this function
602 	 *     returns %FALSE.
603 	 */
604 	public bool getDateTime(string fieldname, out DateTime value)
605 	{
606 		GstDateTime* outvalue = null;
607 
608 		auto __p = gst_structure_get_date_time(gstStructure, Str.toStringz(fieldname), &outvalue) != 0;
609 
610 		value = ObjectG.getDObject!(DateTime)(outvalue);
611 
612 		return __p;
613 	}
614 
615 	/**
616 	 * Sets the double pointed to by @value corresponding to the value of the
617 	 * given field.  Caller is responsible for making sure the field exists
618 	 * and has the correct type.
619 	 *
620 	 * Params:
621 	 *     fieldname = the name of a field
622 	 *     value = a pointer to a gdouble to set
623 	 *
624 	 * Returns: %TRUE if the value could be set correctly. If there was no field
625 	 *     with @fieldname or the existing field did not contain a double, this
626 	 *     function returns %FALSE.
627 	 */
628 	public bool getDouble(string fieldname, out double value)
629 	{
630 		return gst_structure_get_double(gstStructure, Str.toStringz(fieldname), &value) != 0;
631 	}
632 
633 	/**
634 	 * Sets the int pointed to by @value corresponding to the value of the
635 	 * given field.  Caller is responsible for making sure the field exists,
636 	 * has the correct type and that the enumtype is correct.
637 	 *
638 	 * Params:
639 	 *     fieldname = the name of a field
640 	 *     enumtype = the enum type of a field
641 	 *     value = a pointer to an int to set
642 	 *
643 	 * Returns: %TRUE if the value could be set correctly. If there was no field
644 	 *     with @fieldname or the existing field did not contain an enum of the given
645 	 *     type, this function returns %FALSE.
646 	 */
647 	public bool getEnum(string fieldname, GType enumtype, out int value)
648 	{
649 		return gst_structure_get_enum(gstStructure, Str.toStringz(fieldname), enumtype, &value) != 0;
650 	}
651 
652 	/**
653 	 * Finds the field with the given name, and returns the type of the
654 	 * value it contains.  If the field is not found, G_TYPE_INVALID is
655 	 * returned.
656 	 *
657 	 * Params:
658 	 *     fieldname = the name of the field
659 	 *
660 	 * Returns: the #GValue of the field
661 	 */
662 	public GType getFieldType(string fieldname)
663 	{
664 		return gst_structure_get_field_type(gstStructure, Str.toStringz(fieldname));
665 	}
666 
667 	/**
668 	 * Read the GstFlagSet flags and mask out of the structure into the
669 	 * provided pointers.
670 	 *
671 	 * Params:
672 	 *     fieldname = the name of a field
673 	 *     valueFlags = a pointer to a guint for the flags field
674 	 *     valueMask = a pointer to a guint for the mask field
675 	 *
676 	 * Returns: %TRUE if the values could be set correctly. If there was no field
677 	 *     with @fieldname or the existing field did not contain a GstFlagSet, this
678 	 *     function returns %FALSE.
679 	 *
680 	 * Since: 1.6
681 	 */
682 	public bool getFlagset(string fieldname, out uint valueFlags, out uint valueMask)
683 	{
684 		return gst_structure_get_flagset(gstStructure, Str.toStringz(fieldname), &valueFlags, &valueMask) != 0;
685 	}
686 
687 	/**
688 	 * Sets the integers pointed to by @value_numerator and @value_denominator
689 	 * corresponding to the value of the given field.  Caller is responsible
690 	 * for making sure the field exists and has the correct type.
691 	 *
692 	 * Params:
693 	 *     fieldname = the name of a field
694 	 *     valueNumerator = a pointer to an int to set
695 	 *     valueDenominator = a pointer to an int to set
696 	 *
697 	 * Returns: %TRUE if the values could be set correctly. If there was no field
698 	 *     with @fieldname or the existing field did not contain a GstFraction, this
699 	 *     function returns %FALSE.
700 	 */
701 	public bool getFraction(string fieldname, out int valueNumerator, out int valueDenominator)
702 	{
703 		return gst_structure_get_fraction(gstStructure, Str.toStringz(fieldname), &valueNumerator, &valueDenominator) != 0;
704 	}
705 
706 	/**
707 	 * Sets the int pointed to by @value corresponding to the value of the
708 	 * given field.  Caller is responsible for making sure the field exists
709 	 * and has the correct type.
710 	 *
711 	 * Params:
712 	 *     fieldname = the name of a field
713 	 *     value = a pointer to an int to set
714 	 *
715 	 * Returns: %TRUE if the value could be set correctly. If there was no field
716 	 *     with @fieldname or the existing field did not contain an int, this function
717 	 *     returns %FALSE.
718 	 */
719 	public bool getInt(string fieldname, out int value)
720 	{
721 		return gst_structure_get_int(gstStructure, Str.toStringz(fieldname), &value) != 0;
722 	}
723 
724 	/**
725 	 * Sets the #gint64 pointed to by @value corresponding to the value of the
726 	 * given field. Caller is responsible for making sure the field exists
727 	 * and has the correct type.
728 	 *
729 	 * Params:
730 	 *     fieldname = the name of a field
731 	 *     value = a pointer to a #gint64 to set
732 	 *
733 	 * Returns: %TRUE if the value could be set correctly. If there was no field
734 	 *     with @fieldname or the existing field did not contain a #gint64, this function
735 	 *     returns %FALSE.
736 	 *
737 	 * Since: 1.4
738 	 */
739 	public bool getInt64(string fieldname, out long value)
740 	{
741 		return gst_structure_get_int64(gstStructure, Str.toStringz(fieldname), &value) != 0;
742 	}
743 
744 	/**
745 	 * This is useful in language bindings where unknown #GValue types are not
746 	 * supported. This function will convert the %GST_TYPE_LIST into a newly
747 	 * allocated GValueArray and return it through @array. Be aware that this is
748 	 * slower then getting the #GValue directly.
749 	 *
750 	 * Params:
751 	 *     fieldname = the name of a field
752 	 *     array = a pointer to a #GValueArray
753 	 *
754 	 * Returns: %TRUE if the value could be set correctly. If there was no field
755 	 *     with @fieldname or the existing field did not contain a %GST_TYPE_LIST, this
756 	 *     function returns %FALSE.
757 	 *
758 	 * Since: 1.12
759 	 */
760 	public bool getList(string fieldname, out ValueArray array)
761 	{
762 		GValueArray* outarray = null;
763 
764 		auto __p = gst_structure_get_list(gstStructure, Str.toStringz(fieldname), &outarray) != 0;
765 
766 		array = ObjectG.getDObject!(ValueArray)(outarray);
767 
768 		return __p;
769 	}
770 
771 	/**
772 	 * Get the name of @structure as a string.
773 	 *
774 	 * Returns: the name of the structure.
775 	 */
776 	public string getName()
777 	{
778 		return Str.toString(gst_structure_get_name(gstStructure));
779 	}
780 
781 	/**
782 	 * Get the name of @structure as a GQuark.
783 	 *
784 	 * Returns: the quark representing the name of the structure.
785 	 */
786 	public GQuark getNameId()
787 	{
788 		return gst_structure_get_name_id(gstStructure);
789 	}
790 
791 	/**
792 	 * Finds the field corresponding to @fieldname, and returns the string
793 	 * contained in the field's value.  Caller is responsible for making
794 	 * sure the field exists and has the correct type.
795 	 *
796 	 * The string should not be modified, and remains valid until the next
797 	 * call to a gst_structure_*() function with the given structure.
798 	 *
799 	 * Params:
800 	 *     fieldname = the name of a field
801 	 *
802 	 * Returns: a pointer to the string or %NULL when the
803 	 *     field did not exist or did not contain a string.
804 	 */
805 	public string getString(string fieldname)
806 	{
807 		return Str.toString(gst_structure_get_string(gstStructure, Str.toStringz(fieldname)));
808 	}
809 
810 	/**
811 	 * Sets the uint pointed to by @value corresponding to the value of the
812 	 * given field.  Caller is responsible for making sure the field exists
813 	 * and has the correct type.
814 	 *
815 	 * Params:
816 	 *     fieldname = the name of a field
817 	 *     value = a pointer to a uint to set
818 	 *
819 	 * Returns: %TRUE if the value could be set correctly. If there was no field
820 	 *     with @fieldname or the existing field did not contain a uint, this function
821 	 *     returns %FALSE.
822 	 */
823 	public bool getUint(string fieldname, out uint value)
824 	{
825 		return gst_structure_get_uint(gstStructure, Str.toStringz(fieldname), &value) != 0;
826 	}
827 
828 	/**
829 	 * Sets the #guint64 pointed to by @value corresponding to the value of the
830 	 * given field. Caller is responsible for making sure the field exists
831 	 * and has the correct type.
832 	 *
833 	 * Params:
834 	 *     fieldname = the name of a field
835 	 *     value = a pointer to a #guint64 to set
836 	 *
837 	 * Returns: %TRUE if the value could be set correctly. If there was no field
838 	 *     with @fieldname or the existing field did not contain a #guint64, this function
839 	 *     returns %FALSE.
840 	 *
841 	 * Since: 1.4
842 	 */
843 	public bool getUint64(string fieldname, out ulong value)
844 	{
845 		return gst_structure_get_uint64(gstStructure, Str.toStringz(fieldname), &value) != 0;
846 	}
847 
848 	/**
849 	 * Parses the variable arguments and reads fields from @structure accordingly.
850 	 * valist-variant of gst_structure_get(). Look at the documentation of
851 	 * gst_structure_get() for more details.
852 	 *
853 	 * Params:
854 	 *     firstFieldname = the name of the first field to read
855 	 *     args = variable arguments
856 	 *
857 	 * Returns: %TRUE, or %FALSE if there was a problem reading any of the fields
858 	 */
859 	public bool getValist(string firstFieldname, void* args)
860 	{
861 		return gst_structure_get_valist(gstStructure, Str.toStringz(firstFieldname), args) != 0;
862 	}
863 
864 	/**
865 	 * Get the value of the field with name @fieldname.
866 	 *
867 	 * Params:
868 	 *     fieldname = the name of the field to get
869 	 *
870 	 * Returns: the #GValue corresponding to the field with the given
871 	 *     name.
872 	 */
873 	public Value getValue(string fieldname)
874 	{
875 		auto __p = gst_structure_get_value(gstStructure, Str.toStringz(fieldname));
876 
877 		if(__p is null)
878 		{
879 			return null;
880 		}
881 
882 		return ObjectG.getDObject!(Value)(cast(GValue*) __p);
883 	}
884 
885 	/**
886 	 * Check if @structure contains a field named @fieldname.
887 	 *
888 	 * Params:
889 	 *     fieldname = the name of a field
890 	 *
891 	 * Returns: %TRUE if the structure contains a field with the given name
892 	 */
893 	public bool hasField(string fieldname)
894 	{
895 		return gst_structure_has_field(gstStructure, Str.toStringz(fieldname)) != 0;
896 	}
897 
898 	/**
899 	 * Check if @structure contains a field named @fieldname and with GType @type.
900 	 *
901 	 * Params:
902 	 *     fieldname = the name of a field
903 	 *     type = the type of a value
904 	 *
905 	 * Returns: %TRUE if the structure contains a field with the given name and type
906 	 */
907 	public bool hasFieldTyped(string fieldname, GType type)
908 	{
909 		return gst_structure_has_field_typed(gstStructure, Str.toStringz(fieldname), type) != 0;
910 	}
911 
912 	/**
913 	 * Checks if the structure has the given name
914 	 *
915 	 * Params:
916 	 *     name = structure name to check for
917 	 *
918 	 * Returns: %TRUE if @name matches the name of the structure.
919 	 */
920 	public bool hasName(string name)
921 	{
922 		return gst_structure_has_name(gstStructure, Str.toStringz(name)) != 0;
923 	}
924 
925 	/**
926 	 * Parses the variable arguments and reads fields from @structure accordingly.
927 	 * valist-variant of gst_structure_id_get(). Look at the documentation of
928 	 * gst_structure_id_get() for more details.
929 	 *
930 	 * Params:
931 	 *     firstFieldId = the quark of the first field to read
932 	 *     args = variable arguments
933 	 *
934 	 * Returns: %TRUE, or %FALSE if there was a problem reading any of the fields
935 	 */
936 	public bool idGetValist(GQuark firstFieldId, void* args)
937 	{
938 		return gst_structure_id_get_valist(gstStructure, firstFieldId, args) != 0;
939 	}
940 
941 	/**
942 	 * Get the value of the field with GQuark @field.
943 	 *
944 	 * Params:
945 	 *     field = the #GQuark of the field to get
946 	 *
947 	 * Returns: the #GValue corresponding to the field with the given
948 	 *     name identifier.
949 	 */
950 	public Value idGetValue(GQuark field)
951 	{
952 		auto __p = gst_structure_id_get_value(gstStructure, field);
953 
954 		if(__p is null)
955 		{
956 			return null;
957 		}
958 
959 		return ObjectG.getDObject!(Value)(cast(GValue*) __p);
960 	}
961 
962 	/**
963 	 * Check if @structure contains a field named @field.
964 	 *
965 	 * Params:
966 	 *     field = #GQuark of the field name
967 	 *
968 	 * Returns: %TRUE if the structure contains a field with the given name
969 	 */
970 	public bool idHasField(GQuark field)
971 	{
972 		return gst_structure_id_has_field(gstStructure, field) != 0;
973 	}
974 
975 	/**
976 	 * Check if @structure contains a field named @field and with GType @type.
977 	 *
978 	 * Params:
979 	 *     field = #GQuark of the field name
980 	 *     type = the type of a value
981 	 *
982 	 * Returns: %TRUE if the structure contains a field with the given name and type
983 	 */
984 	public bool idHasFieldTyped(GQuark field, GType type)
985 	{
986 		return gst_structure_id_has_field_typed(gstStructure, field, type) != 0;
987 	}
988 
989 	/**
990 	 * va_list form of gst_structure_id_set().
991 	 *
992 	 * Params:
993 	 *     fieldname = the name of the field to set
994 	 *     varargs = variable arguments
995 	 */
996 	public void idSetValist(GQuark fieldname, void* varargs)
997 	{
998 		gst_structure_id_set_valist(gstStructure, fieldname, varargs);
999 	}
1000 
1001 	/**
1002 	 * Sets the field with the given GQuark @field to @value.  If the field
1003 	 * does not exist, it is created.  If the field exists, the previous
1004 	 * value is replaced and freed.
1005 	 *
1006 	 * Params:
1007 	 *     field = a #GQuark representing a field
1008 	 *     value = the new value of the field
1009 	 */
1010 	public void idSetValue(GQuark field, Value value)
1011 	{
1012 		gst_structure_id_set_value(gstStructure, field, (value is null) ? null : value.getValueStruct());
1013 	}
1014 
1015 	/**
1016 	 * Sets the field with the given GQuark @field to @value.  If the field
1017 	 * does not exist, it is created.  If the field exists, the previous
1018 	 * value is replaced and freed.
1019 	 *
1020 	 * Params:
1021 	 *     field = a #GQuark representing a field
1022 	 *     value = the new value of the field
1023 	 */
1024 	public void idTakeValue(GQuark field, Value value)
1025 	{
1026 		gst_structure_id_take_value(gstStructure, field, (value is null) ? null : value.getValueStruct());
1027 	}
1028 
1029 	/**
1030 	 * Intersects @struct1 and @struct2 and returns the intersection.
1031 	 *
1032 	 * Params:
1033 	 *     struct2 = a #GstStructure
1034 	 *
1035 	 * Returns: Intersection of @struct1 and @struct2
1036 	 */
1037 	public Structure intersect(Structure struct2)
1038 	{
1039 		auto __p = gst_structure_intersect(gstStructure, (struct2 is null) ? null : struct2.getStructureStruct());
1040 
1041 		if(__p is null)
1042 		{
1043 			return null;
1044 		}
1045 
1046 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) __p, true);
1047 	}
1048 
1049 	/**
1050 	 * Tests if the two #GstStructure are equal.
1051 	 *
1052 	 * Params:
1053 	 *     structure2 = a #GstStructure.
1054 	 *
1055 	 * Returns: %TRUE if the two structures have the same name and field.
1056 	 */
1057 	public bool isEqual(Structure structure2)
1058 	{
1059 		return gst_structure_is_equal(gstStructure, (structure2 is null) ? null : structure2.getStructureStruct()) != 0;
1060 	}
1061 
1062 	/**
1063 	 * Checks if @subset is a subset of @superset, i.e. has the same
1064 	 * structure name and for all fields that are existing in @superset,
1065 	 * @subset has a value that is a subset of the value in @superset.
1066 	 *
1067 	 * Params:
1068 	 *     superset = a potentially greater #GstStructure
1069 	 *
1070 	 * Returns: %TRUE if @subset is a subset of @superset
1071 	 */
1072 	public bool isSubset(Structure superset)
1073 	{
1074 		return gst_structure_is_subset(gstStructure, (superset is null) ? null : superset.getStructureStruct()) != 0;
1075 	}
1076 
1077 	/**
1078 	 * Calls the provided function once for each field in the #GstStructure. In
1079 	 * contrast to gst_structure_foreach(), the function may modify but not delete the
1080 	 * fields. The structure must be mutable.
1081 	 *
1082 	 * Params:
1083 	 *     func = a function to call for each field
1084 	 *     userData = private data
1085 	 *
1086 	 * Returns: %TRUE if the supplied function returns %TRUE For each of the fields,
1087 	 *     %FALSE otherwise.
1088 	 */
1089 	public bool mapInPlace(GstStructureMapFunc func, void* userData)
1090 	{
1091 		return gst_structure_map_in_place(gstStructure, func, userData) != 0;
1092 	}
1093 
1094 	/**
1095 	 * Get the number of fields in the structure.
1096 	 *
1097 	 * Returns: the number of fields in the structure
1098 	 */
1099 	public int nFields()
1100 	{
1101 		return gst_structure_n_fields(gstStructure);
1102 	}
1103 
1104 	/**
1105 	 * Get the name of the given field number, counting from 0 onwards.
1106 	 *
1107 	 * Params:
1108 	 *     index = the index to get the name of
1109 	 *
1110 	 * Returns: the name of the given field number
1111 	 */
1112 	public string nthFieldName(uint index)
1113 	{
1114 		return Str.toString(gst_structure_nth_field_name(gstStructure, index));
1115 	}
1116 
1117 	/**
1118 	 * Removes all fields in a GstStructure.
1119 	 */
1120 	public void removeAllFields()
1121 	{
1122 		gst_structure_remove_all_fields(gstStructure);
1123 	}
1124 
1125 	/**
1126 	 * Removes the field with the given name.  If the field with the given
1127 	 * name does not exist, the structure is unchanged.
1128 	 *
1129 	 * Params:
1130 	 *     fieldname = the name of the field to remove
1131 	 */
1132 	public void removeField(string fieldname)
1133 	{
1134 		gst_structure_remove_field(gstStructure, Str.toStringz(fieldname));
1135 	}
1136 
1137 	/**
1138 	 * va_list form of gst_structure_remove_fields().
1139 	 *
1140 	 * Params:
1141 	 *     fieldname = the name of the field to remove
1142 	 *     varargs = %NULL-terminated list of more fieldnames to remove
1143 	 */
1144 	public void removeFieldsValist(string fieldname, void* varargs)
1145 	{
1146 		gst_structure_remove_fields_valist(gstStructure, Str.toStringz(fieldname), varargs);
1147 	}
1148 
1149 	/**
1150 	 * This is useful in language bindings where unknown GValue types are not
1151 	 * supported. This function will convert a @array to %GST_TYPE_ARRAY and set
1152 	 * the field specified by @fieldname.  Be aware that this is slower then using
1153 	 * %GST_TYPE_ARRAY in a #GValue directly.
1154 	 *
1155 	 * Params:
1156 	 *     fieldname = the name of a field
1157 	 *     array = a pointer to a #GValueArray
1158 	 *
1159 	 * Since: 1.12
1160 	 */
1161 	public void setArray(string fieldname, ValueArray array)
1162 	{
1163 		gst_structure_set_array(gstStructure, Str.toStringz(fieldname), (array is null) ? null : array.getValueArrayStruct());
1164 	}
1165 
1166 	/**
1167 	 * This is useful in language bindings where unknown GValue types are not
1168 	 * supported. This function will convert a @array to %GST_TYPE_LIST and set
1169 	 * the field specified by @fieldname. Be aware that this is slower then using
1170 	 * %GST_TYPE_LIST in a #GValue directly.
1171 	 *
1172 	 * Params:
1173 	 *     fieldname = the name of a field
1174 	 *     array = a pointer to a #GValueArray
1175 	 *
1176 	 * Since: 1.12
1177 	 */
1178 	public void setList(string fieldname, ValueArray array)
1179 	{
1180 		gst_structure_set_list(gstStructure, Str.toStringz(fieldname), (array is null) ? null : array.getValueArrayStruct());
1181 	}
1182 
1183 	/**
1184 	 * Sets the name of the structure to the given @name.  The string
1185 	 * provided is copied before being used. It must not be empty, start with a
1186 	 * letter and can be followed by letters, numbers and any of "/-_.:".
1187 	 *
1188 	 * Params:
1189 	 *     name = the new name of the structure
1190 	 */
1191 	public void setName(string name)
1192 	{
1193 		gst_structure_set_name(gstStructure, Str.toStringz(name));
1194 	}
1195 
1196 	/**
1197 	 * Sets the parent_refcount field of #GstStructure. This field is used to
1198 	 * determine whether a structure is mutable or not. This function should only be
1199 	 * called by code implementing parent objects of #GstStructure, as described in
1200 	 * the MT Refcounting section of the design documents.
1201 	 *
1202 	 * Params:
1203 	 *     refcount = a pointer to the parent's refcount
1204 	 *
1205 	 * Returns: %TRUE if the parent refcount could be set.
1206 	 */
1207 	public bool setParentRefcount(int* refcount)
1208 	{
1209 		return gst_structure_set_parent_refcount(gstStructure, refcount) != 0;
1210 	}
1211 
1212 	/**
1213 	 * va_list form of gst_structure_set().
1214 	 *
1215 	 * Params:
1216 	 *     fieldname = the name of the field to set
1217 	 *     varargs = variable arguments
1218 	 */
1219 	public void setValist(string fieldname, void* varargs)
1220 	{
1221 		gst_structure_set_valist(gstStructure, Str.toStringz(fieldname), varargs);
1222 	}
1223 
1224 	/**
1225 	 * Sets the field with the given name @field to @value.  If the field
1226 	 * does not exist, it is created.  If the field exists, the previous
1227 	 * value is replaced and freed.
1228 	 *
1229 	 * Params:
1230 	 *     fieldname = the name of the field to set
1231 	 *     value = the new value of the field
1232 	 */
1233 	public void setValue(string fieldname, Value value)
1234 	{
1235 		gst_structure_set_value(gstStructure, Str.toStringz(fieldname), (value is null) ? null : value.getValueStruct());
1236 	}
1237 
1238 	/**
1239 	 * Sets the field with the given name @field to @value.  If the field
1240 	 * does not exist, it is created.  If the field exists, the previous
1241 	 * value is replaced and freed. The function will take ownership of @value.
1242 	 *
1243 	 * Params:
1244 	 *     fieldname = the name of the field to set
1245 	 *     value = the new value of the field
1246 	 */
1247 	public void takeValue(string fieldname, Value value)
1248 	{
1249 		gst_structure_take_value(gstStructure, Str.toStringz(fieldname), (value is null) ? null : value.getValueStruct());
1250 	}
1251 
1252 	/**
1253 	 * Converts @structure to a human-readable string representation.
1254 	 *
1255 	 * For debugging purposes its easier to do something like this:
1256 	 * |[<!-- language="C" -->
1257 	 * GST_LOG ("structure is %" GST_PTR_FORMAT, structure);
1258 	 * ]|
1259 	 * This prints the structure in human readable form.
1260 	 *
1261 	 * The current implementation of serialization will lead to unexpected results
1262 	 * when there are nested #GstCaps / #GstStructure deeper than one level.
1263 	 *
1264 	 * Free-function: g_free
1265 	 *
1266 	 * Returns: a pointer to string allocated by g_malloc().
1267 	 *     g_free() after usage.
1268 	 */
1269 	public override string toString()
1270 	{
1271 		auto retStr = gst_structure_to_string(gstStructure);
1272 
1273 		scope(exit) Str.freeString(retStr);
1274 		return Str.toString(retStr);
1275 	}
1276 
1277 	/**
1278 	 * Atomically modifies a pointer to point to a new structure.
1279 	 * The #GstStructure @oldstr_ptr is pointing to is freed and
1280 	 * @newstr is taken ownership over.
1281 	 *
1282 	 * Either @newstr and the value pointed to by @oldstr_ptr may be %NULL.
1283 	 *
1284 	 * It is a programming error if both @newstr and the value pointed to by
1285 	 * @oldstr_ptr refer to the same, non-%NULL structure.
1286 	 *
1287 	 * Params:
1288 	 *     oldstrPtr = pointer to a place of
1289 	 *         a #GstStructure to take
1290 	 *     newstr = a new #GstStructure
1291 	 *
1292 	 * Returns: %TRUE if @newstr was different from @oldstr_ptr
1293 	 *
1294 	 * Since: 1.18
1295 	 */
1296 	public static bool take(ref Structure oldstrPtr, Structure newstr)
1297 	{
1298 		GstStructure* outoldstrPtr = oldstrPtr.getStructureStruct();
1299 
1300 		auto __p = gst_structure_take(&outoldstrPtr, (newstr is null) ? null : newstr.getStructureStruct(true)) != 0;
1301 
1302 		oldstrPtr = ObjectG.getDObject!(Structure)(outoldstrPtr);
1303 
1304 		return __p;
1305 	}
1306 }