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