Skip to content

D

Ada has a D client available on Github and also on dub.pm.

Installation

Add the following as a dependency to your project (dub.json or dub.sdl):

Terminal window
# dub add ada-d from dub-registry
$ dub add ada-d

Modules hierarchy:

Terminal window
.
└── source
└── ada
├── c
│   ├── ada.d # low-level C bindings - @nogc, nothrow, @safe and betterC compatible
│   └── wrapper.d # D (mangled) RAII - @nogc, nothrow, @safe and betterC compatible
└── url
└── package.d # by default set public wrapper.d in 'import ada.url'
# (for low-level C bindings use 'import ada.c.ada')

Usage

Here is an example illustrating a common usage:

import ada.url : AdaUrl, ParseOptions; // @safe, nothrow and betterC compatible
import std.stdio : writeln; // need GC and throw exception
void main() @safe {
auto u = AdaUrl(ParseOptions("http://www.google:8080/love#drug"));
writeln("port: ", u.getPort);
writeln("hash: ", u.getHash);
writeln("pathname: ", u.getPathname);
writeln("href: ", u.getHref());
u.setPort("9999");
writeln("href: ", u.getHref); // empty '()' is optional
}

full example: here

Resources