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