src/httpquery

Search:
Group by:

A Nim library for parsing RFC 3986 URL query strings.

Types

httpParam {.final.} = object
httpQuery {.final.} = object
HTTPQueryException {.pure, inheritable.} = object of CatchableError
HTTPQueryParseException {.pure, inheritable.} = object of HTTPQueryException

Procs

proc `$`(query: httpQuery): string {....raises: [], tags: [], forbids: [].}
Converts the httpQuery to its string representation (same as dumpString).
proc `=destroy`(query: httpQuery): void {....raises: [], tags: [], forbids: [].}
Destructor. Automatically frees the internal query resources.
proc addFloat(query: httpQuery; key: string; value: BiggestFloat): void {.
    ...raises: [], tags: [], forbids: [].}
Adds a floating-point key-value pair to the query.
proc addInt(query: httpQuery; key: string; value: BiggestInt): void {.
    ...raises: [], tags: [], forbids: [].}
Adds an integer key-value pair to the query.
proc addString(query: httpQuery; key: string; value: string): void {....raises: [],
    tags: [], forbids: [].}
Adds a string key-value pair to the query.
proc addUInt(query: httpQuery; key: string; value: BiggestUInt): void {.
    ...raises: [], tags: [], forbids: [].}
Adds an unsigned integer key-value pair to the query.
proc clear(query: httpQuery): void {....raises: [], tags: [], forbids: [].}
Clears all parameters from the query and frees internal memory.
proc dumpString(query: httpQuery): string {....raises: [], tags: [], forbids: [].}
Serializes the query back into a query string (e.g. "key1=value1&..."). The returned string is properly encoded.
proc getBool(param: httpParam; key: string): bool {....raises: [KeyError],
    tags: [], forbids: [].}
Retrieves a boolean value by key from a single httpParam.
proc getBool(query: httpQuery; key: string): bool {....raises: [KeyError],
    tags: [], forbids: [].}
Retrieves a boolean value by key from the query.
proc getFloat(param: httpParam; key: string): BiggestFloat {....raises: [KeyError],
    tags: [], forbids: [].}
Retrieves a float value by key from a single httpParam.
proc getFloat(query: httpQuery; key: string): BiggestFloat {....raises: [KeyError],
    tags: [], forbids: [].}
Retrieves a float value by key from the query.
proc getInt(param: httpParam; key: string): BiggestInt {....raises: [KeyError],
    tags: [], forbids: [].}
Retrieves an integer value by key from a single httpParam.
proc getInt(query: httpQuery; key: string): BiggestInt {....raises: [KeyError],
    tags: [], forbids: [].}
Retrieves an integer value by key from the query.
proc getItem(query: httpQuery; index: int): hquery_param_t {....raises: [],
    tags: [], forbids: [].}
Returns the raw hquery_param_t at the given index (0-based).
proc getString(param: httpParam; key: string; decode: bool = true): string {.
    ...raises: [KeyError], tags: [], forbids: [].}
Retrieves a string value by key from a single httpParam.
  • If decode is true (default), the value is URL-decoded.
proc getString(query: httpQuery; key: string; decode: bool = true): string {.
    ...raises: [KeyError], tags: [], forbids: [].}
Retrieves a string value by key from the query.
  • If decode is true (default), the value is URL-decoded.
proc getUInt(param: httpParam; key: string): BiggestUInt {....raises: [KeyError],
    tags: [], forbids: [].}
Retrieves an unsigned integer value by key from a single httpParam.
proc getUInt(query: httpQuery; key: string): BiggestUInt {....raises: [KeyError],
    tags: [], forbids: [].}
Retrieves an unsigned integer value by key from the query.
proc len(query: httpQuery): int {....raises: [], tags: [], forbids: [].}
Returns the number of parameters currently in the query.
proc newHttpQuery(sep: char = '&'; subsep: string = "="): httpQuery {.
    ...raises: [], tags: [], forbids: [].}
Creates a new empty httpQuery object.
  • sep: character used to separate parameters (default &).
  • subsep: string used to separate key from value (default =).
proc parseFile(query: httpQuery; filename: string): void {.
    ...raises: [HTTPQueryParseException], tags: [], forbids: [].}
Loads and parses a query string from a file.
proc parseString(query: httpQuery; str: string): void {.
    ...raises: [HTTPQueryParseException], tags: [], forbids: [].}
Parses a query string (e.g. "key1=value1&key2=value2") into the httpQuery object.