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.
- Since:
- 2.66
-
Constructor Summary
ConstructorsConstructorDescriptionAllocate 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 MemoryLayoutThe memory layout of the native struct.voidinit(String params, long length, String separators, Set<UriParamsFlags> flags) Initializes an attribute/value pair iterator.voidinit(String params, long length, String separators, UriParamsFlags... flags) Initializes an attribute/value pair iterator.booleanAdvances this UriParamsIter and retrieves the next attribute/value.intRead the value of the fielddummy0.Read the value of the fielddummy1.Read the value of the fielddummy2.@org.jspecify.annotations.Nullable byte @Nullable []Read the value of the fielddummy3.voidwriteDummy0(int dummy0) Write a value in the fielddummy0.voidwriteDummy1(MemorySegment dummy1) Write a value in the fielddummy1.voidwriteDummy2(MemorySegment dummy2) Write a value in the fielddummy2.voidwriteDummy3(@org.jspecify.annotations.Nullable byte @Nullable [] dummy3, Arena _arena) Write a value in the fielddummy3.Methods inherited from class org.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 fielddummy0dummy1- value for the fielddummy1dummy2- value for the fielddummy2dummy3- value for the fielddummy3arena- 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 fielddummy0dummy1- value for the fielddummy1dummy2- value for the fielddummy2dummy3- 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 @org.jspecify.annotations.Nullable byte @Nullable [] 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
-
init
Initializes an attribute/value pair iterator.The iterator keeps pointers to the
paramsandseparatorsarguments, those variables must thus outlive the iterator and not be modified during the iteration.If
UriParamsFlags.WWW_FORMis passed inflags,+characters in the param string will be replaced with spaces in the output. For example,foo=bar+bazwill give attributefoowith valuebar baz. This is commonly used on the web (thehttpsandhttpschemes only), but is deprecated in favour of the equivalent of encoding spaces as%20.Unlike with g_uri_parse_params(),
UriParamsFlags.CASE_INSENSITIVEhas no effect if passed toflagsfor 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=valueparameterslength- the length ofparams,or-1if 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.- Since:
- 2.66
-
init
Initializes an attribute/value pair iterator.The iterator keeps pointers to the
paramsandseparatorsarguments, those variables must thus outlive the iterator and not be modified during the iteration.If
UriParamsFlags.WWW_FORMis passed inflags,+characters in the param string will be replaced with spaces in the output. For example,foo=bar+bazwill give attributefoowith valuebar baz. This is commonly used on the web (thehttpsandhttpschemes only), but is deprecated in favour of the equivalent of encoding spaces as%20.Unlike with g_uri_parse_params(),
UriParamsFlags.CASE_INSENSITIVEhas no effect if passed toflagsfor 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=valueparameterslength- the length ofparams,or-1if 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.- Since:
- 2.66
-
next
public boolean next(@Nullable Out<String> attribute, @Nullable Out<String> value) throws GErrorException Advances this UriParamsIter and retrieves the next attribute/value.falseis returned if an error has occurred (in which caseerroris set), or if the end of the iteration is reached (in which caseattributeandvalueare set tonulland the iterator becomes invalid). Iftrueis returned, g_uri_params_iter_next() may be called again to receive another attribute/value pair.Note that the same
attributemay 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:
falseif the end of the parameters has been reached or an error was encountered.trueotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.66
-