Mercurial > projects > qtd
diff d2/qtd/Str.d @ 350:31520b2c0b3c
Removed dependency on parent trait and stringof
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Thu, 20 May 2010 15:49:08 +0300 |
parents | 96a75b1e5b26 |
children |
line wrap: on
line diff
--- a/d2/qtd/Str.d Mon May 17 21:48:15 2010 +0300 +++ b/d2/qtd/Str.d Thu May 20 15:49:08 2010 +0300 @@ -11,19 +11,15 @@ module qtd.Str; +import core.stdc.string; import std.utf : toUTF8; -version(D_Version2) { -// private import core.sys.posix.stdio; - private import core.stdc.string; - - version = druntime; -} - alias immutable(char)* stringz; alias const(char)* cstringz; -public static char** toStringzArray(string[] args) +/** + */ +static char** toStringzArray(string[] args) { if ( args is null ) { @@ -40,12 +36,37 @@ return argv; } -public string fromStringz(const (char) *s) +/** + */ +bool isDigit(char s) +{ + return (s >= '0' && s <= '9'); +} + +/** + */ +bool isOctalChar(char s) +{ + return (s >= '0' && s <= '7'); +} + +/** + */ +bool isHexChar(char s) +{ + return ((s >= 'a' && s <= 'f') + || (s >= 'A' && s <= 'F') + || (s >= '0' && s <= '9') + ); +} + +/** + */ +string fromStringz(const (char) *s) { return s ? s[0 .. strlen(s)].idup : cast(string)null; } - extern(C) void qtd_toUtf8(wchar* arr, uint size, string* str) { *str = toUTF8(arr[0..size]);