std1.0.0-beta-7 SafeC docs

std :: encoding::url

Struct std::QueryParams

#include <std/encoding/url.h> source

struct QueryParams {
    struct Vec<struct UrlQueryPair> pairs;
}

An ordered multi-map of decoded key/value pairs — the parsed form of "a=1&b=two%20words&a=3" (a query string without its '?', or an application/x-www-form-urlencoded request body). Keys may repeat; get() returns the first. Lookups are case-sensitive, like URLSearchParams.

Fields

§struct Vec<struct UrlQueryPair> pairssource

Methods

§static struct QueryParams new()source · definition
§static struct QueryParams parse(const &char qs)source · definition

Parses 'qs' (a leading '?' is skipped). Empty segments ("a=1&&b=2") are dropped; a segment without '=' is a key with an empty value.

§static struct QueryParams parse_bytes([]const char qs)source · definition

parse() over raw bytes (e.g. a request body, which is not NUL-terminated in general).

§unsigned long length() constsource · definition
§const ?&char get(const &char key) constsource · definition

The first value for 'key', or null if absent. The reference aliases this object's storage: valid until the next mutation or free().

§const &char get_or(const &char key, const &char fallback) constsource · definition

get() with a fallback for an absent key.

§unsigned long count(const &char key) constsource · definition

How many pairs have this key, and the n-th of them (0-based; null past the end).

§const ?&char get_nth(const &char key, unsigned long n) constsource · definition
§int has(const &char key) constsource · definition
§const ?&char key_at(unsigned long i) constsource · definition

i-th pair in order (null past the end).

§const ?&char value_at(unsigned long i) constsource · definition
§void append(const &char key, const &char value)source · definition

Adds a pair at the end (keeps existing ones with the same key).

§void set(const &char key, const &char value)source · definition

Replaces the first pair with this key and removes the others, or appends one if there was none.

§unsigned long remove(const &char key)source · definition

Removes every pair with this key; returns how many there were.

§void sort()source · definition

Stable sort by key (byte order), as URLSearchParams.sort().

§struct String to_string() constsource · definition

Serializes back to "k=v&k2=v2" with form_encode on both halves (no leading '?').

§struct QueryParams clone() constsource · definition
§void drop()source · definition
§void free() consumesource · definition

= drop()