Top | ![]() |
![]() |
![]() |
![]() |
IdeUri * | ide_uri_new () |
IdeUri * | ide_uri_new_relative () |
IdeUri * | ide_uri_new_from_file () |
char * | ide_uri_to_string () |
IdeUri * | ide_uri_copy () |
IdeUri * | ide_uri_ref () |
void | ide_uri_unref () |
const gchar * | ide_uri_get_scheme () |
void | ide_uri_set_scheme () |
const gchar * | ide_uri_get_user () |
void | ide_uri_set_user () |
const gchar * | ide_uri_get_password () |
void | ide_uri_set_password () |
const gchar * | ide_uri_get_auth_params () |
void | ide_uri_set_auth_params () |
const gchar * | ide_uri_get_host () |
void | ide_uri_set_host () |
gushort | ide_uri_get_port () |
void | ide_uri_set_port () |
const gchar * | ide_uri_get_path () |
void | ide_uri_set_path () |
const gchar * | ide_uri_get_query () |
void | ide_uri_set_query () |
const gchar * | ide_uri_get_fragment () |
void | ide_uri_set_fragment () |
void | ide_uri_split () |
GHashTable * | ide_uri_parse_params () |
gboolean | ide_uri_parse_host () |
gchar * | ide_uri_build () |
gboolean | ide_uri_is_file () |
GFile * | ide_uri_to_file () |
GQuark | ide_uri_error_quark () |
enum | IdeUriParseFlags |
enum | IdeUriToStringFlags |
#define | IDE_URI_ERROR |
enum | IdeUriError |
IdeUri * ide_uri_new (const gchar *uri_string
,IdeUriParseFlags flags
,GError **error
);
Parses uri_string
according to flags
. If the result is not a
valid absolute URI, it will be discarded, and an error returned.
IdeUri * ide_uri_new_relative (IdeUri *base_uri
,const gchar *uri_string
,IdeUriParseFlags flags
,GError **error
);
Parses uri_string
according to flags
and, if it is a relative
URI, merges it with base_uri
. If the result is not a valid
absolute URI, it will be discarded, and an error returned.
IdeUri *
ide_uri_new_from_file (GFile *file
);
Creates a new IdeUri from the uri provided by file
.
char * ide_uri_to_string (IdeUri *uri
,IdeUriToStringFlags flags
);
Returns a string representing uri
.
void
ide_uri_unref (IdeUri *uri
);
Decrements the reference count of uri
by 1. If the reference count
reaches zero, the structure will be freed.
void ide_uri_set_scheme (IdeUri *uri
,const gchar *scheme
);
Sets uri
's scheme to scheme
.
const gchar *
ide_uri_get_user (IdeUri *uri
);
Gets uri
's user. If uri
was parsed with IDE_URI_PARSE_PASSWORD
or
IDE_URI_PARSE_AUTH_PARAMS
, this is the string that appears before the
password and parameters in the userinfo. If not, then the entire
userinfo is considered the user.
void ide_uri_set_user (IdeUri *uri
,const gchar *user
);
Sets uri
's user to user
. See ide_uri_get_user()
for a description
of how this interacts with various parsing flags.
const gchar *
ide_uri_get_password (IdeUri *uri
);
Gets uri
's password. If uri
was not parsed with
IDE_URI_PARSE_PASSWORD
, this will always be NULL
.
void ide_uri_set_password (IdeUri *uri
,const gchar *password
);
Sets uri
's password to password
.
const gchar *
ide_uri_get_auth_params (IdeUri *uri
);
Gets uri
's authentication parameters. Depending on the URI scheme,
ide_uri_parse_params()
may be useful for further parsing this
information.
void ide_uri_set_auth_params (IdeUri *uri
,const gchar *auth_params
);
Sets uri
's authentication parameters to auth_params
.
const gchar *
ide_uri_get_host (IdeUri *uri
);
Gets uri
's host. If uri
contained an IPv6 address literal, this
value will not include the brackets that are required by the URI
syntax.
void ide_uri_set_host (IdeUri *uri
,const gchar *host
);
Sets uri
's host to host
.
If host
is an IPv6 IP address, it should not include the brackets
required by the URI syntax; they will be added automatically when
converting uri
to a string.
void ide_uri_set_port (IdeUri *uri
,gushort port
);
Sets uri
's port to port
. If port
is 0, it will not be output
when calling ide_uri_to_string()
.
const gchar *
ide_uri_get_path (IdeUri *uri
);
Gets uri
's path, which may contain %-encoding, depending
on the flags with which uri
was parsed.
void ide_uri_set_path (IdeUri *uri
,const gchar *path
);
Sets uri
's path to path
, which is assumed to have been
appropriately %-encoded. In particular, this means that if
you want to include a literal percent sign the path, you must write
it as "%25". That being said, if path
contains an
unencoded '?' or '#' character, it will get encoded, since
otherwise converting uri
to a string and then back to a IdeUri
again would give a different result.
const gchar *
ide_uri_get_query (IdeUri *uri
);
Gets uri
's query, which may contain %-encoding, depending
on the flags with which uri
was parsed.
For queries consisting of a series of "name=value" parameters,
ide_uri_parse_params()
may be useful.
void ide_uri_set_query (IdeUri *uri
,const gchar *query
);
Sets uri
's query to query
, which is assumed to have been
%-encoded by the caller. See ide_uri_set_path()
for more
details.
const gchar *
ide_uri_get_fragment (IdeUri *uri
);
Gets uri
's fragment, which may contain %-encoding,
depending on the flags with which uri
was parsed.
void ide_uri_set_fragment (IdeUri *uri
,const gchar *fragment
);
Sets uri
's fragment to fragment
, which is assumed to have been
%-encoded by the caller. See ide_uri_set_path()
for more
details.
void ide_uri_split (const gchar *uri_string
,gboolean strict
,gchar **scheme
,gchar **userinfo
,gchar **host
,gchar **port
,gchar **path
,gchar **query
,gchar **fragment
);
Parses uri_string
more-or-less according to the generic grammar of
RFC 3986 ("more" if strict
is TRUE
, "less" if FALSE
), and
outputs the pieces into the provided variables. This is a low-level
method that does not do any pre- or post-processing of uri_string
,
and is "garbage in, garbage out"; it just splits uri_string
into
pieces at the appropriate punctuation characters (consuming
delimiters as appropriate), and returns the pieces. Components that
are not present in uri_string
will be set to NULL
(but note that
the path is always present, though it may be an empty string).
uri_string |
a string containing a relative or absolute URI |
|
strict |
whether to parse |
|
scheme |
on return, contains the scheme, or |
[out][nullable] |
userinfo |
on return, contains the userinfo, or |
[out][nullable] |
host |
on return, contains the host, or |
[out][nullable] |
port |
on return, contains the port, or |
[out][nullable] |
path |
on return, contains the path, or |
[out][nullable] |
query |
on return, contains the query, or |
[out][nullable] |
fragment |
on return, contains the fragment, or |
[out][nullable] |
GHashTable * ide_uri_parse_params (const gchar *params
,gssize length
,gchar separator
,gboolean case_insensitive
);
Many URI schemes include one or more attribute/value pairs as part of the URI value. This method can be used to parse them into a hash table.
The params
string is assumed to still be %-encoded, but
the returned values will be fully decoded. (Thus it is possible
that the returned values may contain '=' or separator
, if the
value was encoded in the input.) Invalid %-encoding is
treated as with the non-IDE_URI_PARSE_STRICT
rules for ide_uri_new()
.
(However, if params
is the path or query string from a IdeUri that
was parsed with IDE_URI_PARSE_STRICT
, then you already know that it
does not contain any invalid encoding.)
gboolean ide_uri_parse_host (const gchar *uri_string
,IdeUriParseFlags flags
,gchar **scheme
,gchar **host
,gushort *port
,GError **error
);
Utility function for parsing "network" URIs. This extracts just the
scheme, host, and port from uri_string
. All three out parameters
are mandatory.
uri_string |
a string containing a network URI |
|
flags |
flags for parsing |
|
scheme |
on return, will contain |
[out] |
host |
on return, will contain |
[out] |
port |
on return, will contain |
[out] |
error |
GError for error reporting, or |
gchar * ide_uri_build (const gchar *scheme
,const gchar *userinfo
,const gchar *host
,const gchar *port
,const gchar *path
,const gchar *query
,const gchar *fragment
);
GFile *
ide_uri_to_file (IdeUri *uri
);
Creates a GFile that represents the resource uri
.
Flags that control how a URI string is parsed (or re-parsed).
Parse the URI strictly according to the RFC 3986 grammar. |
||
Parse the URI according to the HTML5 web address parsing rules. |
||
Disallow Internationalized URIs; return an error if the URI contains non-ASCII characters |
||
Split the userinfo into user and password, separated by ':'. |
||
Split the userinfo into user/password and parameters, separated by ';'. |
||
Do not parse the host as a DNS host/IP address. (Eg, for smb URIs with NetBIOS hostnames). |
||
Decode even reserved %encoded
characters in the URI (unless this would result in non-UTF8
strings). Using this flag means that you cannot reliably
convert the parsed URI back to string form with
|
||
Return an error if non-UTF8 characters are encountered in the URI. |
#define IDE_URI_ERROR (ide_uri_error_quark ())
Error domain for URI methods. Errors in this domain will be from the IdeUriError enumeration. See GError for information on error domains.