Mercurial > projects > qtd
comparison 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 |
comparison
equal
deleted
inserted
replaced
349:925386e0e780 | 350:31520b2c0b3c |
---|---|
9 * | 9 * |
10 */ | 10 */ |
11 | 11 |
12 module qtd.Str; | 12 module qtd.Str; |
13 | 13 |
14 import core.stdc.string; | |
14 import std.utf : toUTF8; | 15 import std.utf : toUTF8; |
15 | |
16 version(D_Version2) { | |
17 // private import core.sys.posix.stdio; | |
18 private import core.stdc.string; | |
19 | |
20 version = druntime; | |
21 } | |
22 | 16 |
23 alias immutable(char)* stringz; | 17 alias immutable(char)* stringz; |
24 alias const(char)* cstringz; | 18 alias const(char)* cstringz; |
25 | 19 |
26 public static char** toStringzArray(string[] args) | 20 /** |
21 */ | |
22 static char** toStringzArray(string[] args) | |
27 { | 23 { |
28 if ( args is null ) | 24 if ( args is null ) |
29 { | 25 { |
30 return null; | 26 return null; |
31 } | 27 } |
38 argv[argc] = null; | 34 argv[argc] = null; |
39 | 35 |
40 return argv; | 36 return argv; |
41 } | 37 } |
42 | 38 |
43 public string fromStringz(const (char) *s) | 39 /** |
40 */ | |
41 bool isDigit(char s) | |
42 { | |
43 return (s >= '0' && s <= '9'); | |
44 } | |
45 | |
46 /** | |
47 */ | |
48 bool isOctalChar(char s) | |
49 { | |
50 return (s >= '0' && s <= '7'); | |
51 } | |
52 | |
53 /** | |
54 */ | |
55 bool isHexChar(char s) | |
56 { | |
57 return ((s >= 'a' && s <= 'f') | |
58 || (s >= 'A' && s <= 'F') | |
59 || (s >= '0' && s <= '9') | |
60 ); | |
61 } | |
62 | |
63 /** | |
64 */ | |
65 string fromStringz(const (char) *s) | |
44 { | 66 { |
45 return s ? s[0 .. strlen(s)].idup : cast(string)null; | 67 return s ? s[0 .. strlen(s)].idup : cast(string)null; |
46 } | 68 } |
47 | |
48 | 69 |
49 extern(C) void qtd_toUtf8(wchar* arr, uint size, string* str) | 70 extern(C) void qtd_toUtf8(wchar* arr, uint size, string* str) |
50 { | 71 { |
51 *str = toUTF8(arr[0..size]); | 72 *str = toUTF8(arr[0..size]); |
52 } | 73 } |