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