summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2021-05-15 13:31:41 +0200
committerEugen Wissner <belka@caraus.de>2021-05-15 13:31:47 +0200
commit2c21dc34296ad9eeadae45b96a1e07853dbae84f (patch)
treec3232bc36cc406f60642eb2142d789df3c90b809
parentf0d8c616bb574353b2cfd81a1df91493e0accdab (diff)
downloadtanya-2c21dc34296ad9eeadae45b96a1e07853dbae84f.tar.gz
Replace the ascii module with std.ascii
-rw-r--r--README.md3
-rw-r--r--dub.json2
-rw-r--r--encoding/dub.json17
-rw-r--r--encoding/tanya/encoding/ascii.d501
-rw-r--r--encoding/tanya/encoding/package.d17
-rw-r--r--source/tanya/format.d2
-rw-r--r--source/tanya/net/ip.d2
-rw-r--r--source/tanya/net/uri.d2
8 files changed, 3 insertions, 543 deletions
diff --git a/README.md b/README.md
index c0bafe2..e58cd04 100644
--- a/README.md
+++ b/README.md
@@ -26,10 +26,7 @@ Tanya consists of the following packages and (top-level) modules:
string, Set, Hash table.
* `conv`: This module provides functions for converting between different
types.
-* `encoding`: This package provides tools to work with text encodings.
* `format`: Formatting and conversion functions.
-* `functional`: Functions that manipulate other functions and their argument
-lists.
* `hash`: Hash algorithms.
* `math`: Arbitrary precision integer and a set of functions.
* `memory`: Tools for manual memory management (allocators, smart pointers).
diff --git a/dub.json b/dub.json
index 7f21d7d..3b652b9 100644
--- a/dub.json
+++ b/dub.json
@@ -12,7 +12,6 @@
"dependencies": {
"tanya:meta": "*",
"tanya:os": "*",
- "tanya:encoding": "*",
"tanya:middle": "*",
"tanya:test": "*"
},
@@ -24,7 +23,6 @@
"subPackages": [
"./meta",
"./os",
- "./encoding",
"./middle",
"./test"
],
diff --git a/encoding/dub.json b/encoding/dub.json
deleted file mode 100644
index 717656e..0000000
--- a/encoding/dub.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "name": "encoding",
- "description": "This package provides tools to work with text encodings",
- "targetType": "library",
-
- "dependencies": {
- "tanya:meta": "*"
- },
-
- "sourcePaths": [
- "."
- ],
- "importPaths": [
- "."
- ],
- "dflags-dmd": ["-dip1000"]
-}
diff --git a/encoding/tanya/encoding/ascii.d b/encoding/tanya/encoding/ascii.d
deleted file mode 100644
index f09da56..0000000
--- a/encoding/tanya/encoding/ascii.d
+++ /dev/null
@@ -1,501 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Functions operating on ASCII characters.
- *
- * ASCII is $(B A)merican $(B S)tandard $(B C)ode for $(B I)nformation
- * $(B I)nterchange.
- *
- * Copyright: Eugene Wissner 2017-2020.
- * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
- * Mozilla Public License, v. 2.0).
- * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
- * Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/encoding/tanya/encoding/ascii.d,
- * tanya/encoding/ascii.d)
- */
-module tanya.encoding.ascii;
-
-import tanya.meta.trait;
-
-immutable string fullHexDigits = "0123456789ABCDEFabcdef"; /// 0..9A..Fa..f.
-immutable string hexDigits = "0123456789ABCDEF"; /// 0..9A..F.
-immutable string lowerHexDigits = "0123456789abcdef"; /// 0..9a..f.
-immutable string digits = "0123456789"; /// 0..9.
-immutable string octalDigits = "01234567"; /// 0..7.
-
-/// A..Za..z.
-immutable string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-
-immutable string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; /// A..Z.
-immutable string lowercase = "abcdefghijklmnopqrstuvwxyz"; /// a..z.
-
-/**
- * Whitespace, Horizontal Tab (HT), Line Feed (LF), Carriage Return (CR),
- * Vertical Tab (VT) or Form Feed (FF).
- */
-immutable string whitespace = "\t\n\v\f\r ";
-
-/// Letter case specifier.
-enum LetterCase : bool
-{
- upper, /// Uppercase.
- lower, /// Lowercase.
-}
-
-/**
- * Checks for an uppecase alphabetic character.
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: $(D_KEYWORD true) if $(D_PARAM c) is an uppercase alphabetic
- * character, $(D_KEYWORD false) otherwise.
- */
-bool isUpper(C)(C c)
-if (isSomeChar!C)
-{
- return (c >= 'A') && (c <= 'Z');
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(isUpper('A'));
- assert(isUpper('Z'));
- assert(isUpper('L'));
- assert(!isUpper('a'));
- assert(!isUpper('!'));
-}
-
-/**
- * Checks for a lowercase alphabetic character.
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: $(D_KEYWORD true) if $(D_PARAM c) is a lowercase alphabetic
- * character, $(D_KEYWORD false) otherwise.
- */
-bool isLower(C)(C c)
-if (isSomeChar!C)
-{
- return (c >= 'a') && (c <= 'z');
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(isLower('a'));
- assert(isLower('z'));
- assert(isLower('l'));
- assert(!isLower('A'));
- assert(!isLower('!'));
-}
-
-/**
- * Checks for an alphabetic character (upper- or lowercase).
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: $(D_KEYWORD true) if $(D_PARAM c) is an alphabetic character,
- * $(D_KEYWORD false) otherwise.
- */
-bool isAlpha(C)(C c)
-if (isSomeChar!C)
-{
- return isUpper(c) || isLower(c);
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(isAlpha('A'));
- assert(isAlpha('Z'));
- assert(isAlpha('L'));
- assert(isAlpha('a'));
- assert(isAlpha('z'));
- assert(isAlpha('l'));
- assert(!isAlpha('!'));
-}
-
-/**
- * Checks for a digit.
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: $(D_KEYWORD true) if $(D_PARAM c) is a digit,
- * $(D_KEYWORD false) otherwise.
- */
-bool isDigit(C)(C c)
-if (isSomeChar!C)
-{
- return (c >= '0') && (c <= '9');
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(isDigit('0'));
- assert(isDigit('1'));
- assert(isDigit('2'));
- assert(isDigit('3'));
- assert(isDigit('4'));
- assert(isDigit('5'));
- assert(isDigit('6'));
- assert(isDigit('7'));
- assert(isDigit('8'));
- assert(isDigit('9'));
- assert(!isDigit('a'));
- assert(!isDigit('!'));
-}
-
-/**
- * Checks for an alphabetic character (upper- or lowercase) or a digit.
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: $(D_KEYWORD true) if $(D_PARAM c) is an alphabetic character or a
- * digit, $(D_KEYWORD false) otherwise.
- */
-bool isAlphaNum(C)(C c)
-if (isSomeChar!C)
-{
- return isAlpha(c) || isDigit(c);
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(isAlphaNum('0'));
- assert(isAlphaNum('1'));
- assert(isAlphaNum('9'));
- assert(isAlphaNum('A'));
- assert(isAlphaNum('Z'));
- assert(isAlphaNum('L'));
- assert(isAlphaNum('a'));
- assert(isAlphaNum('z'));
- assert(isAlphaNum('l'));
- assert(!isAlphaNum('!'));
-}
-
-/**
- * Checks for a 7-bit ASCII character.
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: $(D_KEYWORD true) if $(D_PARAM c) is an ASCII character,
- * $(D_KEYWORD false) otherwise.
- */
-bool isASCII(C)(C c)
-if (isSomeChar!C)
-{
- return c < 128;
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(isASCII('0'));
- assert(isASCII('L'));
- assert(isASCII('l'));
- assert(isASCII('!'));
- assert(!isASCII('©'));
- assert(!isASCII('§'));
- assert(!isASCII(char.init)); // 0xFF
- assert(!isASCII(wchar.init)); // 0xFFFF
- assert(!isASCII(dchar.init)); // 0xFFFF
-}
-
-/**
- * Checks for a control character.
- *
- * Control characters are non-printable characters. Their ASCII codes are those
- * between 0x00 (NUL) and 0x1f (US), and 0x7f (DEL).
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: $(D_KEYWORD true) if $(D_PARAM c) is a control character,
- * $(D_KEYWORD false) otherwise.
- *
- * See_Also: $(D_PSYMBOL isPrintable), $(D_PSYMBOL isGraphical).
- */
-bool isControl(C)(C c)
-if (isSomeChar!C)
-{
- return (c <= 0x1f) || (c == 0x7f);
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(isControl('\t'));
- assert(isControl('\0'));
- assert(isControl('\u007f'));
- assert(!isControl(' '));
- assert(!isControl('a'));
- assert(!isControl(char.init)); // 0xFF
- assert(!isControl(wchar.init)); // 0xFFFF
-}
-
-/**
- * Checks for a whitespace character.
- *
- * Whitespace characters are:
- *
- * $(UL
- * $(LI Whitespace)
- * $(LI Horizontal Tab (HT))
- * $(LI Line Feed (LF))
- * $(LI Carriage Return (CR))
- * $(LI Vertical Tab (VT))
- * $(LI Form Feed (FF))
- * )
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: $(D_KEYWORD true) if $(D_PARAM c) is a whitespace character,
- * $(D_KEYWORD false) otherwise.
- *
- * See_Also: $(D_PSYMBOL whitespace).
- */
-bool isWhite(C)(C c)
-if (isSomeChar!C)
-{
- return ((c >= 0x09) && (c <= 0x0d)) || (c == 0x20);
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(isWhite('\t'));
- assert(isWhite('\n'));
- assert(isWhite('\v'));
- assert(isWhite('\f'));
- assert(isWhite('\r'));
- assert(isWhite(' '));
-}
-
-/**
- * Checks for a graphical character.
- *
- * Graphical characters are printable characters but whitespace characters.
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: $(D_KEYWORD true) if $(D_PARAM c) is a control character,
- * $(D_KEYWORD false) otherwise.
- *
- * See_Also: $(D_PSYMBOL isControl), $(D_PSYMBOL isWhite).
- */
-bool isGraphical(C)(C c)
-if (isSomeChar!C)
-{
- return (c > 0x20) && (c < 0x7f);
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(isGraphical('a'));
- assert(isGraphical('0'));
- assert(!isGraphical('\u007f'));
- assert(!isGraphical('§'));
- assert(!isGraphical('\n'));
- assert(!isGraphical(' '));
-}
-
-/**
- * Checks for a printable character.
- *
- * This is the opposite of a control character.
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: $(D_KEYWORD true) if $(D_PARAM c) is a control character,
- * $(D_KEYWORD false) otherwise.
- *
- * See_Also: $(D_PSYMBOL isControl).
- */
-bool isPrintable(C)(C c)
-if (isSomeChar!C)
-{
- return (c >= 0x20) && (c < 0x7f);
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(isPrintable('a'));
- assert(isPrintable('0'));
- assert(!isPrintable('\u007f'));
- assert(!isPrintable('§'));
- assert(!isPrintable('\n'));
- assert(isPrintable(' '));
-}
-
-/**
- * Checks for a hexadecimal digit.
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: $(D_KEYWORD true) if $(D_PARAM c) is a hexadecimal digit,
- * $(D_KEYWORD false) otherwise.
- */
-bool isHexDigit(C)(C c)
-if (isSomeChar!C)
-{
- return ((c >= '0') && (c <= '9'))
- || ((c >= 'a') && (c <= 'f'))
- || ((c >= 'A') && (c <= 'F'));
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(isHexDigit('0'));
- assert(isHexDigit('1'));
- assert(isHexDigit('8'));
- assert(isHexDigit('9'));
- assert(isHexDigit('A'));
- assert(isHexDigit('F'));
- assert(!isHexDigit('G'));
- assert(isHexDigit('a'));
- assert(isHexDigit('f'));
- assert(!isHexDigit('g'));
-}
-
-/**
- * Checks for an octal character.
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: $(D_KEYWORD true) if $(D_PARAM c) is an octal character,
- * $(D_KEYWORD false) otherwise.
- */
-bool isOctalDigit(C)(C c)
-if (isSomeChar!C)
-{
- return (c >= '0') && (c <= '7');
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(isOctalDigit('0'));
- assert(isOctalDigit('1'));
- assert(isOctalDigit('2'));
- assert(isOctalDigit('3'));
- assert(isOctalDigit('4'));
- assert(isOctalDigit('5'));
- assert(isOctalDigit('6'));
- assert(isOctalDigit('7'));
- assert(!isOctalDigit('8'));
-}
-
-/**
- * Checks for a octal character.
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: $(D_KEYWORD true) if $(D_PARAM c) is a octal character,
- * $(D_KEYWORD false) otherwise.
- */
-bool isPunctuation(C)(C c)
-if (isSomeChar!C)
-{
- return ((c >= 0x21) && (c <= 0x2f))
- || ((c >= 0x3a) && (c <= 0x40))
- || ((c >= 0x5b) && (c <= 0x60))
- || ((c >= 0x7b) && (c <= 0x7e));
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(isPunctuation('!'));
- assert(isPunctuation(':'));
- assert(isPunctuation('\\'));
- assert(isPunctuation('|'));
- assert(!isPunctuation('0'));
- assert(!isPunctuation(' '));
-}
-
-/**
- * Converts $(D_PARAM c) to uppercase.
- *
- * If $(D_PARAM c) is not a lowercase character, $(D_PARAM c) is returned
- * unchanged.
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: The lowercase of $(D_PARAM c) if available, just $(D_PARAM c)
- * otherwise.
- */
-C toUpper(C)(C c)
-if (isSomeChar!C)
-{
- return isLower(c) ? (cast(C) (c - 32)) : c;
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(toUpper('a') == 'A');
- assert(toUpper('A') == 'A');
- assert(toUpper('!') == '!');
-}
-
-/**
- * Converts $(D_PARAM c) to lowercase.
- *
- * If $(D_PARAM c) is not an uppercase character, $(D_PARAM c) is returned
- * unchanged.
- *
- * Params:
- * C = Some character type.
- * c = Some character.
- *
- * Returns: The uppercase of $(D_PARAM c) if available, just $(D_PARAM c)
- * otherwise.
- */
-C toLower(C)(C c)
-if (isSomeChar!C)
-{
- return isUpper(c) ? (cast(C) (c + 32)) : c;
-}
-
-///
-@nogc nothrow pure @safe unittest
-{
- assert(toLower('A') == 'a');
- assert(toLower('a') == 'a');
- assert(toLower('!') == '!');
-}
diff --git a/encoding/tanya/encoding/package.d b/encoding/tanya/encoding/package.d
deleted file mode 100644
index 75642f0..0000000
--- a/encoding/tanya/encoding/package.d
+++ /dev/null
@@ -1,17 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * This package provides tools to work with text encodings.
- *
- * Copyright: Eugene Wissner 2017-2020.
- * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
- * Mozilla Public License, v. 2.0).
- * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
- * Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/encoding/tanya/encoding/package.d,
- * tanya/encoding/package.d)
- */
-module tanya.encoding;
-
-public import tanya.encoding.ascii;
diff --git a/source/tanya/format.d b/source/tanya/format.d
index 0e349e3..32249a7 100644
--- a/source/tanya/format.d
+++ b/source/tanya/format.d
@@ -48,8 +48,8 @@
module tanya.format;
import std.algorithm.comparison;
+import std.ascii;
import tanya.container.string;
-import tanya.encoding.ascii;
import tanya.math;
static import tanya.memory.op;
import tanya.meta.metafunction;
diff --git a/source/tanya/net/ip.d b/source/tanya/net/ip.d
index 21e35d9..c4a5b53 100644
--- a/source/tanya/net/ip.d
+++ b/source/tanya/net/ip.d
@@ -15,12 +15,12 @@
module tanya.net.ip;
import std.algorithm.comparison;
+import std.ascii;
import std.typecons;
import tanya.algorithm.iteration;
import tanya.algorithm.mutation;
import tanya.container.string;
import tanya.conv;
-import tanya.encoding.ascii;
import tanya.format;
import tanya.memory.lifetime;
import tanya.meta.trait;
diff --git a/source/tanya/net/uri.d b/source/tanya/net/uri.d
index be48528..419b486 100644
--- a/source/tanya/net/uri.d
+++ b/source/tanya/net/uri.d
@@ -14,8 +14,8 @@
*/
module tanya.net.uri;
+import std.ascii;
import tanya.conv;
-import tanya.encoding.ascii;
import tanya.memory.allocator;
/**