Remove new templates

This commit is contained in:
Jack Stouffer 2016-07-22 14:22:14 -04:00
parent 2c928a2d54
commit 7134932984

View file

@ -378,15 +378,15 @@ template EncoderFunctions()
template ReadFromString() template ReadFromString()
{ {
@property bool canRead() { return s.length != 0; } @property bool canRead() { return s.length != 0; }
E peek()() { return s[0]; } E peek() @safe pure @nogc nothrow { return s[0]; }
E read()() { E t = s[0]; s = s[1..$]; return t; } E read() @safe pure @nogc nothrow { E t = s[0]; s = s[1..$]; return t; }
} }
template ReverseReadFromString() template ReverseReadFromString()
{ {
@property bool canRead() { return s.length != 0; } @property bool canRead() { return s.length != 0; }
E peek()() { return s[$-1]; } E peek() @safe pure @nogc nothrow { return s[$-1]; }
E read()() { E t = s[$-1]; s = s[0..$-1]; return t; } E read() @safe pure @nogc nothrow { E t = s[$-1]; s = s[0..$-1]; return t; }
} }
// Various forms of Write // Various forms of Write
@ -394,17 +394,17 @@ template EncoderFunctions()
template WriteToString() template WriteToString()
{ {
E[] s; E[] s;
void write()(E c) { s ~= c; } void write(E c) @safe pure nothrow { s ~= c; }
} }
template WriteToArray() template WriteToArray()
{ {
void write()(E c) { array[0] = c; array = array[1..$]; } void write(E c) @safe pure @nogc nothrow { array[0] = c; array = array[1..$]; }
} }
template WriteToDelegate() template WriteToDelegate()
{ {
void write()(E c) { dg(c); } void write(E c) { dg(c); }
} }
// Functions we will export // Functions we will export
@ -412,31 +412,31 @@ template EncoderFunctions()
template EncodeViaWrite() template EncodeViaWrite()
{ {
mixin encodeViaWrite; mixin encodeViaWrite;
void encode()(dchar c) { encodeViaWrite(c); } void encode(dchar c) { encodeViaWrite(c); }
} }
template SkipViaRead() template SkipViaRead()
{ {
mixin skipViaRead; mixin skipViaRead;
void skip()() { skipViaRead(); } void skip() @safe pure @nogc nothrow { skipViaRead(); }
} }
template DecodeViaRead() template DecodeViaRead()
{ {
mixin decodeViaRead; mixin decodeViaRead;
dchar decode()() { return decodeViaRead(); } dchar decode() @safe pure @nogc nothrow { return decodeViaRead(); }
} }
template SafeDecodeViaRead() template SafeDecodeViaRead()
{ {
mixin safeDecodeViaRead; mixin safeDecodeViaRead;
dchar safeDecode()() { return safeDecodeViaRead(); } dchar safeDecode() @safe pure @nogc nothrow { return safeDecodeViaRead(); }
} }
template DecodeReverseViaRead() template DecodeReverseViaRead()
{ {
mixin decodeReverseViaRead; mixin decodeReverseViaRead;
dchar decodeReverse()() { return decodeReverseViaRead(); } dchar decodeReverse() @safe pure @nogc nothrow { return decodeReverseViaRead(); }
} }
// Encoding to different destinations // Encoding to different destinations
@ -489,26 +489,26 @@ template EncoderFunctions()
// Below are the functions we will ultimately expose to the user // Below are the functions we will ultimately expose to the user
E[] encode()(dchar c) E[] encode(dchar c) @safe pure nothrow
{ {
mixin EncodeToString e; mixin EncodeToString e;
e.encode(c); e.encode(c);
return e.s; return e.s;
} }
void encode()(dchar c, ref E[] array) void encode(dchar c, ref E[] array) @safe pure nothrow
{ {
mixin EncodeToArray e; mixin EncodeToArray e;
e.encode(c); e.encode(c);
} }
void encode()(dchar c, void delegate(E) dg) void encode(dchar c, void delegate(E) dg)
{ {
mixin EncodeToDelegate e; mixin EncodeToDelegate e;
e.encode(c); e.encode(c);
} }
void skip()(ref const(E)[] s) void skip(ref const(E)[] s) @safe pure nothrow
{ {
mixin SkipFromString e; mixin SkipFromString e;
e.skip(); e.skip();
@ -526,7 +526,7 @@ template EncoderFunctions()
return e.safeDecode(); return e.safeDecode();
} }
dchar decodeReverse()(ref const(E)[] s) dchar decodeReverse(ref const(E)[] s) @safe pure nothrow
{ {
mixin DecodeReverseFromString e; mixin DecodeReverseFromString e;
return e.decodeReverse(); return e.decodeReverse();
@ -650,7 +650,7 @@ template EncoderInstance(E)
private template GenericEncoder() private template GenericEncoder()
{ {
bool canEncode()(dchar c) bool canEncode(dchar c) @safe pure @nogc nothrow
{ {
if (c < m_charMapStart || (c > m_charMapEnd && c < 0x100)) return true; if (c < m_charMapStart || (c > m_charMapEnd && c < 0x100)) return true;
if (c >= 0xFFFD) return false; if (c >= 0xFFFD) return false;
@ -665,13 +665,13 @@ private template GenericEncoder()
return false; return false;
} }
bool isValidCodeUnit()(E c) bool isValidCodeUnit(E c) @safe pure @nogc nothrow
{ {
if (c < m_charMapStart || c > m_charMapEnd) return true; if (c < m_charMapStart || c > m_charMapEnd) return true;
return charMap[c-m_charMapStart] != 0xFFFD; return charMap[c-m_charMapStart] != 0xFFFD;
} }
size_t encodedLength()(dchar c) size_t encodedLength(dchar c) @safe pure @nogc nothrow
in in
{ {
assert(canEncode(c)); assert(canEncode(c));
@ -726,7 +726,7 @@ private template GenericEncoder()
return (c >= m_charMapStart && c <= m_charMapEnd) ? charMap[c-m_charMapStart] : c; return (c >= m_charMapStart && c <= m_charMapEnd) ? charMap[c-m_charMapStart] : c;
} }
@property EString replacementSequence()() @property EString replacementSequence() @safe pure @nogc nothrow
{ {
return cast(EString)("?"); return cast(EString)("?");
} }
@ -1389,17 +1389,17 @@ template EncoderInstance(CharType : dchar)
return "UTF-32"; return "UTF-32";
} }
bool canEncode()(dchar c) bool canEncode(dchar c) @safe pure @nogc nothrow
{ {
return isValidCodePoint(c); return isValidCodePoint(c);
} }
bool isValidCodeUnit()(dchar c) bool isValidCodeUnit(dchar c) @safe pure @nogc nothrow
{ {
return isValidCodePoint(c); return isValidCodePoint(c);
} }
size_t encodedLength()(dchar c) size_t encodedLength(dchar c) @safe pure @nogc nothrow
in in
{ {
assert(canEncode(c)); assert(canEncode(c));
@ -2462,7 +2462,7 @@ abstract class EncodingScheme
* Params: * Params:
* s = the array to be tested * s = the array to be tested
*/ */
bool isValid()(const(ubyte)[] s) bool isValid(const(ubyte)[] s)
{ {
while (s.length != 0) while (s.length != 0)
{ {