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 name.
770 	 */
771 	public Value getValue(string fieldname)
772 	{
773 		auto p = gst_structure_get_value(gstStructure, Str.toStringz(fieldname));
774 
775 		if(p is null)
776 		{
777 			return null;
778 		}
779 
780 		return ObjectG.getDObject!(Value)(cast(GValue*) p);
781 	}
782 
783 	/**
784 	 * Check if @structure contains a field named @fieldname.
785 	 *
786 	 * Params:
787 	 *     fieldname = the name of a field
788 	 *
789 	 * Returns: %TRUE if the structure contains a field with the given name
790 	 */
791 	public bool hasField(string fieldname)
792 	{
793 		return gst_structure_has_field(gstStructure, Str.toStringz(fieldname)) != 0;
794 	}
795 
796 	/**
797 	 * Check if @structure contains a field named @fieldname and with GType @type.
798 	 *
799 	 * Params:
800 	 *     fieldname = the name of a field
801 	 *     type = the type of a value
802 	 *
803 	 * Returns: %TRUE if the structure contains a field with the given name and type
804 	 */
805 	public bool hasFieldTyped(string fieldname, GType type)
806 	{
807 		return gst_structure_has_field_typed(gstStructure, Str.toStringz(fieldname), type) != 0;
808 	}
809 
810 	/**
811 	 * Checks if the structure has the given name
812 	 *
813 	 * Params:
814 	 *     name = structure name to check for
815 	 *
816 	 * Returns: %TRUE if @name matches the name of the structure.
817 	 */
818 	public bool hasName(string name)
819 	{
820 		return gst_structure_has_name(gstStructure, Str.toStringz(name)) != 0;
821 	}
822 
823 	/**
824 	 * Parses the variable arguments and reads fields from @structure accordingly.
825 	 * valist-variant of gst_structure_id_get(). Look at the documentation of
826 	 * gst_structure_id_get() for more details.
827 	 *
828 	 * Params:
829 	 *     firstFieldId = the quark of the first field to read
830 	 *     args = variable arguments
831 	 *
832 	 * Returns: %TRUE, or %FALSE if there was a problem reading any of the fields
833 	 */
834 	public bool idGetValist(GQuark firstFieldId, void* args)
835 	{
836 		return gst_structure_id_get_valist(gstStructure, firstFieldId, args) != 0;
837 	}
838 
839 	/**
840 	 * Get the value of the field with GQuark @field.
841 	 *
842 	 * Params:
843 	 *     field = the #GQuark of the field to get
844 	 *
845 	 * Returns: the #GValue corresponding to the field with the given name
846 	 *     identifier.
847 	 */
848 	public Value idGetValue(GQuark field)
849 	{
850 		auto p = gst_structure_id_get_value(gstStructure, field);
851 
852 		if(p is null)
853 		{
854 			return null;
855 		}
856 
857 		return ObjectG.getDObject!(Value)(cast(GValue*) p);
858 	}
859 
860 	/**
861 	 * Check if @structure contains a field named @field.
862 	 *
863 	 * Params:
864 	 *     field = #GQuark of the field name
865 	 *
866 	 * Returns: %TRUE if the structure contains a field with the given name
867 	 */
868 	public bool idHasField(GQuark field)
869 	{
870 		return gst_structure_id_has_field(gstStructure, field) != 0;
871 	}
872 
873 	/**
874 	 * Check if @structure contains a field named @field and with GType @type.
875 	 *
876 	 * Params:
877 	 *     field = #GQuark of the field name
878 	 *     type = the type of a value
879 	 *
880 	 * Returns: %TRUE if the structure contains a field with the given name and type
881 	 */
882 	public bool idHasFieldTyped(GQuark field, GType type)
883 	{
884 		return gst_structure_id_has_field_typed(gstStructure, field, type) != 0;
885 	}
886 
887 	/**
888 	 * va_list form of gst_structure_id_set().
889 	 *
890 	 * Params:
891 	 *     fieldname = the name of the field to set
892 	 *     varargs = variable arguments
893 	 */
894 	public void idSetValist(GQuark fieldname, void* varargs)
895 	{
896 		gst_structure_id_set_valist(gstStructure, fieldname, varargs);
897 	}
898 
899 	/**
900 	 * Sets the field with the given GQuark @field to @value.  If the field
901 	 * does not exist, it is created.  If the field exists, the previous
902 	 * value is replaced and freed.
903 	 *
904 	 * Params:
905 	 *     field = a #GQuark representing a field
906 	 *     value = the new value of the field
907 	 */
908 	public void idSetValue(GQuark field, Value value)
909 	{
910 		gst_structure_id_set_value(gstStructure, field, (value is null) ? null : value.getValueStruct());
911 	}
912 
913 	/**
914 	 * Sets the field with the given GQuark @field to @value.  If the field
915 	 * does not exist, it is created.  If the field exists, the previous
916 	 * value is replaced and freed.
917 	 *
918 	 * Params:
919 	 *     field = a #GQuark representing a field
920 	 *     value = the new value of the field
921 	 */
922 	public void idTakeValue(GQuark field, Value value)
923 	{
924 		gst_structure_id_take_value(gstStructure, field, (value is null) ? null : value.getValueStruct());
925 	}
926 
927 	/**
928 	 * Intersects @struct1 and @struct2 and returns the intersection.
929 	 *
930 	 * Params:
931 	 *     struct2 = a #GstStructure
932 	 *
933 	 * Returns: Intersection of @struct1 and @struct2
934 	 */
935 	public Structure intersect(Structure struct2)
936 	{
937 		auto p = gst_structure_intersect(gstStructure, (struct2 is null) ? null : struct2.getStructureStruct());
938 
939 		if(p is null)
940 		{
941 			return null;
942 		}
943 
944 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p, true);
945 	}
946 
947 	/**
948 	 * Tests if the two #GstStructure are equal.
949 	 *
950 	 * Params:
951 	 *     structure2 = a #GstStructure.
952 	 *
953 	 * Returns: %TRUE if the two structures have the same name and field.
954 	 */
955 	public bool isEqual(Structure structure2)
956 	{
957 		return gst_structure_is_equal(gstStructure, (structure2 is null) ? null : structure2.getStructureStruct()) != 0;
958 	}
959 
960 	/**
961 	 * Checks if @subset is a subset of @superset, i.e. has the same
962 	 * structure name and for all fields that are existing in @superset,
963 	 * @subset has a value that is a subset of the value in @superset.
964 	 *
965 	 * Params:
966 	 *     superset = a potentially greater #GstStructure
967 	 *
968 	 * Returns: %TRUE if @subset is a subset of @superset
969 	 */
970 	public bool isSubset(Structure superset)
971 	{
972 		return gst_structure_is_subset(gstStructure, (superset is null) ? null : superset.getStructureStruct()) != 0;
973 	}
974 
975 	/**
976 	 * Calls the provided function once for each field in the #GstStructure. In
977 	 * contrast to gst_structure_foreach(), the function may modify but not delete the
978 	 * fields. The structure must be mutable.
979 	 *
980 	 * Params:
981 	 *     func = a function to call for each field
982 	 *     userData = private data
983 	 *
984 	 * Returns: %TRUE if the supplied function returns %TRUE For each of the fields,
985 	 *     %FALSE otherwise.
986 	 */
987 	public bool mapInPlace(GstStructureMapFunc func, void* userData)
988 	{
989 		return gst_structure_map_in_place(gstStructure, func, userData) != 0;
990 	}
991 
992 	/**
993 	 * Get the number of fields in the structure.
994 	 *
995 	 * Returns: the number of fields in the structure
996 	 */
997 	public int nFields()
998 	{
999 		return gst_structure_n_fields(gstStructure);
1000 	}
1001 
1002 	/**
1003 	 * Get the name of the given field number, counting from 0 onwards.
1004 	 *
1005 	 * Params:
1006 	 *     index = the index to get the name of
1007 	 *
1008 	 * Returns: the name of the given field number
1009 	 */
1010 	public string nthFieldName(uint index)
1011 	{
1012 		return Str.toString(gst_structure_nth_field_name(gstStructure, index));
1013 	}
1014 
1015 	/**
1016 	 * Removes all fields in a GstStructure.
1017 	 */
1018 	public void removeAllFields()
1019 	{
1020 		gst_structure_remove_all_fields(gstStructure);
1021 	}
1022 
1023 	/**
1024 	 * Removes the field with the given name.  If the field with the given
1025 	 * name does not exist, the structure is unchanged.
1026 	 *
1027 	 * Params:
1028 	 *     fieldname = the name of the field to remove
1029 	 */
1030 	public void removeField(string fieldname)
1031 	{
1032 		gst_structure_remove_field(gstStructure, Str.toStringz(fieldname));
1033 	}
1034 
1035 	/**
1036 	 * va_list form of gst_structure_remove_fields().
1037 	 *
1038 	 * Params:
1039 	 *     fieldname = the name of the field to remove
1040 	 *     varargs = %NULL-terminated list of more fieldnames to remove
1041 	 */
1042 	public void removeFieldsValist(string fieldname, void* varargs)
1043 	{
1044 		gst_structure_remove_fields_valist(gstStructure, Str.toStringz(fieldname), varargs);
1045 	}
1046 
1047 	/**
1048 	 * This is useful in language bindings where unknown GValue types are not
1049 	 * supported. This function will convert a @array to %GST_TYPE_ARRAY and set
1050 	 * the field specified by @fieldname.  Be aware that this is slower then using
1051 	 * %GST_TYPE_ARRAY in a #GValue directly.
1052 	 *
1053 	 * Since 1.12
1054 	 *
1055 	 * Params:
1056 	 *     fieldname = the name of a field
1057 	 *     array = a pointer to a #GValueArray
1058 	 */
1059 	public void setArray(string fieldname, ValueArray array)
1060 	{
1061 		gst_structure_set_array(gstStructure, Str.toStringz(fieldname), (array is null) ? null : array.getValueArrayStruct());
1062 	}
1063 
1064 	/**
1065 	 * This is useful in language bindings where unknown GValue types are not
1066 	 * supported. This function will convert a @array to %GST_TYPE_ARRAY and set
1067 	 * the field specified by @fieldname. Be aware that this is slower then using
1068 	 * %GST_TYPE_ARRAY in a #GValue directly.
1069 	 *
1070 	 * Since 1.12
1071 	 *
1072 	 * Params:
1073 	 *     fieldname = the name of a field
1074 	 *     array = a pointer to a #GValueArray
1075 	 */
1076 	public void setList(string fieldname, ValueArray array)
1077 	{
1078 		gst_structure_set_list(gstStructure, Str.toStringz(fieldname), (array is null) ? null : array.getValueArrayStruct());
1079 	}
1080 
1081 	/**
1082 	 * Sets the name of the structure to the given @name.  The string
1083 	 * provided is copied before being used. It must not be empty, start with a
1084 	 * letter and can be followed by letters, numbers and any of "/-_.:".
1085 	 *
1086 	 * Params:
1087 	 *     name = the new name of the structure
1088 	 */
1089 	public void setName(string name)
1090 	{
1091 		gst_structure_set_name(gstStructure, Str.toStringz(name));
1092 	}
1093 
1094 	/**
1095 	 * Sets the parent_refcount field of #GstStructure. This field is used to
1096 	 * determine whether a structure is mutable or not. This function should only be
1097 	 * called by code implementing parent objects of #GstStructure, as described in
1098 	 * the MT Refcounting section of the design documents.
1099 	 *
1100 	 * Params:
1101 	 *     refcount = a pointer to the parent's refcount
1102 	 *
1103 	 * Returns: %TRUE if the parent refcount could be set.
1104 	 */
1105 	public bool setParentRefcount(int* refcount)
1106 	{
1107 		return gst_structure_set_parent_refcount(gstStructure, refcount) != 0;
1108 	}
1109 
1110 	/**
1111 	 * va_list form of gst_structure_set().
1112 	 *
1113 	 * Params:
1114 	 *     fieldname = the name of the field to set
1115 	 *     varargs = variable arguments
1116 	 */
1117 	public void setValist(string fieldname, void* varargs)
1118 	{
1119 		gst_structure_set_valist(gstStructure, Str.toStringz(fieldname), varargs);
1120 	}
1121 
1122 	/**
1123 	 * Sets the field with the given name @field to @value.  If the field
1124 	 * does not exist, it is created.  If the field exists, the previous
1125 	 * value is replaced and freed.
1126 	 *
1127 	 * Params:
1128 	 *     fieldname = the name of the field to set
1129 	 *     value = the new value of the field
1130 	 */
1131 	public void setValue(string fieldname, Value value)
1132 	{
1133 		gst_structure_set_value(gstStructure, Str.toStringz(fieldname), (value is null) ? null : value.getValueStruct());
1134 	}
1135 
1136 	/**
1137 	 * Sets the field with the given name @field to @value.  If the field
1138 	 * does not exist, it is created.  If the field exists, the previous
1139 	 * value is replaced and freed. The function will take ownership of @value.
1140 	 *
1141 	 * Params:
1142 	 *     fieldname = the name of the field to set
1143 	 *     value = the new value of the field
1144 	 */
1145 	public void takeValue(string fieldname, Value value)
1146 	{
1147 		gst_structure_take_value(gstStructure, Str.toStringz(fieldname), (value is null) ? null : value.getValueStruct());
1148 	}
1149 
1150 	/**
1151 	 * Converts @structure to a human-readable string representation.
1152 	 *
1153 	 * For debugging purposes its easier to do something like this:
1154 	 * |[<!-- language="C" -->
1155 	 * GST_LOG ("structure is %" GST_PTR_FORMAT, structure);
1156 	 * ]|
1157 	 * This prints the structure in human readable form.
1158 	 *
1159 	 * The current implementation of serialization will lead to unexpected results
1160 	 * when there are nested #GstCaps / #GstStructure deeper than one level.
1161 	 *
1162 	 * Free-function: g_free
1163 	 *
1164 	 * Returns: a pointer to string allocated by g_malloc().
1165 	 *     g_free() after usage.
1166 	 */
1167 	public override string toString()
1168 	{
1169 		auto retStr = gst_structure_to_string(gstStructure);
1170 
1171 		scope(exit) Str.freeString(retStr);
1172 		return Str.toString(retStr);
1173 	}
1174 
1175 	/**
1176 	 * Creates a #GstStructure from a string representation.
1177 	 * If end is not %NULL, a pointer to the place inside the given string
1178 	 * where parsing ended will be returned.
1179 	 *
1180 	 * Free-function: gst_structure_free
1181 	 *
1182 	 * Params:
1183 	 *     str = a string representation of a #GstStructure.
1184 	 *     end = pointer to store the end of the string in.
1185 	 *
1186 	 * Returns: a new #GstStructure or %NULL
1187 	 *     when the string could not be parsed. Free with
1188 	 *     gst_structure_free() after use.
1189 	 */
1190 	public static Structure fromString(string str, out string end)
1191 	{
1192 		char* outend = null;
1193 
1194 		auto p = gst_structure_from_string(Str.toStringz(str), &outend);
1195 
1196 		end = Str.toString(outend);
1197 
1198 		if(p is null)
1199 		{
1200 			return null;
1201 		}
1202 
1203 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p, true);
1204 	}
1205 }