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