Fix crash on startup if an LV2 plugin has a bad .ttl file.
[ardour.git] / libs / glibmm2 / glib / src / uriutils.hg
1 /* $Id: fileutils.hg,v 1.3 2004/01/22 18:38:12 murrayc Exp $ */
2
3 /* Copyright (C) 2002 The gtkmm Development Team
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 _DEFS(glibmm,glib)
21
22 #include <string>
23 #include <glibmmconfig.h>
24
25 GLIBMM_USING_STD(string)
26
27
28 namespace Glib
29 {
30
31 /** @defgroup UriUtils URI Utilities
32  * Various uri-related functions.
33  */
34
35 //Note that the illegal_characters and reserved_chars_allowed parameters are bytes and may not be UTF-8 
36 //so they are not Glib::ustring. See http://bugzilla.gnome.org/show_bug.cgi?id=508773
37
38 /** Unescapes a whole escaped string.
39  * If any of the characters in @a illegal_characters or the character zero appears
40  * as an escaped character in @a escaped_string then that is an error and an empty string 
41  * will be returned. This is useful it you want to avoid, for instance, having a
42  * slash being expanded in an escaped path element, which might confuse pathname
43  * handling.
44  *
45  * @param escaped_string An escaped string to be unescaped.
46  * @param illegal_characters An optional string of illegal characters not to be allowed.
47  * @result An unescaped version of @a escaped_string.
48  * 
49  * @ingroup UriUtils
50  * @newin2p16
51  */
52 std::string uri_unescape_string(const std::string& escaped_string, const std::string& illegal_characters = std::string());
53
54 //TODO: Use iterator? 
55 //char *   g_uri_unescape_segment      (const char *escaped_string,
56 //                                    const char *escaped_string_end,
57 //                                    const char *illegal_characters);
58
59 /** Gets the scheme portion of a URI. RFC 3986 decodes the scheme as:
60  * @code
61  * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] 
62  * @endcode
63  * Common schemes include "file", "http", "svn+ssh", etc.
64  *
65  * @param uri
66  * @result The "Scheme" component of the URI, or an empty string on error. 
67  * 
68  * @ingroup UriUtils
69  * @newin2p16
70  */
71 std::string uri_parse_scheme(const std::string& uri);
72
73 /** Escapes a string for use in a URI.
74  *
75  * Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical
76  * characters plus dash, dot, underscore and tilde) are escaped.
77  * But if you specify characters in @a reserved_chars_allowed they are not
78  * escaped. This is useful for the "reserved" characters in the URI
79  * specification, since those are allowed unescaped in some portions of
80  * a URI.
81  *
82  * @param unescaped The unescaped input string.
83  * @param reserved_chars_allowed A string of reserved characters that are allowed to be used.
84  * @param allow_utf8 true if the result can include UTF-8 characters.
85  * @result An escaped version of @a unescaped.
86  *
87  * @ingroup UriUtils
88  * @newin2p16
89  */
90 std::string uri_escape_string(const std::string& unescaped, const std::string& reserved_chars_allowed = std::string(), bool allow_utf8 = true);
91
92 } // namespace Glib
93