1,085 changes: 541 additions & 544 deletions std/datetime.d

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions std/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -3252,22 +3252,22 @@ alias PreserveAttributes = Flag!"preserveAttributes";

version (StdDdoc)
{
/// Defaults to PreserveAttributes.yes on Windows, and the opposite on all other platforms.
/// Defaults to $(D Yes.preserveAttributes) on Windows, and the opposite on all other platforms.
PreserveAttributes preserveAttributesDefault;
}
else version(Windows)
{
enum preserveAttributesDefault = PreserveAttributes.yes;
enum preserveAttributesDefault = Yes.preserveAttributes;
}
else
{
enum preserveAttributesDefault = PreserveAttributes.no;
enum preserveAttributesDefault = No.preserveAttributes;
}

/***************************************************
Copy file $(D from) to file $(D to). File timestamps are preserved.
File attributes are preserved, if $(D preserve) equals $(D PreserveAttributes.yes).
On Windows only $(D PreserveAttributes.yes) (the default on Windows) is supported.
File attributes are preserved, if $(D preserve) equals $(D Yes.preserveAttributes).
On Windows only $(D Yes.preserveAttributes) (the default on Windows) is supported.
If the target file exists, it is overwritten.
Params:
Expand Down
26 changes: 13 additions & 13 deletions std/net/curl.d
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ struct ByLineBuffer(Char)
*
* Params:
* url = The url to receive content from
* keepTerminator = KeepTerminator.yes signals that the line terminator should be
* keepTerminator = $(D Yes.keepTerminator) signals that the line terminator should be
* returned as part of the lines in the range.
* terminator = The character that terminates a line
* conn = The connection to use e.g. HTTP or FTP.
Expand All @@ -1224,7 +1224,7 @@ struct ByLineBuffer(Char)
* A range of Char[] with the content of the resource pointer to by the URL
*/
auto byLine(Conn = AutoProtocol, Terminator = char, Char = char)
(const(char)[] url, KeepTerminator keepTerminator = KeepTerminator.no,
(const(char)[] url, KeepTerminator keepTerminator = No.keepTerminator,
Terminator terminator = '\n', Conn conn = Conn())
if (isCurlConn!Conn && isSomeChar!Char && isSomeChar!Terminator)
{
Expand Down Expand Up @@ -1290,7 +1290,7 @@ if (isCurlConn!Conn && isSomeChar!Char && isSomeChar!Terminator)
}

auto result = _getForRange!Char(url, conn);
return SyncLineInputRange(result, keepTerminator == KeepTerminator.yes, terminator);
return SyncLineInputRange(result, keepTerminator == Yes.keepTerminator, terminator);
}

unittest
Expand Down Expand Up @@ -1590,7 +1590,7 @@ private static struct AsyncLineInputRange(Char)
* Params:
* url = The url to receive content from
* postData = Data to HTTP Post
* keepTerminator = KeepTerminator.yes signals that the line terminator should be
* keepTerminator = $(D Yes.keepTerminator) signals that the line terminator should be
* returned as part of the lines in the range.
* terminator = The character that terminates a line
* transmitBuffers = The number of lines buffered asynchronously
Expand All @@ -1602,7 +1602,7 @@ private static struct AsyncLineInputRange(Char)
*/
auto byLineAsync(Conn = AutoProtocol, Terminator = char, Char = char, PostUnit)
(const(char)[] url, const(PostUnit)[] postData,
KeepTerminator keepTerminator = KeepTerminator.no,
KeepTerminator keepTerminator = No.keepTerminator,
Terminator terminator = '\n',
size_t transmitBuffers = 10, Conn conn = Conn())
if (isCurlConn!Conn && isSomeChar!Char && isSomeChar!Terminator)
Expand All @@ -1623,7 +1623,7 @@ auto byLineAsync(Conn = AutoProtocol, Terminator = char, Char = char, PostUnit)
auto tid = spawn(&_spawnAsync!(Conn, Char, Terminator));
tid.send(thisTid);
tid.send(terminator);
tid.send(keepTerminator == KeepTerminator.yes);
tid.send(keepTerminator == Yes.keepTerminator);

_asyncDuplicateConnection(url, conn, postData, tid);

Expand All @@ -1634,7 +1634,7 @@ auto byLineAsync(Conn = AutoProtocol, Terminator = char, Char = char, PostUnit)

/// ditto
auto byLineAsync(Conn = AutoProtocol, Terminator = char, Char = char)
(const(char)[] url, KeepTerminator keepTerminator = KeepTerminator.no,
(const(char)[] url, KeepTerminator keepTerminator = No.keepTerminator,
Terminator terminator = '\n',
size_t transmitBuffers = 10, Conn conn = Conn())
{
Expand Down Expand Up @@ -2493,7 +2493,7 @@ struct HTTP
Params:
throwOnError = whether to throw an exception or return a CurlCode on error
*/
CurlCode perform(ThrowOnError throwOnError = ThrowOnError.yes)
CurlCode perform(ThrowOnError throwOnError = Yes.throwOnError)
{
p.status.reset();

Expand Down Expand Up @@ -3246,7 +3246,7 @@ struct FTP
Params:
throwOnError = whether to throw an exception or return a CurlCode on error
*/
CurlCode perform(ThrowOnError throwOnError = ThrowOnError.yes)
CurlCode perform(ThrowOnError throwOnError = Yes.throwOnError)
{
return p.curl.perform(throwOnError);
}
Expand Down Expand Up @@ -3577,7 +3577,7 @@ struct SMTP
Params:
throwOnError = whether to throw an exception or return a CurlCode on error
*/
CurlCode perform(ThrowOnError throwOnError = ThrowOnError.yes)
CurlCode perform(ThrowOnError throwOnError = Yes.throwOnError)
{
return p.curl.perform(throwOnError);
}
Expand Down Expand Up @@ -3859,7 +3859,7 @@ class CurlTimeoutException : CurlException
/// Equal to $(REF CURLcode, etc,c,curl)
alias CurlCode = CURLcode;

import std.typecons : Flag;
import std.typecons : Flag, Yes, No;
/// Flag to specify whether or not an exception is thrown on error.
alias ThrowOnError = Flag!"throwOnError";

Expand Down Expand Up @@ -4205,7 +4205,7 @@ struct Curl
Params:
throwOnError = whether to throw an exception or return a CurlCode on error
*/
CurlCode perform(ThrowOnError throwOnError = ThrowOnError.yes)
CurlCode perform(ThrowOnError throwOnError = Yes.throwOnError)
{
throwOnStopped();
CurlCode code = curl.easy_perform(this.handle);
Expand Down Expand Up @@ -4812,7 +4812,7 @@ private static void _spawnAsync(Conn, Unit, Terminator = void)()
CurlCode code;
try
{
code = client.perform(ThrowOnError.no);
code = client.perform(No.throwOnError);
}
catch (Exception ex)
{
Expand Down
348 changes: 174 additions & 174 deletions std/net/isemail.d

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions std/socket.d
Original file line number Diff line number Diff line change
Expand Up @@ -2583,14 +2583,15 @@ private:
version(SlowTests)
softUnittest({
import std.datetime;
import std.typecons;

enum msecs = 1000;
auto pair = socketPair();
auto sock = pair[0];
sock.setOption(SocketOptionLevel.SOCKET,
SocketOption.RCVTIMEO, dur!"msecs"(msecs));

auto sw = StopWatch(AutoStart.yes);
auto sw = StopWatch(Yes.autoStart);
ubyte[1] buf;
sock.receive(buf);
sw.stop();
Expand Down Expand Up @@ -3208,6 +3209,7 @@ public:
* Example:
* ---
* import std.datetime;
* import std.typecons;
* auto pair = socketPair();
* scope(exit) foreach (s; pair) s.close();
*
Expand All @@ -3216,7 +3218,7 @@ public:
* pair[0].setOption(SocketOptionLevel.SOCKET,
* SocketOption.RCVTIMEO, dur!"seconds"(1));
*
* auto sw = StopWatch(AutoStart.yes);
* auto sw = StopWatch(Yes.autoStart);
* ubyte[1] buffer;
* pair[0].receive(buffer);
* writefln("Waited %s ms until the socket timed out.",
Expand Down
18 changes: 9 additions & 9 deletions std/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,7 @@ Allows to directly use range operations on lines of a file.
enum defTerm = cast(Terminator)"\n";

public:
this(File f, KeepTerminator kt = KeepTerminator.no,
this(File f, KeepTerminator kt = No.keepTerminator,
Terminator terminator = defTerm)
{
impl = PImpl(f, kt, terminator);
Expand Down Expand Up @@ -1963,7 +1963,7 @@ Allows to directly use range operations on lines of a file.
file.detach();
line = null;
}
else if (keepTerminator == KeepTerminator.no
else if (keepTerminator == No.keepTerminator
&& endsWith(line, terminator))
{
static if (isScalarType!Terminator)
Expand Down Expand Up @@ -1998,7 +1998,7 @@ instead.
Params:
Char = Character type for each line, defaulting to $(D char).
keepTerminator = Use $(D KeepTerminator.yes) to include the
keepTerminator = Use $(D Yes.keepTerminator) to include the
terminator at the end of each line.
terminator = Line separator ($(D '\n') by default). Use
$(REF newline, std,ascii) for portability (unless the file was opened in
Expand Down Expand Up @@ -2043,7 +2043,7 @@ $(D front) after the corresponding $(D popFront) call is made (because
the contents may well have changed).
*/
auto byLine(Terminator = char, Char = char)
(KeepTerminator keepTerminator = KeepTerminator.no,
(KeepTerminator keepTerminator = No.keepTerminator,
Terminator terminator = '\n')
if (isScalarType!Terminator)
{
Expand Down Expand Up @@ -2157,7 +2157,7 @@ primitives may throw $(D StdioException) on I/O error.
Params:
Char = Character type for each line, defaulting to $(D immutable char).
keepTerminator = Use $(D KeepTerminator.yes) to include the
keepTerminator = Use $(D Yes.keepTerminator) to include the
terminator at the end of each line.
terminator = Line separator ($(D '\n') by default). Use
$(REF newline, std,ascii) for portability (unless the file was opened in
Expand All @@ -2181,7 +2181,7 @@ See_Also:
$(REF readText, std,file)
*/
auto byLineCopy(Terminator = char, Char = immutable char)
(KeepTerminator keepTerminator = KeepTerminator.no,
(KeepTerminator keepTerminator = No.keepTerminator,
Terminator terminator = '\n')
if (isScalarType!Terminator)
{
Expand Down Expand Up @@ -2260,7 +2260,7 @@ $(REF readText, std,file)
assert(File(deleteme).byLineCopy(kt, term).array.sort() == witness.dup.sort());
}

KeepTerminator kt = KeepTerminator.no;
KeepTerminator kt = No.keepTerminator;
test("", null, kt, '\n');
test("\n", [ "" ], kt, '\n');
test("asd\ndef\nasdf", [ "asd", "def", "asdf" ], kt, '\n');
Expand All @@ -2271,7 +2271,7 @@ $(REF readText, std,file)
kt, "\r\n");
test("sue\r", ["sue"], kt, '\r');

kt = KeepTerminator.yes;
kt = Yes.keepTerminator;
test("", null, kt, '\n');
test("\n", [ "\n" ], kt, '\n');
test("asd\ndef\nasdf", [ "asd\n", "def\n", "asdf" ], kt, '\n');
Expand Down Expand Up @@ -4352,7 +4352,7 @@ __gshared

void main() {
stdin // read from stdin
.byLineCopy(KeepTerminator.yes) // copying each line
.byLineCopy(Yes.keepTerminator) // copying each line
.array() // convert to array of lines
.sort() // sort the lines
.copy( // copy output of .sort to an OutputRange
Expand Down
432 changes: 216 additions & 216 deletions std/string.d

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions std/utf.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module std.utf;
import std.meta; // AliasSeq
import std.range.primitives;
import std.traits; // isSomeChar, isSomeString
import std.typecons; // Flag
import std.typecons; // Flag, Yes, No
import std.exception; // basicExceptionCtors

//debug=utf; // uncomment to turn on debugging printf's
Expand Down Expand Up @@ -999,9 +999,9 @@ alias UseReplacementDchar = Flag!"useReplacementDchar";
Throws:
$(LREF UTFException) if $(D str[index]) is not the start of a valid UTF
sequence and useReplacementDchar is UseReplacementDchar.no
sequence and useReplacementDchar is $(D No.useReplacementDchar)
+/
dchar decode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(auto ref S str, ref size_t index)
dchar decode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(auto ref S str, ref size_t index)
if (!isSomeString!S &&
isRandomAccessRange!S && hasSlicing!S && hasLength!S && isSomeChar!(ElementType!S))
in
Expand All @@ -1020,7 +1020,7 @@ body
return decodeImpl!(true, useReplacementDchar)(str, index);
}

dchar decode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
dchar decode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(
auto ref S str, ref size_t index) @trusted pure if (isSomeString!S)
in
{
Expand Down Expand Up @@ -1061,7 +1061,7 @@ body
type of range being used and how many code units had to be popped off
before the code point was determined to be invalid.
+/
dchar decodeFront(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
dchar decodeFront(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(
ref S str, out size_t numCodeUnits) if (!isSomeString!S && isInputRange!S && isSomeChar!(ElementType!S))
in
{
Expand Down Expand Up @@ -1097,7 +1097,7 @@ body
}
}

dchar decodeFront(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
dchar decodeFront(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(
ref S str, out size_t numCodeUnits) @trusted pure if (isSomeString!S)
in
{
Expand Down Expand Up @@ -1125,7 +1125,7 @@ body
}

/++ Ditto +/
dchar decodeFront(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(ref S str)
dchar decodeFront(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(ref S str)
if (isInputRange!S && isSomeChar!(ElementType!S))
{
size_t numCodeUnits;
Expand Down Expand Up @@ -1161,7 +1161,7 @@ package template codeUnitLimit(S)
* Returns:
* decoded character
*/
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(
auto ref S str, ref size_t index) if (
is(S : const char[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == char)))
{
Expand Down Expand Up @@ -1385,13 +1385,13 @@ unittest
{
auto r = R(s);
size_t index;
dchar dc = decodeImpl!(false, Flag!"useReplacementDchar".yes)(r, index);
dchar dc = decodeImpl!(false, Yes.useReplacementDchar)(r, index);
assert(dc == replacementDchar);
assert(1 <= index && index <= s.length);
}
}

private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)
(auto ref S str, ref size_t index)
if (is(S : const wchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == wchar)))
{
Expand Down Expand Up @@ -1502,13 +1502,13 @@ unittest
{
auto r = R(s);
size_t index;
dchar dc = decodeImpl!(false, Flag!"useReplacementDchar".yes)(r, index);
dchar dc = decodeImpl!(false, Yes.useReplacementDchar)(r, index);
assert(dc == replacementDchar);
assert(1 <= index && index <= s.length);
}
}

private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(
auto ref S str, ref size_t index)
if (is(S : const dchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == dchar)))
{
Expand Down Expand Up @@ -1566,7 +1566,7 @@ unittest
{
auto r = R(s);
size_t index;
dchar dc = decodeImpl!(false, Flag!"useReplacementDchar".yes)(r, index);
dchar dc = decodeImpl!(false, Yes.useReplacementDchar)(r, index);
assert(dc == replacementDchar);
assert(1 <= index && index <= s.length);
}
Expand Down Expand Up @@ -1860,7 +1860,7 @@ private dchar _utfException(UseReplacementDchar useReplacementDchar)(string msg,
Throws:
$(D UTFException) if $(D c) is not a valid UTF code point.
+/
size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
size_t encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
ref char[4] buf, dchar c) @safe pure
{
if (c <= 0x7F)
Expand Down Expand Up @@ -1928,14 +1928,14 @@ size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
assertThrown!UTFException(encode(buf, cast(dchar)0xDFFF));
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));

assert(encode!(UseReplacementDchar.yes)(buf, cast(dchar)0x110000) == buf.stride);
assert(encode!(Yes.useReplacementDchar)(buf, cast(dchar)0x110000) == buf.stride);
assert(buf.front == replacementDchar);
});
}


/// Ditto
size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
size_t encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
ref wchar[2] buf, dchar c) @safe pure
{
if (c <= 0xFFFF)
Expand Down Expand Up @@ -1981,14 +1981,14 @@ size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
assertThrown!UTFException(encode(buf, cast(dchar)0xDFFF));
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));

assert(encode!(UseReplacementDchar.yes)(buf, cast(dchar)0x110000) == buf.stride);
assert(encode!(Yes.useReplacementDchar)(buf, cast(dchar)0x110000) == buf.stride);
assert(buf.front == replacementDchar);
});
}


/// Ditto
size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
size_t encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
ref dchar[1] buf, dchar c) @safe pure
{
if ((0xD800 <= c && c <= 0xDFFF) || 0x10FFFF < c)
Expand Down Expand Up @@ -2019,7 +2019,7 @@ size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
assertThrown!UTFException(encode(buf, cast(dchar)0xDFFF));
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));

assert(encode!(UseReplacementDchar.yes)(buf, cast(dchar)0x110000) == buf.stride);
assert(encode!(Yes.useReplacementDchar)(buf, cast(dchar)0x110000) == buf.stride);
assert(buf.front == replacementDchar);
});
}
Expand All @@ -2031,7 +2031,7 @@ size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
Throws:
$(D UTFException) if $(D c) is not a valid UTF code point.
+/
void encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
ref char[] str, dchar c) @safe pure
{
char[] r = str;
Expand Down Expand Up @@ -2134,13 +2134,13 @@ void encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));

assert(buf.back != replacementDchar);
encode!(UseReplacementDchar.yes)(buf, cast(dchar)0x110000);
encode!(Yes.useReplacementDchar)(buf, cast(dchar)0x110000);
assert(buf.back == replacementDchar);
});
}

/// ditto
void encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
ref wchar[] str, dchar c) @safe pure
{
wchar[] r = str;
Expand Down Expand Up @@ -2195,13 +2195,13 @@ void encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));

assert(buf.back != replacementDchar);
encode!(UseReplacementDchar.yes)(buf, cast(dchar)0x110000);
encode!(Yes.useReplacementDchar)(buf, cast(dchar)0x110000);
assert(buf.back == replacementDchar);
});
}

/// ditto
void encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
ref dchar[] str, dchar c) @safe pure
{
if ((0xD800 <= c && c <= 0xDFFF) || 0x10FFFF < c)
Expand Down Expand Up @@ -2232,7 +2232,7 @@ void encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));

assert(buf.back != replacementDchar);
encode!(UseReplacementDchar.yes)(buf, cast(dchar)0x110000);
encode!(Yes.useReplacementDchar)(buf, cast(dchar)0x110000);
assert(buf.back == replacementDchar);
});
}
Expand Down Expand Up @@ -3597,13 +3597,13 @@ template byUTF(C) if (isSomeChar!C)
{
static if (is(RC == dchar))
{
fill = cast(ushort) encode!(UseReplacementDchar.yes)(buf, c);
fill = cast(ushort) encode!(Yes.useReplacementDchar)(buf, c);
r.popFront;
}
else
{
fill = cast(ushort) encode!(UseReplacementDchar.yes)(
buf, decodeFront!(UseReplacementDchar.yes)(r));
fill = cast(ushort) encode!(Yes.useReplacementDchar)(
buf, decodeFront!(Yes.useReplacementDchar)(r));
}
}
}
Expand Down