Class UriParamsIter
- All Implemented Interfaces:
Proxy
scheme://server/path?query=string&is=there
has two
attributes – query=string
and is=there
– in its query part.
A GUriParamsIter
structure represents an iterator that can be used to
iterate over the attribute/value pairs of a URI query string. GUriParamsIter
structures are typically allocated on the stack and then initialized with
g_uri_params_iter_init(). See the documentation for g_uri_params_iter_init()
for a usage example.
-
Constructor Summary
ConstructorDescriptionAllocate a new UriParamsIter.UriParamsIter
(int dummy0, MemorySegment dummy1, MemorySegment dummy2, byte[] dummy3) Allocate a new UriParamsIter with the fields set to the provided values.UriParamsIter
(int dummy0, MemorySegment dummy1, MemorySegment dummy2, byte[] dummy3, Arena arena) Allocate a new UriParamsIter with the fields set to the provided values.UriParamsIter
(Arena arena) Allocate a new UriParamsIter.UriParamsIter
(MemorySegment address) Create a UriParamsIter proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionstatic MemoryLayout
The memory layout of the native struct.void
init
(String params, long length, String separators, Set<UriParamsFlags> flags) Initializes an attribute/value pair iterator.void
init
(String params, long length, String separators, UriParamsFlags... flags) Initializes an attribute/value pair iterator.boolean
Advances this UriParamsIter and retrieves the next attribute/value.int
Read the value of the fielddummy0
.Read the value of the fielddummy1
.Read the value of the fielddummy2
.byte[]
Read the value of the fielddummy3
.void
writeDummy0
(int dummy0) Write a value in the fielddummy0
.void
writeDummy1
(MemorySegment dummy1) Write a value in the fielddummy1
.void
writeDummy2
(MemorySegment dummy2) Write a value in the fielddummy2
.void
writeDummy3
(byte[] dummy3, Arena _arena) Write a value in the fielddummy3
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
UriParamsIter
Create a UriParamsIter proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
UriParamsIter
Allocate a new UriParamsIter.- Parameters:
arena
- to control the memory allocation scope
-
UriParamsIter
public UriParamsIter()Allocate a new UriParamsIter. The memory is allocated withArena.ofAuto()
. -
UriParamsIter
public UriParamsIter(int dummy0, MemorySegment dummy1, MemorySegment dummy2, byte[] dummy3, Arena arena) Allocate a new UriParamsIter with the fields set to the provided values.- Parameters:
dummy0
- value for the fielddummy0
dummy1
- value for the fielddummy1
dummy2
- value for the fielddummy2
dummy3
- value for the fielddummy3
arena
- to control the memory allocation scope
-
UriParamsIter
Allocate a new UriParamsIter with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
dummy0
- value for the fielddummy0
dummy1
- value for the fielddummy1
dummy2
- value for the fielddummy2
dummy3
- value for the fielddummy3
-
-
Method Details
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readDummy0
public int readDummy0()Read the value of the fielddummy0
.- Returns:
- The value of the field
dummy0
-
writeDummy0
public void writeDummy0(int dummy0) Write a value in the fielddummy0
.- Parameters:
dummy0
- The new value for the fielddummy0
-
readDummy1
Read the value of the fielddummy1
.- Returns:
- The value of the field
dummy1
-
writeDummy1
Write a value in the fielddummy1
.- Parameters:
dummy1
- The new value for the fielddummy1
-
readDummy2
Read the value of the fielddummy2
.- Returns:
- The value of the field
dummy2
-
writeDummy2
Write a value in the fielddummy2
.- Parameters:
dummy2
- The new value for the fielddummy2
-
readDummy3
public byte[] readDummy3()Read the value of the fielddummy3
.- Returns:
- The value of the field
dummy3
-
writeDummy3
Write a value in the fielddummy3
.- Parameters:
dummy3
- The new value for the fielddummy3
_arena
- to control the memory allocation scope
-
init
Initializes an attribute/value pair iterator.The iterator keeps pointers to the
params
andseparators
arguments, those variables must thus outlive the iterator and not be modified during the iteration.If
UriParamsFlags.WWW_FORM
is passed inflags
,+
characters in the param string will be replaced with spaces in the output. For example,foo=bar+baz
will give attributefoo
with valuebar baz
. This is commonly used on the web (thehttps
andhttp
schemes only), but is deprecated in favour of the equivalent of encoding spaces as%20
.Unlike with g_uri_parse_params(),
UriParamsFlags.CASE_INSENSITIVE
has no effect if passed toflags
for g_uri_params_iter_init(). The caller is responsible for doing their own case-insensitive comparisons.GUriParamsIter iter; GError *error = NULL; gchar *unowned_attr, *unowned_value; g_uri_params_iter_init (&iter, "foo=bar&baz=bar&Foo=frob&baz=bar2", -1, "&", G_URI_PARAMS_NONE); while (g_uri_params_iter_next (&iter, &unowned_attr, &unowned_value, &error)) { g_autofree gchar *attr = g_steal_pointer (&unowned_attr); g_autofree gchar *value = g_steal_pointer (&unowned_value); // do something with attr and value; this code will be called 4 times // for the params string in this example: once with attr=foo and value=bar, // then with baz/bar, then Foo/frob, then baz/bar2. } if (error) // handle parsing error
- Parameters:
params
- a%
-encoded string containingattribute=value
parameterslength
- the length ofparams
, or-1
if it is nul-terminatedseparators
- the separator byte character set between parameters. (usually&
, but sometimes;
or both&;
). Note that this function works on bytes not characters, so it can't be used to delimit UTF-8 strings for anything but ASCII characters. You may pass an empty set, in which case no splitting will occur.flags
- flags to modify the way the parameters are handled.
-
init
Initializes an attribute/value pair iterator.The iterator keeps pointers to the
params
andseparators
arguments, those variables must thus outlive the iterator and not be modified during the iteration.If
UriParamsFlags.WWW_FORM
is passed inflags
,+
characters in the param string will be replaced with spaces in the output. For example,foo=bar+baz
will give attributefoo
with valuebar baz
. This is commonly used on the web (thehttps
andhttp
schemes only), but is deprecated in favour of the equivalent of encoding spaces as%20
.Unlike with g_uri_parse_params(),
UriParamsFlags.CASE_INSENSITIVE
has no effect if passed toflags
for g_uri_params_iter_init(). The caller is responsible for doing their own case-insensitive comparisons.GUriParamsIter iter; GError *error = NULL; gchar *unowned_attr, *unowned_value; g_uri_params_iter_init (&iter, "foo=bar&baz=bar&Foo=frob&baz=bar2", -1, "&", G_URI_PARAMS_NONE); while (g_uri_params_iter_next (&iter, &unowned_attr, &unowned_value, &error)) { g_autofree gchar *attr = g_steal_pointer (&unowned_attr); g_autofree gchar *value = g_steal_pointer (&unowned_value); // do something with attr and value; this code will be called 4 times // for the params string in this example: once with attr=foo and value=bar, // then with baz/bar, then Foo/frob, then baz/bar2. } if (error) // handle parsing error
- Parameters:
params
- a%
-encoded string containingattribute=value
parameterslength
- the length ofparams
, or-1
if it is nul-terminatedseparators
- the separator byte character set between parameters. (usually&
, but sometimes;
or both&;
). Note that this function works on bytes not characters, so it can't be used to delimit UTF-8 strings for anything but ASCII characters. You may pass an empty set, in which case no splitting will occur.flags
- flags to modify the way the parameters are handled.
-
next
public boolean next(@Nullable @Nullable Out<String> attribute, @Nullable @Nullable Out<String> value) throws GErrorException Advances this UriParamsIter and retrieves the next attribute/value.false
is returned if an error has occurred (in which caseerror
is set), or if the end of the iteration is reached (in which caseattribute
andvalue
are set tonull
and the iterator becomes invalid). Iftrue
is returned, g_uri_params_iter_next() may be called again to receive another attribute/value pair.Note that the same
attribute
may be returned multiple times, since URIs allow repeated attributes.- Parameters:
attribute
- on return, contains the attribute, ornull
.value
- on return, contains the value, ornull
.- Returns:
false
if the end of the parameters has been reached or an error was encountered.true
otherwise.- Throws:
GErrorException
- seeGError
-