Class UriParamsIter

java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.glib.UriParamsIter
All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class UriParamsIter extends ProxyInstance

Many URI schemes include one or more attribute/value pairs as part of the URI value. For example 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 Details

    • UriParamsIter

      public UriParamsIter(MemorySegment address)
      Create a UriParamsIter proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • UriParamsIter

      public UriParamsIter(Arena arena)
      Allocate a new UriParamsIter.
      Parameters:
      arena - to control the memory allocation scope
    • UriParamsIter

      public UriParamsIter()
      Allocate a new UriParamsIter. The memory is allocated with Arena.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 field dummy0
      dummy1 - value for the field dummy1
      dummy2 - value for the field dummy2
      dummy3 - value for the field dummy3
      arena - to control the memory allocation scope
    • UriParamsIter

      public UriParamsIter(int dummy0, MemorySegment dummy1, MemorySegment dummy2, byte[] dummy3)
      Allocate a new UriParamsIter with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      dummy0 - value for the field dummy0
      dummy1 - value for the field dummy1
      dummy2 - value for the field dummy2
      dummy3 - value for the field dummy3
  • Method Details

    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readDummy0

      public int readDummy0()
      Read the value of the field dummy0.
      Returns:
      The value of the field dummy0
    • writeDummy0

      public void writeDummy0(int dummy0)
      Write a value in the field dummy0.
      Parameters:
      dummy0 - The new value for the field dummy0
    • readDummy1

      public MemorySegment readDummy1()
      Read the value of the field dummy1.
      Returns:
      The value of the field dummy1
    • writeDummy1

      public void writeDummy1(MemorySegment dummy1)
      Write a value in the field dummy1.
      Parameters:
      dummy1 - The new value for the field dummy1
    • readDummy2

      public MemorySegment readDummy2()
      Read the value of the field dummy2.
      Returns:
      The value of the field dummy2
    • writeDummy2

      public void writeDummy2(MemorySegment dummy2)
      Write a value in the field dummy2.
      Parameters:
      dummy2 - The new value for the field dummy2
    • readDummy3

      public @Nullable byte @Nullable [] readDummy3()
      Read the value of the field dummy3.
      Returns:
      The value of the field dummy3
    • writeDummy3

      public void writeDummy3(@Nullable byte @Nullable [] dummy3, Arena _arena)
      Write a value in the field dummy3.
      Parameters:
      dummy3 - The new value for the field dummy3
    • init

      public void init(String params, long length, String separators, Set<UriParamsFlags> flags)

      Initializes an attribute/value pair iterator.

      The iterator keeps pointers to the params and separators arguments, those variables must thus outlive the iterator and not be modified during the iteration.

      If UriParamsFlags.WWW_FORM is passed in flags, + characters in the param string will be replaced with spaces in the output. For example, foo=bar+baz will give attribute foo with value bar baz. This is commonly used on the web (the https and http 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 to flags 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 containing attribute=value parameters
      length - the length of params, or -1 if it is nul-terminated
      separators - 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

      public void init(String params, long length, String separators, UriParamsFlags... flags)

      Initializes an attribute/value pair iterator.

      The iterator keeps pointers to the params and separators arguments, those variables must thus outlive the iterator and not be modified during the iteration.

      If UriParamsFlags.WWW_FORM is passed in flags, + characters in the param string will be replaced with spaces in the output. For example, foo=bar+baz will give attribute foo with value bar baz. This is commonly used on the web (the https and http 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 to flags 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 containing attribute=value parameters
      length - the length of params, or -1 if it is nul-terminated
      separators - 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. false is returned if an error has occurred (in which case error is set), or if the end of the iteration is reached (in which case attribute and value are set to null and the iterator becomes invalid). If true 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, or null.
      value - on return, contains the value, or null.
      Returns:
      false if the end of the parameters has been reached or an error was encountered. true otherwise.
      Throws:
      GErrorException - see GError
      Since:
      2.66