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