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