Skip to content
This repository
Browse code

Removed class String from Core.

  • Loading branch information...
commit c8e8d5d6b7d3739d6400514dc849166c63a0eff6 1 parent 8d0f2de
Dave Wilkinson II authored

Showing 79 changed files with 2,919 additions and 5,119 deletions. Show diff stats Hide diff stats

  1. +2 2 Makefile
  2. +4 4 analyzing/debugger.d
  3. +44 51 console/prompt.d
  4. +1 1  core/arguments.d
  5. +0 4 core/exception.d
  6. +2 15 core/library.d
  7. +1 1  core/list.d
  8. +2 2 core/locales/en_us.d
  9. +2 2 core/locales/fr_fr.d
  10. +37 58 core/regex.d
  11. +0 21 core/stream.d
  12. +677 958 core/string.d
  13. +12 13 core/time.d
  14. +3 4 core/timezone.d
  15. +0 560 core/tostring.d
  16. +202 73 core/variant.d
  17. +1 1  djehuty.d
  18. +3 3 examples/Snake/win.d
  19. +1 1  examples/TuiTetris/gamewindow.d
  20. +0 50 graphics/graphics.d
  21. +5 18 gui/button.d
  22. +33 45 gui/listbox.d
  23. +29 33 gui/listfield.d
  24. +32 44 gui/textfield.d
  25. +5 15 gui/togglefield.d
  26. +9 75 gui/window.d
  27. +4 8 hashes/digest.d
  28. +1 9 hashes/md5.d
  29. +0 8 hashes/sha1.d
  30. +0 8 hashes/sha224.d
  31. +0 8 hashes/sha256.d
  32. +0 10 interfaces/mod.d
  33. +10 11 io/console.d
  34. +4 25 io/socket.d
  35. +2 4 math/currency.d
  36. +1 3 math/fixed.d
  37. +1 2  math/integer.d
  38. +0 1  math/vector.d
  39. +2 3 networking/http.d
  40. +14 17 networking/irc.d
  41. +0 14 networking/telnet.d
  42. +0 4 opengl/window.d
  43. +0 1  parsing/ast.d
  44. +13 41 parsing/cfg.d
  45. +11 11 parsing/d/lexer.d
  46. +27 28 parsing/options.d
  47. +0 1  parsing/parseunit.d
  48. +1 1  platform/unix/main.d
  49. +2 2 platform/unix/scaffold/console.d
  50. +0 1  platform/unix/scaffold/directory.d
  51. +13 155 platform/unix/scaffold/graphics.d
  52. +2 2 platform/unix/scaffold/menu.d
  53. +4 6 platform/unix/scaffold/socket.d
  54. +4 4 platform/unix/scaffold/system.d
  55. +4 4 platform/unix/scaffold/window.d
  56. +10 38 resource/menu.d
  57. +4 4 resource/sound.d
  58. +8 25 scripting/lua.d
  59. +5 31 specs/core/exception.d
  60. +21 21 specs/core/regex.d
  61. +0 220 specs/core/string.d
  62. +65 0 specs/core/variant.d
  63. +4 4 specs/hashes/digest.d
  64. +4 9 specs/hashes/md5.d
  65. +2 7 specs/hashes/sha1.d
  66. +2 7 specs/hashes/sha224.d
  67. +2 7 specs/hashes/sha256.d
  68. +1,464 2,141 specs/test.d
  69. +4 4 tools/dspec/output.d
  70. +4 4 tui/codebox.d
  71. +6 10 tui/container.d
  72. +6 24 tui/label.d
  73. +26 26 tui/listbox.d
  74. +23 22 tui/textbox.d
  75. +9 9 tui/textfield.d
  76. +5 12 tui/widget.d
  77. +9 17 tui/window.d
  78. +1 4 utils/linkedlist.d
  79. +8 27 winsamp.d
4 Makefile
@@ -38,7 +38,7 @@ DFILES_PLATFORM_WIN = binding/win32/gdipluscolormatrix.d binding/win32/gdiplusin
38 38 DFILES_PLATFORM_XOMB = platform/xomb/main.d platform/xomb/common.d platform/xomb/scaffold.d platform/xomb/vars.d platform/xomb/console.d platform/xomb/definitions.d platform/xomb/scaffolds/wave.d platform/xomb/scaffolds/graphics.d platform/xomb/scaffolds/thread.d platform/xomb/scaffolds/menu.d platform/xomb/scaffolds/window.d platform/xomb/scaffolds/view.d platform/xomb/scaffolds/color.d platform/xomb/scaffolds/file.d platform/xomb/scaffolds/socket.d platform/xomb/scaffolds/app.d platform/xomb/scaffolds/time.d platform/xomb/oscontrolinterface.d
39 39
40 40 DFILES_ANALYZING = analyzing/debugger.d
41   -DFILES_CORE = core/tostring.d core/locales/en_us.d core/locales/fr_fr.d core/date.d core/locale.d core/variant.d core/list.d core/exception.d core/event.d core/library.d core/system.d core/random.d core/regex.d core/arguments.d core/definitions.d core/application.d core/time.d core/timezone.d core/unicode.d core/endian.d core/stream.d core/string.d core/main.d core/color.d
  41 +DFILES_CORE = core/locales/en_us.d core/locales/fr_fr.d core/date.d core/locale.d core/variant.d core/list.d core/exception.d core/event.d core/library.d core/system.d core/random.d core/regex.d core/arguments.d core/definitions.d core/application.d core/time.d core/timezone.d core/unicode.d core/endian.d core/stream.d core/string.d core/main.d core/color.d
42 42 DFILES_GUI = gui/container.d gui/trackbar.d gui/radiogroup.d gui/progressbar.d gui/togglefield.d gui/listfield.d gui/listbox.d gui/vscrollbar.d gui/hscrollbar.d gui/button.d gui/textfield.d gui/window.d gui/widget.d gui/application.d
43 43 DFILES_UTILS = utils/stack.d utils/linkedlist.d utils/fibonacci.d utils/heap.d
44 44 DFILES_PARSING = parsing/d/trees.d parsing/d/addexprunit.d parsing/d/andexprunit.d parsing/d/assignexprunit.d parsing/d/blockstmtunit.d parsing/d/switchstmtunit.d parsing/d/casestmtunit.d parsing/d/defaultstmtunit.d parsing/d/breakstmtunit.d parsing/d/continuestmtunit.d parsing/d/gotostmtunit.d parsing/d/returnstmtunit.d parsing/d/volatilestmtunit.d parsing/d/throwstmtunit.d parsing/d/postfixexprlistunit.d parsing/d/cmpexprunit.d parsing/d/conditionalexprunit.d parsing/d/declarationunit.d parsing/d/expressionunit.d parsing/d/importdeclunit.d parsing/d/isexprunit.d parsing/d/lexer.d parsing/d/logicalandexprunit.d parsing/d/logicalorexprunit.d parsing/d/moduledeclunit.d parsing/d/moduleunit.d parsing/d/mulexprunit.d parsing/d/nodes.d parsing/d/orexprunit.d parsing/d/parser.d parsing/d/postfixexprunit.d parsing/d/primaryexprunit.d parsing/d/shiftexprunit.d parsing/d/staticunit.d parsing/d/declaratorunit.d parsing/d/declaratorsuffixunit.d parsing/d/declaratortypeunit.d parsing/d/tokens.d parsing/d/enumdeclunit.d parsing/d/typeunit.d parsing/d/enumbodyunit.d parsing/d/aggregatedeclunit.d parsing/d/aggregatebodyunit.d parsing/d/classbodyunit.d parsing/d/templatebodyunit.d parsing/d/interfacebodyunit.d parsing/d/classdeclunit.d parsing/d/interfacedeclunit.d parsing/d/constructorunit.d parsing/d/destructorunit.d parsing/d/parameterlistunit.d parsing/d/functionbodyunit.d parsing/d/staticifunit.d parsing/d/versionunit.d parsing/d/debugunit.d parsing/d/unittestunit.d parsing/d/parameterunit.d parsing/d/basictypeunit.d parsing/d/statementunit.d parsing/d/pragmastmtunit.d parsing/d/staticassertunit.d parsing/d/foreachstmtunit.d parsing/d/scopedstmtunit.d parsing/d/forstmtunit.d parsing/d/typedeclarationunit.d parsing/d/unaryexprunit.d parsing/d/xorexprunit.d parsing/ast.d parsing/lexer.d parsing/token.d parsing/parser.d parsing/options.d parsing/cfg.d parsing/parseunit.d
@@ -56,7 +56,7 @@ DFILES_CONSOLE = console/prompt.d
56 56 DFILES_TUI = tui/filebox.d tui/container.d tui/dialog.d tui/window.d tui/application.d tui/widget.d tui/telnet.d tui/buffer.d tui/vt100.d tui/listbox.d tui/textfield.d tui/label.d tui/textbox.d tui/codebox.d tui/tabbox.d
57 57 DFILES_SCRIPTING = scripting/lua.d
58 58 DFILES_BINDING = binding/opengl/gl.d binding/opengl/glu.d binding/lua.d
59   -DFILES_INTERFACES = interfaces/container.d interfaces/mod.d
  59 +DFILES_INTERFACES = interfaces/container.d
60 60 DFILES_MATH = math/currency.d math/fixed.d math/integer.d math/common.d math/vector.d math/matrix.d math/mathobject.d
61 61 DFILES_OPENGL = opengl/window.d opengl/texture.d opengl/light.d
62 62 DFILES_SPECS = specs/test.d
8 analyzing/debugger.d
@@ -69,17 +69,17 @@ public:
69 69 if (w !is null) {
70 70 // get class name
71 71 ClassInfo ci = w.classinfo;
72   - String className = new String(ci.name);
  72 + string className = ci.name.dup;
73 73
74   - Console.putln(" window: ", className.array, " [", w.text.array, "]");
  74 + Console.putln(" window: ", className, " [", w.text, "]");
75 75 }
76 76
77 77 if (t !is null) {
78 78 // get class name
79 79 ClassInfo ci = t.classinfo;
80   - String className = new String(ci.name);
  80 + string className = ci.name.dup;
81 81
82   - Console.putln(" thread: ", className.array);
  82 + Console.putln(" thread: ", className);
83 83 }
84 84
85 85 Console.setColor(fgColor.White);
95 console/prompt.d
... ... @@ -1,6 +1,7 @@
1 1 module console.prompt;
2 2
3 3 import core.string;
  4 +import core.unicode;
4 5
5 6 import io.console;
6 7
@@ -14,25 +15,19 @@ import utils.linkedlist;
14 15 class Prompt {
15 16 // TODO: Allow ANSI emulated prompt strings
16 17 this() {
17   - _prompt = new String("");
18   - }
19   -
20   - // Description: This will set the prompt string that will precede the input.
21   - // prompt: A string representing the prompt.
22   - void prompt(String prompt) {
23   - _prompt = new String(prompt);
  18 + _prompt = "";
24 19 }
25 20
26 21 // Description: This will set the prompt string that will precede the input.
27 22 // prompt: A string representing the prompt.
28 23 void prompt(string prompt) {
29   - _prompt = new String(prompt);
  24 + _prompt = prompt.dup;
30 25 }
31 26
32 27 // Description: This function will return the current prompt.
33 28 // Returns: The current prompt.
34   - String prompt() {
35   - return new String(_prompt);
  29 + string prompt() {
  30 + return _prompt.dup;
36 31 }
37 32
38 33 void promptColor(fgColor fgClr) {
@@ -51,7 +46,7 @@ class Prompt {
51 46 }
52 47
53 48 if (bufferSize != 0) {
54   - _lineBuffer = new LinkedList!(String)();
  49 + _lineBuffer = new LinkedList!(string)();
55 50 }
56 51 else {
57 52 _lineBuffer = null;
@@ -62,18 +57,18 @@ class Prompt {
62 57
63 58 // Description: This will display the prompt and return the line typed by the user.
64 59 // Returns: The line typed by the user.
65   - String line() {
  60 + string line() {
66 61 // the current displayed line
67   - String line;
  62 + string line;
68 63
69 64 // the 'working' line being edited
70   - String workingLine;
  65 + string workingLine;
71 66
72 67 // Print out the prompt string
73 68
74 69 Console.setColor(_promptClr);
75 70
76   - Console.put(_prompt.array);
  71 + Console.put(_prompt);
77 72
78 73 // Go into a key loop, wait for a return
79 74 // On any special key, fire the callback and expect a result (for instance, on TAB)
@@ -83,7 +78,7 @@ class Prompt {
83 78
84 79 uint code;
85 80
86   - line = new String("");
  81 + line = "";
87 82
88 83 workingLine = line;
89 84 if (_lineBuffer !is null) {
@@ -105,23 +100,23 @@ class Prompt {
105 100 else if (code == Key.Backspace) {
106 101 // backspace
107 102
108   - if (line.length() > 0 && _pos > 0) {
  103 + if (line.length > 0 && _pos > 0) {
109 104 Console.put(chr);
110 105 Console.put(' ');
111 106 Console.put(chr);
112 107
113   - if (_pos == line.length()) {
114   - line = line.subString(0, line.length()-1);
  108 + if (_pos == line.length) {
  109 + line = line.substring(0, line.length-1);
115 110 }
116 111 else {
117   - String newLine = line.subString(0, _pos-1);
118   - String restLine = line.subString(_pos);
119   - newLine.append(restLine);
  112 + string newLine = line.substring(0, _pos-1);
  113 + string restLine = line.substring(_pos);
  114 + newLine ~= restLine;
120 115
121   - Console.put(restLine.array);
  116 + Console.put(restLine);
122 117 Console.put(' ');
123 118
124   - for (uint i=0; i<=restLine.length(); i++) {
  119 + for (uint i=0; i<=restLine.length; i++) {
125 120 Console.put(cast(char)0x8);
126 121 }
127 122
@@ -144,7 +139,7 @@ class Prompt {
144 139 }
145 140 }
146 141 else if (code == Key.Right) {
147   - if (_pos < line.length()) {
  142 + if (_pos < line.length) {
148 143 Console.setRelative(1,0);
149 144
150 145 _pos++;
@@ -156,7 +151,7 @@ class Prompt {
156 151 // And then the line buffer spits out
157 152 // the previous line submitted
158 153 if (_lineBuffer !is null) {
159   - if (_bufferPos+1 < cast(int)_lineBuffer.length() && _lineBuffer.length() > 0) {
  154 + if (_bufferPos+1 < cast(int)_lineBuffer.length && _lineBuffer.length > 0) {
160 155 // grab the line from the line buffer
161 156
162 157 _bufferPos++;
@@ -164,14 +159,14 @@ class Prompt {
164 159
165 160 uint i;
166 161
167   - if (line.length() < _pos) {
168   - for (i=line.length(); i<_pos; i++) {
  162 + if (line.length < _pos) {
  163 + for (i=line.length; i<_pos; i++) {
169 164 Console.put(cast(char)0x8);
170 165 Console.put(' ');
171 166 Console.put(cast(char)0x8);
172 167 }
173 168
174   - _pos = line.length();
  169 + _pos = line.length;
175 170 }
176 171
177 172 for (i=0; i<_pos; i++) {
@@ -179,9 +174,9 @@ class Prompt {
179 174 }
180 175
181 176 // print the line
182   - Console.put(line.array);
  177 + Console.put(line);
183 178
184   - _pos = line.length();
  179 + _pos = line.length;
185 180 }
186 181 }
187 182 }
@@ -209,14 +204,14 @@ class Prompt {
209 204
210 205 uint i;
211 206
212   - if (line.length() < _pos) {
213   - for (i=line.length(); i<_pos; i++) {
  207 + if (line.length < _pos) {
  208 + for (i=line.length; i<_pos; i++) {
214 209 Console.put(cast(char)0x8);
215 210 Console.put(' ');
216 211 Console.put(cast(char)0x8);
217 212 }
218 213
219   - _pos = line.length();
  214 + _pos = line.length;
220 215 }
221 216
222 217 for (i=0; i<_pos; i++) {
@@ -224,28 +219,26 @@ class Prompt {
224 219 }
225 220
226 221 // print the line
227   - Console.put(line.array);
  222 + Console.put(line);
228 223
229 224 // erase the rest of the previous line
230 225
231   - _pos = line.length();
  226 + _pos = line.length;
232 227 }
233 228 }
234 229 else if (chr != 0) {
235 230 // written character
236 231
237   - if (_pos == line.length()) {
  232 + if (_pos == line.length) {
238 233 Console.put(chr);
239   - line.appendChar(chr);
  234 + line ~= chr;
240 235 }
241 236 else if (_pos == 0) {
242   - String newLine = new String("");
243   - newLine.appendChar(chr);
244   - newLine.append(line);
  237 + string newLine = "" ~ Unicode.toUtf8([chr]) ~ line;
245 238
246   - Console.put(newLine.array);
  239 + Console.put(newLine);
247 240
248   - for (uint i=1; i<newLine.length(); i++) {
  241 + for (uint i=1; i<newLine.length; i++) {
249 242 Console.put(cast(char)0x8);
250 243 }
251 244
@@ -253,14 +246,14 @@ class Prompt {
253 246 }
254 247 else {
255 248 Console.put(chr);
256   - String leftLine = line.subString(0, _pos);
257   - leftLine.appendChar(chr);
258   - String rightLine = line.subString(_pos);
259   - leftLine.append(rightLine);
  249 + string leftLine = line.substring(0, _pos);
  250 + leftLine ~= chr;
  251 + string rightLine = line.substring(_pos);
  252 + leftLine ~= rightLine;
260 253
261   - Console.put(rightLine.array);
  254 + Console.put(rightLine);
262 255
263   - for (uint i=0; i<rightLine.length(); i++) {
  256 + for (uint i=0; i<rightLine.length; i++) {
264 257 Console.put(cast(char)0x8);
265 258 }
266 259
@@ -294,11 +287,11 @@ class Prompt {
294 287 protected:
295 288
296 289 // the prompt string, for instance "# " or "C:\>"
297   - String _prompt;
  290 + string _prompt;
298 291 fgColor _promptClr = fgColor.White;
299 292 fgColor _clr = fgColor.White;
300 293
301   - LinkedList!(String) _lineBuffer;
  294 + LinkedList!(string) _lineBuffer;
302 295 int _bufferSize;
303 296 int _bufferPos;
304 297
2  core/arguments.d
@@ -7,7 +7,7 @@ import core.string;
7 7 import core.list;
8 8
9 9 // Description: This class holds the command line arguments that were passed into the app and will aid in parsing them.
10   -class Arguments : List!(String) {
  10 +class Arguments : List!(string) {
11 11 public:
12 12
13 13 this() {
4 core/exception.d
@@ -20,10 +20,6 @@ template CustomException(char[] name, char[] error, char[] error_more) {
20 20 super("`~error~`");
21 21 }
22 22
23   - this(String msg) {
24   - super("`~error~error_more~`" ~ msg.toString());
25   - }
26   -
27 23 this(string msg) {
28 24 super("`~error~error_more~`" ~ msg);
29 25 }
17 core/library.d
@@ -23,14 +23,8 @@ class Library {
23 23
24 24 // Description: This constructor will dynamically load the library found at the given framework path.
25 25 // path: The path to the library in question.
26   - this(String path) {
27   - SystemLoadLibrary(_pfvars, path);
28   - }
29   -
30   - // Description: This constructor will dynamically load the library found at the given framework path.
31   - // path: The path to the library in question.
32 26 this(string path) {
33   - this(new String(path));
  27 + SystemLoadLibrary(_pfvars, path);
34 28 }
35 29
36 30 ~this() {
@@ -48,20 +42,13 @@ protected:
48 42 }
49 43
50 44 // acquire the signature (or null)
51   - void* signature = SystemLoadLibraryProc(_pfvars, new String(proc));
  45 + void* signature = SystemLoadLibraryProc(_pfvars, proc);
52 46
53 47 // set in hash
54 48 _funcs[proc] = signature;
55 49 return signature;
56 50 }
57 51
58   - // Description: This function can only be called within an instance of the class. It will give the function pointer to the procedure specified by proc and null when the procedure cannot be found.
59   - // proc: The name of the procedure to call upon.
60   - // Returns: Will return null if the procedure cannot be found, otherwise it will return the address to this function.
61   - final void* getProc(String proc) {
62   - return getProc(proc.toString());
63   - }
64   -
65 52 final void*[string] _funcs;
66 53
67 54 LibraryPlatformVars _pfvars;
2  core/list.d
@@ -12,8 +12,8 @@
12 12 module core.list;
13 13
14 14 import core.definitions;
  15 +import core.string;
15 16 import core.util;
16   -import core.tostring;
17 17 import core.exception;
18 18
19 19 // Description: This template resolves to true when the type T is
4 core/locales/en_us.d
@@ -4,8 +4,8 @@ import core.locale;
4 4
5 5 import core.time;
6 6 import core.date;
7   -import core.tostring;
8 7 import core.definitions;
  8 +import core.string;
9 9
10 10 class LocaleEnglish_US : LocaleInterface {
11 11 string formatTime(Time time) {
@@ -166,7 +166,7 @@ class LocaleEnglish_US : LocaleInterface {
166 166 }
167 167 }
168 168 ret ~= ".";
169   - ret ~= ftoa(value, 10, false);
  169 + ret ~= toStr(value);
170 170
171 171 // round last digit
172 172 bool roundUp = (ret[$-1] >= '5');
4 core/locales/fr_fr.d
@@ -4,7 +4,7 @@ import core.locale;
4 4
5 5 import core.time;
6 6 import core.date;
7   -import core.tostring;
  7 +import core.string;
8 8 import core.definitions;
9 9
10 10 class LocaleFrench_FR : LocaleInterface {
@@ -154,7 +154,7 @@ class LocaleFrench_FR : LocaleInterface {
154 154 }
155 155 }
156 156 ret ~= ",";
157   - ret ~= ftoa(value, 10, false);
  157 + ret ~= toStr(value);
158 158
159 159 // round last digit
160 160 bool roundUp = (ret[$-1] >= '5');
95 core/regex.d
@@ -12,7 +12,6 @@
12 12 module core.regex;
13 13
14 14 import core.string;
15   -import core.tostring;
16 15 import core.definitions;
17 16 import core.list;
18 17
@@ -33,105 +32,105 @@ uint _position() {
33 32 return uint.max;
34 33 }
35 34
36   -String _1() {
  35 +string _1() {
37 36 if (Thread.getCurrent() in Regex.regexRefs) {
38 37 return Regex.regexRefs[Thread.getCurrent()][0];
39 38 }
40 39
41   - return new String("");
  40 + return ("");
42 41 }
43 42
44   -String _2() {
  43 +string _2() {
45 44 if (Thread.getCurrent() in Regex.regexRefs) {
46 45 return Regex.regexRefs[Thread.getCurrent()][1];
47 46 }
48 47
49   - return new String("");
  48 + return ("");
50 49 }
51 50
52   -String _3() {
  51 +string _3() {
53 52 if (Thread.getCurrent() in Regex.regexRefs) {
54 53 return Regex.regexRefs[Thread.getCurrent()][2];
55 54 }
56 55
57   - return new String("");
  56 + return ("");
58 57 }
59 58
60   -String _4() {
  59 +string _4() {
61 60 if (Thread.getCurrent() in Regex.regexRefs) {
62 61 return Regex.regexRefs[Thread.getCurrent()][3];
63 62 }
64 63
65   - return new String("");
  64 + return ("");
66 65 }
67 66
68   -String _5() {
  67 +string _5() {
69 68 if (Thread.getCurrent() in Regex.regexRefs) {
70 69 return Regex.regexRefs[Thread.getCurrent()][4];
71 70 }
72 71
73   - return new String("");
  72 + return ("");
74 73 }
75 74
76   -String _6() {
  75 +string _6() {
77 76 if (Thread.getCurrent() in Regex.regexRefs) {
78 77 return Regex.regexRefs[Thread.getCurrent()][5];
79 78 }
80 79
81   - return new String("");
  80 + return ("");
82 81 }
83 82
84   -String _7() {
  83 +string _7() {
85 84 if (Thread.getCurrent() in Regex.regexRefs) {
86 85 return Regex.regexRefs[Thread.getCurrent()][6];
87 86 }
88 87
89   - return new String("");
  88 + return ("");
90 89 }
91 90
92   -String _8() {
  91 +string _8() {
93 92 if (Thread.getCurrent() in Regex.regexRefs) {
94 93 return Regex.regexRefs[Thread.getCurrent()][7];
95 94 }
96 95
97   - return new String("");
  96 + return ("");
98 97 }
99 98
100   -String _9() {
  99 +string _9() {
101 100 if (Thread.getCurrent() in Regex.regexRefs) {
102 101 return Regex.regexRefs[Thread.getCurrent()][8];
103 102 }
104 103
105   - return new String("");
  104 + return ("");
106 105 }
107 106
108 107 class Regex {
109 108
110 109 // Description: This constructor will create an instance of a Regex that will efficiently compute the regular expression given.
111 110 // regex: The regular expression to utilize.
112   - this(String regex) {
113   - regularExpression = new String(regex);
  111 + this(string regex) {
  112 + regularExpression = (regex);
114 113
115 114 buildDFA(false);
116 115 }
117 116
118 117 this(string regex) {
119   - regularExpression = new String(regex);
  118 + regularExpression = (regex);
120 119
121 120 buildDFA();
122 121 }
123 122
124   - // Description: This function will return a matched regular expression on the given String. Single use regular expression functions, such as this one, use a backtracking algorithm.
125   - // str: The String to run the regular expression upon.
  123 + // Description: This function will return a matched regular expression on the given string. Single use regular expression functions, such as this one, use a backtracking algorithm.
  124 + // str: The string to run the regular expression upon.
126 125 // regex: The regular expression to use.
127 126 // Returns: The matched substring or null when no match could be found.
128   - static String eval(String str, String regex, string options = "") {
  127 + static string eval(string str, string regex, string options = "") {
129 128 RegexInfo regexInfo;
130 129
131 130 /*
132 131 static RegexInfo[string] oldRuns;
133 132
134   - string oldRunIndex = (regex.toString() ~ "_" ~ options);
  133 + string oldRunIndex = (regex.tostring() ~ "_" ~ options);
135 134 if (oldRunIndex in oldRuns) {
136 135 regexInfo = oldRuns[oldRunIndex];
137 136 }*/
@@ -190,7 +189,7 @@ class Regex {
190 189
191 190 bool backtrackedOnCaret = false;
192 191
193   - regexRefs[Thread.getCurrent()] = new String[](9);
  192 + regexRefs[Thread.getCurrent()] = new string [](9);
194 193
195 194 // Suppresses group matching until a position is reached.
196 195 int noMatchUntilClosedAtPos = -1;
@@ -555,7 +554,7 @@ class Regex {
555 554
556 555 if (!noMatch) {
557 556 if (regexGroupStart < 9) {
558   - String consumed = new String(str[regexInfo.groupInfo[regexInfo.groupInfo[regexPos].startPos].strStartPos..strPos]);
  557 + string consumed = (str[regexInfo.groupInfo[regexInfo.groupInfo[regexPos].startPos].strStartPos..strPos]);
559 558 regexRefs[Thread.getCurrent()][regexGroupStart] = consumed;
560 559 regexGroupStart++;
561 560 }
@@ -1201,35 +1200,23 @@ class Regex {
1201 1200 // Return the result
1202 1201 if (matchMade && strPosStart <= str.length) {
1203 1202 if (strPos-strPosStart == 0) {
1204   - return new String("");
  1203 + return ("");
1205 1204 }
1206 1205
1207 1206 // Save the position where the string was consumed
1208 1207 this.regexPos[Thread.getCurrent()] = strPosStart;
1209 1208
1210 1209 // Slice and return the consumed string
1211   - return str.subString(strPosStart, strPos-strPosStart);
  1210 + return str.substring(strPosStart, strPos-strPosStart);
1212 1211 }
1213 1212
1214 1213 return null;
1215 1214 }
1216 1215
1217   - static String eval(string str, String regex, string options = "") {
1218   - return eval(new String(str), regex, options);
1219   - }
1220   -
1221   - static String eval(String str, string regex, string options = "") {
1222   - return eval(str, new String(regex), options);
1223   - }
1224   -
1225   - static String eval(string str, string regex, string options = "") {
1226   - return eval(new String(str), new String(regex), options);
1227   - }
1228   -
1229   - // Description: This function will return a matched regular expression on the given String. Instances of a Regex will use a DFA based approach.
1230   - // str: The String to run the regular expression upon.
  1216 + // Description: This function will return a matched regular expression on the given string. Instances of a Regex will use a DFA based approach.
  1217 + // str: The string to run the regular expression upon.
1231 1218 // Returns: The matched substring or null when no match could be found.
1232   - String eval(String str) {
  1219 + string eval(string str) {
1233 1220 State currentState = startingState;
1234 1221
1235 1222 uint strPos;
@@ -1294,24 +1281,20 @@ class Regex {
1294 1281
1295 1282 // Return consumed string
1296 1283 if (currentState.accept) {
1297   - return str.subString(startingStrPos, strPos - startingStrPos);
  1284 + return str.substring(startingStrPos, strPos - startingStrPos);
1298 1285 }
1299 1286
1300 1287 // No match
1301 1288 return null;
1302 1289 }
1303 1290
1304   - String eval(string str) {
1305   - return eval(new String(str));
1306   - }
1307   -
1308 1291 protected:
1309 1292
1310 1293 // These instance variables contain the data structures
1311 1294 // that will build and maintain the DFA for the regular expression
1312 1295
1313 1296 // Holds the regular expression for the instance
1314   - String regularExpression;
  1297 + string regularExpression;
1315 1298
1316 1299 // For DFA regex operations
1317 1300
@@ -1355,7 +1338,7 @@ protected:
1355 1338 all.add(this);
1356 1339 }
1357 1340
1358   - string toString() {
  1341 + string tostring() {
1359 1342 string ret = "State " ~ toStr(id) ~ ": [";
1360 1343
1361 1344 if (accept) {
@@ -1446,17 +1429,13 @@ private:
1446 1429 }
1447 1430
1448 1431 State buildDFA(string regex) {
1449   - return buildDFA(new String(regex));
1450   - }
1451   -
1452   - State buildDFA(String regex) {
1453 1432 fillGroupInfo();
1454 1433 uint regexPos = 0;
1455 1434 List!(State) current = new List!(State);
1456 1435 return buildDFA(regex, regexPos, current);
1457 1436 }
1458 1437
1459   - State buildDFA(String regex, ref uint regexPos, ref List!(State) current, bool isKleene = false) {
  1438 + State buildDFA(string regex, ref uint regexPos, ref List!(State) current, bool isKleene = false) {
1460 1439 State startState = new State();
1461 1440 Console.putln("Start State: ", startState.id);
1462 1441
@@ -1695,7 +1674,7 @@ private:
1695 1674
1696 1675 // Common
1697 1676
1698   - static String[][Thread] regexRefs;
  1677 + static string[][Thread] regexRefs;
1699 1678 static uint[Thread] regexPos;
1700 1679
1701 1680 // For backtracking regex operations
21 core/stream.d
@@ -410,14 +410,6 @@ public:
410 410 return write(cast(ubyte*)str.ptr, dchar.sizeof * str.length);
411 411 }
412 412
413   - bool append(String str) {
414   - return append(str.array);
415   - }
416   -
417   - bool write(String str) {
418   - return write(str.array);
419   - }
420   -
421 413 // Description: This function places the last bytes of information into the front and sets the pointer to end of the information after it is moved.
422 414 void flush() {
423 415 }
@@ -801,19 +793,6 @@ public:
801 793 return ret;
802 794 }
803 795
804   - int opApply(int delegate(ref String) loopFunc) {
805   - string nextLine;
806   - int ret;
807   - while(readLine(nextLine)) {
808   - String str = new String(nextLine);
809   - ret = loopFunc(str);
810   -
811   - if (ret) { break; }
812   - }
813   -
814   - return ret;
815   - }
816   -
817 796 ubyte[] contents() {
818 797 if (_length == 0) {
819 798 return null;
1,635 core/string.d
@@ -16,9 +16,24 @@ module core.string;
16 16 import core.definitions;
17 17 import core.unicode;
18 18 import core.variant;
  19 +import io.console;
19 20
20 21 public import core.string;
21 22
  23 +string toStrv(Variadic vars) {
  24 + string ret = "";
  25 + foreach(var; vars) {
  26 + ret ~= var.toString();
  27 + }
  28 + return ret;
  29 +}
  30 +
  31 +string toStr(...) {
  32 + Variadic vars = new Variadic(_arguments, _argptr);
  33 +
  34 + return toStrv(vars);
  35 +}
  36 +
22 37 template _StringFormat() {
23 38 const char[] _StringFormat = `
24 39
@@ -101,975 +116,67 @@ template _StringFormat() {
101 116 intToStr = true;
102 117 }
103 118
104   - if (intToStr) {
105   - // convert int to string
106   - // get length of potential string
107   - uint actualLength = 1;
108   - ulong tmpVal;
109   -
110   - bool negative;
111   -
112   - if (argval < 0) {
113   - negative = true;
114   - argval = -argval;
115   - }
116   -
117   - tmpVal = cast(ulong)(argval);
118   -
119   - // initial push
120   - tmpVal /= base;
121   -
122   - // finds the length
123   - while(tmpVal > 0) {
124   - tmpVal /= base;
125   - actualLength++;
126   - }
127   -
128   - if (actualLength < length) { actualLength = length; }
129   -
130   - // from this, we can determine how much of the string to add
131   - result ~= new dchar[actualLength];
132   - result[$-actualLength..$] = '0';
133   -
134   - // add the string
135   - uint valIndex;
136   - for(int o = result.length-1; ; o--) {
137   - valIndex = cast(uint)argval % base;
138   - if (valIndex >= 10) {
139   - result[o] = (valIndex - 10) + 'a';
140   - }
141   - else {
142   - result[o] = valIndex + '0';
143   - }
144   - argval /= base;
145   -
146   - if (argval == 0) { break; }
147   - }
148   - }
149   -
150   - curArg++;
151   - }
152   -
153   - if (curArg == _arguments.length) { // just append the rest and not care
154   - i++;
155   - result ~= fmt[i..$];
156   - break; // exit for
157   - }
158   - }
159   - else {
160   - result ~= fmt[i];
161   - }
162   - }
163   -
164   - `;
165   -}
166   -
167   -// Section: Core/Resources
168   -
169   -// Description: A class that abstracts a character array with the native platform's perferred unicode format.
170   -class String {
171   -
172   - // Description: Will create an empty string.
173   - this() {
174   - this("");
175   - }
176   -
177   - // Description: Will create a string fitting the string passed through via the parameter.
178   - // str: The string to copy to the class.
179   - this (string str, ...) {
180   - if (_arguments.length == 0) {
181   - _data = Unicode.toNative(str);
182   - }
183   - else {
184   - // formatted string
185   - // perform format
186   - mixin(_StringFormat!());
187   -
188   - _data = Unicode.toNative(result);
189   - }
190   - }
191   -
192   - // Description: Will create a string fitting the string passed through via the parameter.
193   - // str: The string to copy to the class.
194   - this(String str) {
195   - _data ~= str._data;
196   - }
197   -
198   - // Description: Will create a string for the given integer.
199   - // val: The value to use.
200   - this(long val) {
201   - fromInteger(val);
202   - }
203   -
204   - // Description: Will return the length of the string.
205   - // Returns: The length of the string.
206   - uint length() {
207   - if (_data.length == 0) {
208   - return 0;
209   - }
210   -
211   - if (_calcIndices) {
212   - return _indices.length;
213   - }
214   -
215   - if (_calcLength) {
216   - return _length;
217   - }
218   -
219   - _length = Unicode.utflen(_data);
220   -
221   - _calcLength = true;
222   -
223   - return _length;
224   - }
225   -
226   - // Description: Will return the pointer to the character array.
227   - // Returns: An address to the internal character array for this String class.
228   - Char* ptr() {
229   - return _data.ptr;
230   - }
231   -
232   - // Description: Will return a reference to the internal character array.
233   - // Returns: A reference to the internal character array for this String class.
234   - Char[] array() {
235   - return _data;
236   - }
237   -
238   - // Description: Will append a String to the current String. The internal character array is rebuilt.
239   - // str: The String to append to the internal character array of this String class.
240   - void append(String str) {
241   - _data ~= str._data.dup;
242   - if (str._calcLength) {
243   - _length += str._length;
244   - }
245   - else {
246   - _calcLength = false;
247   - }
248   - _calcIndices = false;
249   - }
250   -
251   - void append(string str, ...) {
252   - _calcLength = false;
253   - _calcIndices = false;
254   - if (_arguments.length == 0) {
255   - _data ~= Unicode.toNative(str);
256   - }
257   - else {
258   - // formatted string
259   - // perform format
260   -
261   - // scan input, write when appropriate
262   - mixin(_StringFormat!());
263   -
264   - _data ~= Unicode.toNative(result);
265   - }
266   - }
267   -
268   - // Description: Will append a unicode character to this String. The internal character array is rebuilt.
269   - // character: The unicode character to append to the internal character array of this String class.
270   - void appendChar(dchar character) {
271   - _calcIndices = false;
272   - static if (Char.sizeof == dchar.sizeof) {
273   - _data ~= character;
274   - if (!Unicode.isDeadChar(character)) {
275   - _length++;
276   - }
277   - }
278   - else {
279   - dchar[] charArray = [ character ];
280   - // BLEH
281   - static if(Char.sizeof == wchar.sizeof) {
282   - _data ~= Unicode.toUtf16(charArray);
283   - }
284   - else {
285   - char[] chrs = Unicode.toUtf8(charArray);
286   - _data ~= chrs;
287   - }
288   -
289   - if (!Unicode.isDeadChar(character)) {
290   - _length++;
291   - }
292   - }
293   - }
294   -
295   - // Description: Will append a unicode character with combining marks to this String. The internal character array is rebuilt.
296   - // characters: The unicode character to append to the internal character array of this String class.
297   - void appendChar(dstring characters) {
298   - static if (Char.sizeof == dchar.sizeof) {
299   - _data ~= characters;
300   - if (!Unicode.isDeadChar(characters[0])) {
301   - _length++;
302   - }
303   - }
304   - else {
305   - static if(Char.sizeof == wchar.sizeof) {
306   - _data ~= Unicode.toUtf16Chars(characters);
307   - }
308   - else {
309   - _data ~= Unicode.toUtf8Chars(characters);
310   - }
311   -
312   - if (!Unicode.isDeadChar(characters[0])) {
313   - _length++;
314   - }
315   - }
316   - }
317   -
318   - // Description: Inserts a String at an arbitrary position.
319   - String insertAt(String s, uint pos) {
320   - if (pos >= this.length())
321   - return this;
322   -
323   - String ret = new String();
324   -
325   - ret.append(this.subString(0, pos));
326   - ret.append(s);
327   - ret.append(this.subString(pos));
328   -
329   - return ret;
330   - }
331   -
332   - String insertAt(string s, uint pos) {
333   - return insertAt(new String(s), pos);
334   - }
335   -
336   - // Description: Repeats a given string.
337   - // Returns: s repeated n times.
338   - static String repeat(String s, uint n) {
339   - String ret = new String();
340   -
341   - for (uint i = 0; i < n; i++) {
342   - ret.append(s);
343   - }
344   -
345   - return ret;
346   - }
347   -
348   - static String repeat(string s, uint n) {
349   - return repeat(new String(s), n);
350   - }
351   -
352   - String trim() {
353   - // find the start and end
354   - // slice the array
355   -
356   - int startpos;
357   - int endpos;
358   -
359   - if (_data.length == 0) {
360   - return new String("");
361   - }
362   -
363   - for(startpos=0; startpos<_data.length; startpos++) {
364   - if (_data[startpos] != ' ' &&
365   - _data[startpos] != '\t' &&
366   - _data[startpos] != '\r' &&
367   - _data[startpos] != '\n') {
368   -
369   - break;
370   - }
371   - }
372   -
373   - for(endpos=_data.length-1; endpos>=0; endpos--) {
374   - if (_data[endpos] != ' ' &&
375   - _data[endpos] != '\t' &&
376   - _data[endpos] != '\r' &&
377   - _data[endpos] != '\n') {
378   -
379   - break;
380   - }
381   - }
382   - endpos++;
383   -
384   - String ret = new String("");
385   - if (endpos > _data.length) {
386   - endpos = _data.length;
387   - }
388   -
389   - if (startpos > endpos) {
390   - return new String("");
391   - }
392   -
393   - ret._data = _data[startpos..endpos];
394   - return ret;
395   - }
396   -
397   - template _nextInt(T) {
398   - bool _nextInt(T)(out T value) {
399   - int curpos;
400   -
401   - for(curpos=0; curpos<_data.length; curpos++) {
402   - if (_data[curpos] != ' ' &&
403   - _data[curpos] != '\t' &&
404   - _data[curpos] != '\r' &&
405   - _data[curpos] != '\n') {
406   -
407   - break;
408   - }
409   - }
410   -
411   - bool negative = false;
412   -
413   - if (_data[curpos] == '-') {
414   - negative = true;
415   - curpos++;
416   - if (curpos == _data.length) { return false; }
417   - }
418   -
419   - if (_data[curpos] < '0' ||
420   - _data[curpos] > '9') {
421   -
422   - return false;
423   - }
424   -
425   - long tmpval = 0;
426   -
427   - for (;curpos<_data.length;curpos++) {
428   - if (_data[curpos] < '0' ||
429   - _data[curpos] > '9') {
430   -
431   - break;
432   - }
433   -
434   - tmpval *= 10;
435   - tmpval += cast(long)(_data[curpos] - '0');
436   - }
437   -
438   - if (negative) { tmpval = -tmpval; }
439   -
440   - value = cast(T)tmpval;
441   -
442   - return true;
443   - }
444   - }
445   -
446   - // Description: This function will return the next integer value found in the string.
447   - bool nextInt(out int value) {
448   - return _nextInt!(int)(value);
449   - }
450   -
451   - bool nextInt(out uint value) {
452   - return _nextInt!(uint)(value);
453   - }
454   -
455   - bool nextInt(out long value) {
456   - return _nextInt!(long)(value);
457   - }
458   -
459   - bool nextInt(out ulong value) {
460   - return _nextInt!(ulong)(value);
461   - }
462   -
463   - bool nextInt(out short value) {
464   - return _nextInt!(short)(value);
465   - }
466   -
467   - bool nextInt(out ushort value) {
468   - return _nextInt!(ushort)(value);
469   - }
470   -
471   - bool next(out String value, string delimiters) {
472   - return false;
473   - }
474   -
475   - int findReverse(String search) {
476   - // look through string for term search
477   - // in some, hopefully later on, efficient manner
478   -
479   - if (!_calcIndices) {
480   - _indices = Unicode.calcIndices(_data);
481   - _calcIndices = true;
482   - }
483   -
484   - if (!search._calcIndices) {
485   - search._indices = Unicode.calcIndices(search._data);
486   - search._calcIndices = true;
487   - }
488   -
489   - bool found;
490   -
491   - int o;
492   - int i;
493   - int aPos;
494   -
495   - for (i=_indices.length-1; i>=0; i--) {
496   - aPos = _indices[i];
497   -
498   - found = true;
499   - o=i;
500   - foreach (bPos; search._indices) {
501   - dchar aChr, bChr;
502   -
503   - aChr = Unicode.toUtf32Char(_data[_indices[o]..$]);
504   - bChr = Unicode.toUtf32Char(search._data[bPos..$]);
505   -
506   - if (aChr != bChr) {
507   - found = false;
508   - break;
509   - }
510   -
511   - o++;
512   - if (o >= _indices.length) {
513   - found = false;
514   - break;
515   - }
516   - }
517   - if (found) {
518   - return i;
519   - }
520   - }
521   -
522   - return -1;
523   - }
524   -
525   - int find(string search, uint start = 0) {
526   - return find(new String(search), start);
527   - }
528   -
529   - int find(String search, uint start = 0) {
530   - // look through string for term search
531   - // in some, hopefully later on, efficient manner
532   -
533   - if (!_calcIndices) {
534   - _indices = Unicode.calcIndices(_data);
535   - _calcIndices = true;
536   - }
537   -
538   - if (!search._calcIndices) {
539   - search._indices = Unicode.calcIndices(search._data);
540   - search._calcIndices = true;
541   -