Dirk



struct  ConnectionInfo;

Result of the parse and tryParse functions,

containing the parsed connection information.


string  address;

Server  address.


ushort  explicitPort;

Explicitly specified server port, or 0 when unspecified.


pure nothrow @property @safe ushort  port();

Server  port.

Evaluates to ConnectionInfo.explicitPort when an explicit  port was specified, and ConnectionInfo.defaultPort otherwise.


bool  secure;

Security protocol. Is true for TLS/SSL,

and false for no security.


string[]  channels;

Channels to join immediately after a successful connect. Can be empty.


string  channelKey;

Key/passphrase to use when joining channels.

Is null when unspecified.


pure nothrow @property @safe ushort  defaultPort();

Default port for the specified security protocol.

6697 for TLS/SSL, and 6667 otherwise.


class  IrcUrlException: object.Exception;




size_t  location;

Same as  location">ParseError. location.


@safe ConnectionInfo  parse(string url);

Parse IRC URLs (also known as "chat links").

Channels without a valid prefix are automatically prefixed with '#'.

Examples
ConnectionInfo info;

info = parse("ircs://irc.example.com:6697/foo,bar");

assert(info.address == "irc.example.com");
assert(info.explicitPort == 6697);
assert(info.port == 6697);
assert(info.secure);
assert(info.channels == ["#foo", "#bar"]);

info = parse("irc://irc.example.org/foo?pass");

assert(info.address == "irc.example.org");
assert(info.explicitPort == 0);
assert(info.port == 6667); // No explicit port, so it falls back to the default IRC port
assert(!info.secure);
assert(info.channels == ["#foo"]);
assert(info.channelKey == "pass");

struct  ParseError;




string  message;

Error  message.


size_t  location;

Location in input (zero-based column) the error occured.

Ranges from 0 .. $ - 1, where the $ symbol is the length of the input.


pure @safe bool  opCast(T)() if (is(T == bool));

Boolean whether or not an error occured. If an error did not occur,

message and location will not have meaningful values.

Examples
auto error = ParseError("error occured!", 0);
assert(error); // conversion to $(D bool)

@trusted ParseError  tryParse(string url, out ConnectionInfo info);

Same as parse, but returning an error message instead of throwing. Useful for high-volume parsing.

Examples
Parse list of URLs and write any errors to stderr

with column information.
import std.stdio : stderr;

auto urls = ["irc://example.com", "ircs://example.org/foo?pass"];

foreach(url; urls)
{
	ConnectionInfo info;

	if(auto error = url.tryParse(info))
	{
		stderr.writefln("Error parsing URL:\n%s\n%*s\n%s", url, error.location + 1, "^", error.message);
		continue;
	}

	// Use `info`
}