1 /* $Id: fileutils.hg,v 1.3 2004/01/22 18:38:12 murrayc Exp $ */
3 /* Copyright (C) 2002 The gtkmm Development Team
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.
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.
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.
23 #include <glibmmconfig.h>
25 GLIBMM_USING_STD(string)
31 /** @defgroup UriUtils URI Utilities
32 * Various uri-related functions.
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
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
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.
52 std::string uri_unescape_string(const std::string& escaped_string, const std::string& illegal_characters = std::string());
55 //char * g_uri_unescape_segment (const char *escaped_string,
56 // const char *escaped_string_end,
57 // const char *illegal_characters);
59 /** Gets the scheme portion of a URI. RFC 3986 decodes the scheme as:
61 * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
63 * Common schemes include "file", "http", "svn+ssh", etc.
66 * @result The "Scheme" component of the URI, or an empty string on error.
71 std::string uri_parse_scheme(const std::string& uri);
73 /** Escapes a string for use in a URI.
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
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.
90 std::string uri_escape_string(const std::string& unescaped, const std::string& reserved_chars_allowed = std::string(), bool allow_utf8 = true);