Lyricdev
GitHub

class Query

pub class Query

Conforms to Display, Equatable.

The pairs of a query, key=value joined by &, in the order written; a key may appear more than once. parse decodes the percent-encodings and a + as a space (the form convention servers see); show percent-encodes each key and value for Component.Pair, a space as %20.

Methods

pub static fn new(): Query

Returns an empty query.

pub fn pairs(): List<(string, string)>

Returns the pairs in their order.

pub static fn parse(s: StringView): Query throws ParseError

Parses a=1&b=2&a=3: a part without = is a key with an empty value; an empty part is skipped.

Errors

Throws ParseError as Percent.decode does, for a key or value that does not decode.

pub fn get(key: string): ?string

Returns the first value of the key, or null where it is not there.

pub fn all(key: string): string[]

Returns every value of the key, in order.

pub fn has(key: string): bool

Returns whether the key is there.

pub fn length(): int

Returns the number of pairs.

pub fn isEmpty(): bool

Returns whether there are no pairs.

pub mut fn add(key: string, value: string): void

Adds a pair at the end.

pub mut fn set(key: string, value: string): void

Sets the key's first pair to value and removes its others; a key not there is added at the end.

pub mut fn remove(key: string): void

Removes every pair of the key.

fn show(): string
fn equals(o: Query): bool