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.Uri;
26 
27 private import glib.ConstructionException;
28 private import glib.ErrorG;
29 private import glib.GException;
30 private import glib.HashTable;
31 private import glib.ListG;
32 private import glib.Str;
33 private import gobject.ObjectG;
34 private import gstreamerc.gstreamer;
35 public  import gstreamerc.gstreamertypes;
36 
37 
38 /**
39  * A #GstUri object can be used to parse and split a URI string into its
40  * constituant parts. Two #GstUri objects can be joined to make a new #GstUri
41  * using the algorithm described in RFC3986.
42  */
43 public class Uri
44 {
45 	/** the main Gtk struct */
46 	protected GstUri* gstUri;
47 	protected bool ownedRef;
48 
49 	/** Get the main Gtk struct */
50 	public GstUri* getUriStruct()
51 	{
52 		return gstUri;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected void* getStruct()
57 	{
58 		return cast(void*)gstUri;
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (GstUri* gstUri, bool ownedRef = false)
65 	{
66 		this.gstUri = gstUri;
67 		this.ownedRef = ownedRef;
68 	}
69 
70 
71 	/** */
72 	public static GType getType()
73 	{
74 		return gst_uri_get_type();
75 	}
76 
77 	/**
78 	 * Creates a new #GstUri object with the given URI parts. The path and query
79 	 * strings will be broken down into their elements. All strings should not be
80 	 * escaped except where indicated.
81 	 *
82 	 * Params:
83 	 *     scheme = The scheme for the new URI.
84 	 *     userinfo = The user-info for the new URI.
85 	 *     host = The host name for the new URI.
86 	 *     port = The port number for the new URI or %GST_URI_NO_PORT.
87 	 *     path = The path for the new URI with '/' separating path
88 	 *         elements.
89 	 *     query = The query string for the new URI with '&' separating
90 	 *         query elements. Elements containing '&' characters
91 	 *         should encode them as "%26".
92 	 *     fragment = The fragment name for the new URI.
93 	 *
94 	 * Returns: A new #GstUri object.
95 	 *
96 	 * Since: 1.6
97 	 *
98 	 * Throws: ConstructionException GTK+ fails to create the object.
99 	 */
100 	public this(string scheme, string userinfo, string host, uint port, string path, string query, string fragment)
101 	{
102 		auto p = gst_uri_new(Str.toStringz(scheme), Str.toStringz(userinfo), Str.toStringz(host), port, Str.toStringz(path), Str.toStringz(query), Str.toStringz(fragment));
103 		
104 		if(p is null)
105 		{
106 			throw new ConstructionException("null returned by new");
107 		}
108 		
109 		this(cast(GstUri*) p);
110 	}
111 
112 	/**
113 	 * Append a path onto the end of the path in the URI. The path is not
114 	 * normalized, call #gst_uri_normalize() to normalize the path.
115 	 *
116 	 * Params:
117 	 *     relativePath = Relative path to append to the end of the current path.
118 	 *
119 	 * Returns: %TRUE if the path was appended successfully.
120 	 *
121 	 * Since: 1.6
122 	 */
123 	public bool appendPath(string relativePath)
124 	{
125 		return gst_uri_append_path(gstUri, Str.toStringz(relativePath)) != 0;
126 	}
127 
128 	/**
129 	 * Append a single path segment onto the end of the URI path.
130 	 *
131 	 * Params:
132 	 *     pathSegment = The path segment string to append to the URI path.
133 	 *
134 	 * Returns: %TRUE if the path was appended successfully.
135 	 *
136 	 * Since: 1.6
137 	 */
138 	public bool appendPathSegment(string pathSegment)
139 	{
140 		return gst_uri_append_path_segment(gstUri, Str.toStringz(pathSegment)) != 0;
141 	}
142 
143 	/**
144 	 * Compares two #GstUri objects to see if they represent the same normalized
145 	 * URI.
146 	 *
147 	 * Params:
148 	 *     second = Second #GstUri to compare.
149 	 *
150 	 * Returns: %TRUE if the normalized versions of the two URI's would be equal.
151 	 *
152 	 * Since: 1.6
153 	 */
154 	public bool equal(Uri second)
155 	{
156 		return gst_uri_equal(gstUri, (second is null) ? null : second.getUriStruct()) != 0;
157 	}
158 
159 	/**
160 	 * Like gst_uri_from_string() but also joins with a base URI.
161 	 *
162 	 * Params:
163 	 *     uri = The URI string to parse.
164 	 *
165 	 * Returns: A new #GstUri object.
166 	 *
167 	 * Since: 1.6
168 	 */
169 	public Uri fromStringWithBase(string uri)
170 	{
171 		auto p = gst_uri_from_string_with_base(gstUri, Str.toStringz(uri));
172 		
173 		if(p is null)
174 		{
175 			return null;
176 		}
177 		
178 		return ObjectG.getDObject!(Uri)(cast(GstUri*) p, true);
179 	}
180 
181 	/**
182 	 * Get the fragment name from the URI or %NULL if it doesn't exist.
183 	 * If @uri is %NULL then returns %NULL.
184 	 *
185 	 * Returns: The host name from the #GstUri object or %NULL.
186 	 *
187 	 * Since: 1.6
188 	 */
189 	public string getFragment()
190 	{
191 		return Str.toString(gst_uri_get_fragment(gstUri));
192 	}
193 
194 	/**
195 	 * Get the host name from the URI or %NULL if it doesn't exist.
196 	 * If @uri is %NULL then returns %NULL.
197 	 *
198 	 * Returns: The host name from the #GstUri object or %NULL.
199 	 *
200 	 * Since: 1.6
201 	 */
202 	public string getHost()
203 	{
204 		return Str.toString(gst_uri_get_host(gstUri));
205 	}
206 
207 	/**
208 	 * Get the media fragment table from the URI, as defined by "Media Fragments URI 1.0".
209 	 * Hash table returned by this API is a list of "key-value" pairs, and the each
210 	 * pair is generated by splitting "URI fragment" per "&" sub-delims, then "key"
211 	 * and "value" are splitted by "=" sub-delims. The "key" returned by this API may
212 	 * be undefined keyword by standard.
213 	 * A value may be %NULL to indicate that the key should appear in the fragment
214 	 * string in the URI, but does not have a value. Free the returned #GHashTable
215 	 * with #g_hash_table_unref() when it is no longer required.
216 	 * Modifying this hash table does not affect the fragment in the URI.
217 	 *
218 	 * See more about Media Fragments URI 1.0 (W3C) at https://www.w3.org/TR/media-frags/
219 	 *
220 	 * Returns: The fragment hash table
221 	 *     from the URI.
222 	 *
223 	 * Since: 1.12
224 	 */
225 	public HashTable getMediaFragmentTable()
226 	{
227 		auto p = gst_uri_get_media_fragment_table(gstUri);
228 		
229 		if(p is null)
230 		{
231 			return null;
232 		}
233 		
234 		return new HashTable(cast(GHashTable*) p, true);
235 	}
236 
237 	/**
238 	 * Extract the path string from the URI object.
239 	 *
240 	 * Returns: The path from the URI. Once finished with the
241 	 *     string should be g_free()'d.
242 	 *
243 	 * Since: 1.6
244 	 */
245 	public string getPath()
246 	{
247 		auto retStr = gst_uri_get_path(gstUri);
248 		
249 		scope(exit) Str.freeString(retStr);
250 		return Str.toString(retStr);
251 	}
252 
253 	/**
254 	 * Get a list of path segments from the URI.
255 	 *
256 	 * Returns: A #GList of path segment
257 	 *     strings or %NULL if no path segments are available. Free the list
258 	 *     when no longer needed with g_list_free_full(list, g_free).
259 	 *
260 	 * Since: 1.6
261 	 */
262 	public ListG getPathSegments()
263 	{
264 		auto p = gst_uri_get_path_segments(gstUri);
265 		
266 		if(p is null)
267 		{
268 			return null;
269 		}
270 		
271 		return new ListG(cast(GList*) p, true);
272 	}
273 
274 	/**
275 	 * Extract the path string from the URI object as a percent encoded URI path.
276 	 *
277 	 * Returns: The path from the URI. Once finished with the
278 	 *     string should be g_free()'d.
279 	 *
280 	 * Since: 1.6
281 	 */
282 	public string getPathString()
283 	{
284 		auto retStr = gst_uri_get_path_string(gstUri);
285 		
286 		scope(exit) Str.freeString(retStr);
287 		return Str.toString(retStr);
288 	}
289 
290 	/**
291 	 * Get the port number from the URI or %GST_URI_NO_PORT if it doesn't exist.
292 	 * If @uri is %NULL then returns %GST_URI_NO_PORT.
293 	 *
294 	 * Returns: The port number from the #GstUri object or %GST_URI_NO_PORT.
295 	 *
296 	 * Since: 1.6
297 	 */
298 	public uint getPort()
299 	{
300 		return gst_uri_get_port(gstUri);
301 	}
302 
303 	/**
304 	 * Get a list of the query keys from the URI.
305 	 *
306 	 * Returns: A list of keys from
307 	 *     the URI query. Free the list with g_list_free().
308 	 *
309 	 * Since: 1.6
310 	 */
311 	public ListG getQueryKeys()
312 	{
313 		auto p = gst_uri_get_query_keys(gstUri);
314 		
315 		if(p is null)
316 		{
317 			return null;
318 		}
319 		
320 		return new ListG(cast(GList*) p);
321 	}
322 
323 	/**
324 	 * Get a percent encoded URI query string from the @uri.
325 	 *
326 	 * Returns: A percent encoded query string. Use g_free() when
327 	 *     no longer needed.
328 	 *
329 	 * Since: 1.6
330 	 */
331 	public string getQueryString()
332 	{
333 		auto retStr = gst_uri_get_query_string(gstUri);
334 		
335 		scope(exit) Str.freeString(retStr);
336 		return Str.toString(retStr);
337 	}
338 
339 	/**
340 	 * Get the query table from the URI. Keys and values in the table are freed
341 	 * with g_free when they are deleted. A value may be %NULL to indicate that
342 	 * the key should appear in the query string in the URI, but does not have a
343 	 * value. Free the returned #GHashTable with #g_hash_table_unref() when it is
344 	 * no longer required. Modifying this hash table will modify the query in the
345 	 * URI.
346 	 *
347 	 * Returns: The query hash table
348 	 *     from the URI.
349 	 *
350 	 * Since: 1.6
351 	 */
352 	public HashTable getQueryTable()
353 	{
354 		auto p = gst_uri_get_query_table(gstUri);
355 		
356 		if(p is null)
357 		{
358 			return null;
359 		}
360 		
361 		return new HashTable(cast(GHashTable*) p, true);
362 	}
363 
364 	/**
365 	 * Get the value associated with the @query_key key. Will return %NULL if the
366 	 * key has no value or if the key does not exist in the URI query table. Because
367 	 * %NULL is returned for both missing keys and keys with no value, you should
368 	 * use gst_uri_query_has_key() to determine if a key is present in the URI
369 	 * query.
370 	 *
371 	 * Params:
372 	 *     queryKey = The key to lookup.
373 	 *
374 	 * Returns: The value for the given key, or %NULL if not found.
375 	 *
376 	 * Since: 1.6
377 	 */
378 	public string getQueryValue(string queryKey)
379 	{
380 		return Str.toString(gst_uri_get_query_value(gstUri, Str.toStringz(queryKey)));
381 	}
382 
383 	/**
384 	 * Get the scheme name from the URI or %NULL if it doesn't exist.
385 	 * If @uri is %NULL then returns %NULL.
386 	 *
387 	 * Returns: The scheme from the #GstUri object or %NULL.
388 	 */
389 	public string getScheme()
390 	{
391 		return Str.toString(gst_uri_get_scheme(gstUri));
392 	}
393 
394 	/**
395 	 * Get the userinfo (usually in the form "username:password") from the URI
396 	 * or %NULL if it doesn't exist. If @uri is %NULL then returns %NULL.
397 	 *
398 	 * Returns: The userinfo from the #GstUri object or %NULL.
399 	 *
400 	 * Since: 1.6
401 	 */
402 	public string getUserinfo()
403 	{
404 		return Str.toString(gst_uri_get_userinfo(gstUri));
405 	}
406 
407 	/**
408 	 * Tests the @uri to see if it is normalized. A %NULL @uri is considered to be
409 	 * normalized.
410 	 *
411 	 * Returns: TRUE if the URI is normalized or is %NULL.
412 	 *
413 	 * Since: 1.6
414 	 */
415 	public bool isNormalized()
416 	{
417 		return gst_uri_is_normalized(gstUri) != 0;
418 	}
419 
420 	/**
421 	 * Check if it is safe to write to this #GstUri.
422 	 *
423 	 * Check if the refcount of @uri is exactly 1, meaning that no other
424 	 * reference exists to the #GstUri and that the #GstUri is therefore writable.
425 	 *
426 	 * Modification of a #GstUri should only be done after verifying that it is
427 	 * writable.
428 	 *
429 	 * Returns: %TRUE if it is safe to write to the object.
430 	 *
431 	 * Since: 1.6
432 	 */
433 	public bool isWritable()
434 	{
435 		return gst_uri_is_writable(gstUri) != 0;
436 	}
437 
438 	/**
439 	 * Join a reference URI onto a base URI using the method from RFC 3986.
440 	 * If either URI is %NULL then the other URI will be returned with the ref count
441 	 * increased.
442 	 *
443 	 * Params:
444 	 *     refUri = The reference URI to join onto the
445 	 *         base URI.
446 	 *
447 	 * Returns: A #GstUri which represents the base with the
448 	 *     reference URI joined on.
449 	 *
450 	 * Since: 1.6
451 	 */
452 	public Uri join(Uri refUri)
453 	{
454 		auto p = gst_uri_join(gstUri, (refUri is null) ? null : refUri.getUriStruct());
455 		
456 		if(p is null)
457 		{
458 			return null;
459 		}
460 		
461 		return ObjectG.getDObject!(Uri)(cast(GstUri*) p, true);
462 	}
463 
464 	/**
465 	 * Make the #GstUri writable.
466 	 *
467 	 * Checks if @uri is writable, and if so the original object is returned. If
468 	 * not, then a writable copy is made and returned. This gives away the
469 	 * reference to @uri and returns a reference to the new #GstUri.
470 	 * If @uri is %NULL then %NULL is returned.
471 	 *
472 	 * Returns: A writable version of @uri.
473 	 *
474 	 * Since: 1.6
475 	 */
476 	public Uri makeWritable()
477 	{
478 		auto p = gst_uri_make_writable(gstUri);
479 		
480 		if(p is null)
481 		{
482 			return null;
483 		}
484 		
485 		return ObjectG.getDObject!(Uri)(cast(GstUri*) p, true);
486 	}
487 
488 	/**
489 	 * Like gst_uri_new(), but joins the new URI onto a base URI.
490 	 *
491 	 * Params:
492 	 *     scheme = The scheme for the new URI.
493 	 *     userinfo = The user-info for the new URI.
494 	 *     host = The host name for the new URI.
495 	 *     port = The port number for the new URI or %GST_URI_NO_PORT.
496 	 *     path = The path for the new URI with '/' separating path
497 	 *         elements.
498 	 *     query = The query string for the new URI with '&' separating
499 	 *         query elements. Elements containing '&' characters
500 	 *         should encode them as "%26".
501 	 *     fragment = The fragment name for the new URI.
502 	 *
503 	 * Returns: The new URI joined onto @base.
504 	 *
505 	 * Since: 1.6
506 	 */
507 	public Uri newWithBase(string scheme, string userinfo, string host, uint port, string path, string query, string fragment)
508 	{
509 		auto p = gst_uri_new_with_base(gstUri, Str.toStringz(scheme), Str.toStringz(userinfo), Str.toStringz(host), port, Str.toStringz(path), Str.toStringz(query), Str.toStringz(fragment));
510 		
511 		if(p is null)
512 		{
513 			return null;
514 		}
515 		
516 		return ObjectG.getDObject!(Uri)(cast(GstUri*) p, true);
517 	}
518 
519 	/**
520 	 * Normalization will remove extra path segments ("." and "..") from the URI. It
521 	 * will also convert the scheme and host name to lower case and any
522 	 * percent-encoded values to uppercase.
523 	 *
524 	 * The #GstUri object must be writable. Check with gst_uri_is_writable() or use
525 	 * gst_uri_make_writable() first.
526 	 *
527 	 * Returns: TRUE if the URI was modified.
528 	 *
529 	 * Since: 1.6
530 	 */
531 	public bool normalize()
532 	{
533 		return gst_uri_normalize(gstUri) != 0;
534 	}
535 
536 	/**
537 	 * Check if there is a query table entry for the @query_key key.
538 	 *
539 	 * Params:
540 	 *     queryKey = The key to lookup.
541 	 *
542 	 * Returns: %TRUE if @query_key exists in the URI query table.
543 	 *
544 	 * Since: 1.6
545 	 */
546 	public bool queryHasKey(string queryKey)
547 	{
548 		return gst_uri_query_has_key(gstUri, Str.toStringz(queryKey)) != 0;
549 	}
550 
551 	/**
552 	 * Remove an entry from the query table by key.
553 	 *
554 	 * Params:
555 	 *     queryKey = The key to remove.
556 	 *
557 	 * Returns: %TRUE if the key existed in the table and was removed.
558 	 *
559 	 * Since: 1.6
560 	 */
561 	public bool removeQueryKey(string queryKey)
562 	{
563 		return gst_uri_remove_query_key(gstUri, Str.toStringz(queryKey)) != 0;
564 	}
565 
566 	/**
567 	 * Sets the fragment string in the URI. Use a value of %NULL in @fragment to
568 	 * unset the fragment string.
569 	 *
570 	 * Params:
571 	 *     fragment = The fragment string to set.
572 	 *
573 	 * Returns: %TRUE if the fragment was set/unset successfully.
574 	 *
575 	 * Since: 1.6
576 	 */
577 	public bool setFragment(string fragment)
578 	{
579 		return gst_uri_set_fragment(gstUri, Str.toStringz(fragment)) != 0;
580 	}
581 
582 	/**
583 	 * Set or unset the host for the URI.
584 	 *
585 	 * Params:
586 	 *     host = The new host string to set or %NULL to unset.
587 	 *
588 	 * Returns: %TRUE if the host was set/unset successfully.
589 	 *
590 	 * Since: 1.6
591 	 */
592 	public bool setHost(string host)
593 	{
594 		return gst_uri_set_host(gstUri, Str.toStringz(host)) != 0;
595 	}
596 
597 	/**
598 	 * Sets or unsets the path in the URI.
599 	 *
600 	 * Params:
601 	 *     path = The new path to set with path segments separated by '/', or use %NULL
602 	 *         to unset the path.
603 	 *
604 	 * Returns: %TRUE if the path was set successfully.
605 	 *
606 	 * Since: 1.6
607 	 */
608 	public bool setPath(string path)
609 	{
610 		return gst_uri_set_path(gstUri, Str.toStringz(path)) != 0;
611 	}
612 
613 	/**
614 	 * Replace the path segments list in the URI.
615 	 *
616 	 * Params:
617 	 *     pathSegments = The new
618 	 *         path list to set.
619 	 *
620 	 * Returns: %TRUE if the path segments were set successfully.
621 	 *
622 	 * Since: 1.6
623 	 */
624 	public bool setPathSegments(ListG pathSegments)
625 	{
626 		return gst_uri_set_path_segments(gstUri, (pathSegments is null) ? null : pathSegments.getListGStruct()) != 0;
627 	}
628 
629 	/**
630 	 * Sets or unsets the path in the URI.
631 	 *
632 	 * Params:
633 	 *     path = The new percent encoded path to set with path segments separated by
634 	 *         '/', or use %NULL to unset the path.
635 	 *
636 	 * Returns: %TRUE if the path was set successfully.
637 	 *
638 	 * Since: 1.6
639 	 */
640 	public bool setPathString(string path)
641 	{
642 		return gst_uri_set_path_string(gstUri, Str.toStringz(path)) != 0;
643 	}
644 
645 	/**
646 	 * Set or unset the port number for the URI.
647 	 *
648 	 * Params:
649 	 *     port = The new port number to set or %GST_URI_NO_PORT to unset.
650 	 *
651 	 * Returns: %TRUE if the port number was set/unset successfully.
652 	 *
653 	 * Since: 1.6
654 	 */
655 	public bool setPort(uint port)
656 	{
657 		return gst_uri_set_port(gstUri, port) != 0;
658 	}
659 
660 	/**
661 	 * Sets or unsets the query table in the URI.
662 	 *
663 	 * Params:
664 	 *     query = The new percent encoded query string to use to populate the query
665 	 *         table, or use %NULL to unset the query table.
666 	 *
667 	 * Returns: %TRUE if the query table was set successfully.
668 	 *
669 	 * Since: 1.6
670 	 */
671 	public bool setQueryString(string query)
672 	{
673 		return gst_uri_set_query_string(gstUri, Str.toStringz(query)) != 0;
674 	}
675 
676 	/**
677 	 * Set the query table to use in the URI. The old table is unreferenced and a
678 	 * reference to the new one is used instead. A value if %NULL for @query_table
679 	 * will remove the query string from the URI.
680 	 *
681 	 * Params:
682 	 *     queryTable = The new
683 	 *         query table to use.
684 	 *
685 	 * Returns: %TRUE if the new table was sucessfully used for the query table.
686 	 *
687 	 * Since: 1.6
688 	 */
689 	public bool setQueryTable(HashTable queryTable)
690 	{
691 		return gst_uri_set_query_table(gstUri, (queryTable is null) ? null : queryTable.getHashTableStruct()) != 0;
692 	}
693 
694 	/**
695 	 * This inserts or replaces a key in the query table. A @query_value of %NULL
696 	 * indicates that the key has no associated value, but will still be present in
697 	 * the query string.
698 	 *
699 	 * Params:
700 	 *     queryKey = The key for the query entry.
701 	 *     queryValue = The value for the key.
702 	 *
703 	 * Returns: %TRUE if the query table was sucessfully updated.
704 	 *
705 	 * Since: 1.6
706 	 */
707 	public bool setQueryValue(string queryKey, string queryValue)
708 	{
709 		return gst_uri_set_query_value(gstUri, Str.toStringz(queryKey), Str.toStringz(queryValue)) != 0;
710 	}
711 
712 	/**
713 	 * Set or unset the scheme for the URI.
714 	 *
715 	 * Params:
716 	 *     scheme = The new scheme to set or %NULL to unset the scheme.
717 	 *
718 	 * Returns: %TRUE if the scheme was set/unset successfully.
719 	 *
720 	 * Since: 1.6
721 	 */
722 	public bool setScheme(string scheme)
723 	{
724 		return gst_uri_set_scheme(gstUri, Str.toStringz(scheme)) != 0;
725 	}
726 
727 	/**
728 	 * Set or unset the user information for the URI.
729 	 *
730 	 * Params:
731 	 *     userinfo = The new user-information string to set or %NULL to unset.
732 	 *
733 	 * Returns: %TRUE if the user information was set/unset successfully.
734 	 *
735 	 * Since: 1.6
736 	 */
737 	public bool setUserinfo(string userinfo)
738 	{
739 		return gst_uri_set_userinfo(gstUri, Str.toStringz(userinfo)) != 0;
740 	}
741 
742 	/**
743 	 * Convert the URI to a string.
744 	 *
745 	 * Returns the URI as held in this object as a #gchar* nul-terminated string.
746 	 * The caller should g_free() the string once they are finished with it.
747 	 * The string is put together as described in RFC 3986.
748 	 *
749 	 * Returns: The string version of the URI.
750 	 *
751 	 * Since: 1.6
752 	 */
753 	public override string toString()
754 	{
755 		auto retStr = gst_uri_to_string(gstUri);
756 		
757 		scope(exit) Str.freeString(retStr);
758 		return Str.toString(retStr);
759 	}
760 
761 	/**
762 	 * Constructs a URI for a given valid protocol and location.
763 	 *
764 	 * Free-function: g_free
765 	 *
766 	 * Params:
767 	 *     protocol = Protocol for URI
768 	 *     location = Location for URI
769 	 *
770 	 * Returns: a new string for this URI. Returns %NULL if the
771 	 *     given URI protocol is not valid, or the given location is %NULL.
772 	 */
773 	public static string construct(string protocol, string location)
774 	{
775 		auto retStr = gst_uri_construct(Str.toStringz(protocol), Str.toStringz(location));
776 		
777 		scope(exit) Str.freeString(retStr);
778 		return Str.toString(retStr);
779 	}
780 
781 	/**
782 	 * Parses a URI string into a new #GstUri object. Will return NULL if the URI
783 	 * cannot be parsed.
784 	 *
785 	 * Params:
786 	 *     uri = The URI string to parse.
787 	 *
788 	 * Returns: A new #GstUri object, or NULL.
789 	 *
790 	 * Since: 1.6
791 	 */
792 	public static Uri fromString(string uri)
793 	{
794 		auto p = gst_uri_from_string(Str.toStringz(uri));
795 		
796 		if(p is null)
797 		{
798 			return null;
799 		}
800 		
801 		return ObjectG.getDObject!(Uri)(cast(GstUri*) p, true);
802 	}
803 
804 	/**
805 	 * Extracts the location out of a given valid URI, ie. the protocol and "://"
806 	 * are stripped from the URI, which means that the location returned includes
807 	 * the hostname if one is specified. The returned string must be freed using
808 	 * g_free().
809 	 *
810 	 * Free-function: g_free
811 	 *
812 	 * Params:
813 	 *     uri = A URI string
814 	 *
815 	 * Returns: the location for this URI. Returns %NULL if the
816 	 *     URI isn't valid. If the URI does not contain a location, an empty
817 	 *     string is returned.
818 	 */
819 	public static string getLocation(string uri)
820 	{
821 		auto retStr = gst_uri_get_location(Str.toStringz(uri));
822 		
823 		scope(exit) Str.freeString(retStr);
824 		return Str.toString(retStr);
825 	}
826 
827 	/**
828 	 * Extracts the protocol out of a given valid URI. The returned string must be
829 	 * freed using g_free().
830 	 *
831 	 * Params:
832 	 *     uri = A URI string
833 	 *
834 	 * Returns: The protocol for this URI.
835 	 */
836 	public static string getProtocol(string uri)
837 	{
838 		auto retStr = gst_uri_get_protocol(Str.toStringz(uri));
839 		
840 		scope(exit) Str.freeString(retStr);
841 		return Str.toString(retStr);
842 	}
843 
844 	/**
845 	 * Checks if the protocol of a given valid URI matches @protocol.
846 	 *
847 	 * Params:
848 	 *     uri = a URI string
849 	 *     protocol = a protocol string (e.g. "http")
850 	 *
851 	 * Returns: %TRUE if the protocol matches.
852 	 */
853 	public static bool hasProtocol(string uri, string protocol)
854 	{
855 		return gst_uri_has_protocol(Str.toStringz(uri), Str.toStringz(protocol)) != 0;
856 	}
857 
858 	/**
859 	 * Tests if the given string is a valid URI identifier. URIs start with a valid
860 	 * scheme followed by ":" and maybe a string identifying the location.
861 	 *
862 	 * Params:
863 	 *     uri = A URI string
864 	 *
865 	 * Returns: %TRUE if the string is a valid URI
866 	 */
867 	public static bool isValid(string uri)
868 	{
869 		return gst_uri_is_valid(Str.toStringz(uri)) != 0;
870 	}
871 
872 	/**
873 	 * This is a convenience function to join two URI strings and return the result.
874 	 * The returned string should be g_free()'d after use.
875 	 *
876 	 * Params:
877 	 *     baseUri = The percent-encoded base URI.
878 	 *     refUri = The percent-encoded reference URI to join to the @base_uri.
879 	 *
880 	 * Returns: A string representing the percent-encoded join of
881 	 *     the two URIs.
882 	 *
883 	 * Since: 1.6
884 	 */
885 	public static string joinStrings(string baseUri, string refUri)
886 	{
887 		auto retStr = gst_uri_join_strings(Str.toStringz(baseUri), Str.toStringz(refUri));
888 		
889 		scope(exit) Str.freeString(retStr);
890 		return Str.toString(retStr);
891 	}
892 
893 	/**
894 	 * Checks if an element exists that supports the given URI protocol. Note
895 	 * that a positive return value does not imply that a subsequent call to
896 	 * gst_element_make_from_uri() is guaranteed to work.
897 	 *
898 	 * Params:
899 	 *     type = Whether to check for a source or a sink
900 	 *     protocol = Protocol that should be checked for (e.g. "http" or "smb")
901 	 *
902 	 * Returns: %TRUE
903 	 */
904 	public static bool protocolIsSupported(GstURIType type, string protocol)
905 	{
906 		return gst_uri_protocol_is_supported(type, Str.toStringz(protocol)) != 0;
907 	}
908 
909 	/**
910 	 * Tests if the given string is a valid protocol identifier. Protocols
911 	 * must consist of alphanumeric characters, '+', '-' and '.' and must
912 	 * start with a alphabetic character. See RFC 3986 Section 3.1.
913 	 *
914 	 * Params:
915 	 *     protocol = A string
916 	 *
917 	 * Returns: %TRUE if the string is a valid protocol identifier, %FALSE otherwise.
918 	 */
919 	public static bool protocolIsValid(string protocol)
920 	{
921 		return gst_uri_protocol_is_valid(Str.toStringz(protocol)) != 0;
922 	}
923 
924 	/**
925 	 * Similar to g_filename_to_uri(), but attempts to handle relative file paths
926 	 * as well. Before converting @filename into an URI, it will be prefixed by
927 	 * the current working directory if it is a relative path, and then the path
928 	 * will be canonicalised so that it doesn't contain any './' or '../' segments.
929 	 *
930 	 * On Windows #filename should be in UTF-8 encoding.
931 	 *
932 	 * Params:
933 	 *     filename = absolute or relative file name path
934 	 *
935 	 * Returns: newly-allocated URI string, or NULL on error. The caller must
936 	 *     free the URI string with g_free() when no longer needed.
937 	 *
938 	 * Throws: GException on failure.
939 	 */
940 	public static string filenameToUri(string filename)
941 	{
942 		GError* err = null;
943 		
944 		auto retStr = gst_filename_to_uri(Str.toStringz(filename), &err);
945 		
946 		if (err !is null)
947 		{
948 			throw new GException( new ErrorG(err) );
949 		}
950 		
951 		scope(exit) Str.freeString(retStr);
952 		return Str.toString(retStr);
953 	}
954 
955 	/** */
956 	public static GQuark uriErrorQuark()
957 	{
958 		return gst_uri_error_quark();
959 	}
960 }