Changeset 39
- Timestamp:
- 01/04/08 11:00:27 (11 months ago)
- Files:
-
- trunk/CMakeLists.txt (modified) (1 diff)
- trunk/tango/scrapple/net/http/HttpMultipart.d (modified) (2 diffs)
- trunk/tango/scrapple/protocol/PlainTextProtocol.d (modified) (1 diff)
- trunk/tango/scrapple/sys/win32/Registry.d (modified) (21 diffs)
- trunk/tango/scrapple/text/convert/TimeStamp.d (modified) (1 diff)
- trunk/tango/scrapple/util/Test.d (modified) (6 diffs)
- trunk/tango/scrapple/util/uuid/Uuid.d (modified) (6 diffs)
- trunk/tango/scrapple/util/uuid/Uuid2.d (modified) (6 diffs)
- trunk/tango/scrapple/util/uuid/Uuid3.d (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/CMakeLists.txt
r38 r39 1 ################################# #1 ################################# 2 2 # Preamble 3 3 ############## trunk/tango/scrapple/net/http/HttpMultipart.d
r36 r39 19 19 tango.io.FilePath, 20 20 tango.net.http.HttpPost, 21 tango.util.time.DateTime, 21 tango.time.Clock, 22 tango.time.Time, 22 23 23 24 ConvertTime = tango.text.convert.TimeStamp; … … 61 62 { 62 63 super(url); 63 boundary = getBoundary(ConvertTime.to Utf8(DateTime.now.time));64 boundary = getBoundary(ConvertTime.toString(Clock.now)); 64 65 } 65 66 trunk/tango/scrapple/protocol/PlainTextProtocol.d
r11 r39 96 96 } 97 97 98 /***************************************************************************99 100 Construct a buffer upon the given conduit, placing a buffer between101 102 ***************************************************************************/103 104 this (IConduit conduit, bool _prefix = true)105 {106 this (new Buffer (conduit), _prefix);107 }108 109 98 /*************************************************************************** 110 99 trunk/tango/scrapple/sys/win32/Registry.d
r34 r39 63 63 private import tango.core.Exception; 64 64 private import tango.stdc.string : wcslen; 65 private import tango.text.convert.Utf : to Utf16, toUTF8 = toUtf8;65 private import tango.text.convert.Utf : toString16, toUTF8 = toString; 66 66 67 67 // Grabbed from juno.base.native, use tango.sys.win32.UserGdi have some problem here … … 220 220 221 221 // Grabbed from juno.base.string since Tango's stdc.stringz, text.convert.Utf lacks these: 222 public wchar* to Utf16z(string s, int start = 0, int count = -1) {222 public wchar* toString16z(string s, int start = 0, int count = -1) { 223 223 if (s is null) 224 224 return null; … … 229 229 return s[start .. count].toUTF16z(); 230 230 } 231 public string to Utf8(wchar* s, int start = 0, int count = -1) {231 public string toString(wchar* s, int start = 0, int count = -1) { 232 232 if (s == null) 233 233 return null; … … 342 342 { 343 343 wchar[] ws; 344 ws = to Utf16(s);344 ws = toString16(s); 345 345 ws ~= '\0'; 346 346 return ws.ptr; … … 356 356 if (parts[i].length > 0) { 357 357 string temp = "%" ~ parts[i] ~ "%"; 358 uint n = ExpandEnvironmentStrings(temp.to Utf16z(), buffer.ptr, c);358 uint n = ExpandEnvironmentStrings(temp.toString16z(), buffer.ptr, c); 359 359 while (n > c) { 360 360 c = n; 361 361 buffer.length = c; 362 n = ExpandEnvironmentStrings(temp.to Utf16z(), buffer.ptr, c);363 } 364 } 365 } 366 int n = ExpandEnvironmentStrings(name.to Utf16z(), buffer.ptr, c);362 n = ExpandEnvironmentStrings(temp.toString16z(), buffer.ptr, c); 363 } 364 } 365 } 366 int n = ExpandEnvironmentStrings(name.toString16z(), buffer.ptr, c); 367 367 while (n > c) { 368 368 c = n; 369 369 buffer.length = c; 370 n = ExpandEnvironmentStrings(name.to Utf16z(), buffer.ptr, c);371 } 372 373 return .to Utf8(buffer.ptr);370 n = ExpandEnvironmentStrings(name.toString16z(), buffer.ptr, c); 371 } 372 373 return .toString(buffer.ptr); 374 374 } 375 375 … … 465 465 public RegistryKey openSubKey(string name, bool writable = false) { 466 466 Handle hkey; 467 int r = RegOpenKeyEx(hKey_, name.to Utf16z(), 0, (writable ? (KEY_READ | KEY_WRITE) : KEY_READ), hkey);467 int r = RegOpenKeyEx(hKey_, name.toString16z(), 0, (writable ? (KEY_READ | KEY_WRITE) : KEY_READ), hkey); 468 468 if (r == ERROR_SUCCESS && hkey != Handle.init && hkey != INVALID_HANDLE_VALUE) { 469 469 auto key = new RegistryKey(hkey, writable, false, false, false); … … 479 479 Handle hkey; 480 480 uint disposition; 481 int r = RegCreateKeyEx(hKey_, name.to Utf16z(), 0, null, 0, KEY_READ | KEY_WRITE, null, hkey, disposition);481 int r = RegCreateKeyEx(hKey_, name.toString16z(), 0, null, 0, KEY_READ | KEY_WRITE, null, hkey, disposition); 482 482 if (r == ERROR_SUCCESS && hkey != Handle.init && hkey != INVALID_HANDLE_VALUE) { 483 483 auto key = new RegistryKey(hkey, true, false, false, false); … … 498 498 */ 499 499 public void deleteSubKey(string name) { 500 RegDeleteKey(hKey_, name.to Utf16z());500 RegDeleteKey(hKey_, name.toString16z()); 501 501 } 502 502 … … 511 511 key.close(); 512 512 513 int r = RegDeleteKey(hKey_, name.to Utf16z());513 int r = RegDeleteKey(hKey_, name.toString16z()); 514 514 //if (r != ERROR_SUCCESS) 515 515 //issueError(r, null); … … 524 524 */ 525 525 public void deleteValue(string name) { 526 RegDeleteValue(hKey_, name.to Utf16z());526 RegDeleteValue(hKey_, name.toString16z()); 527 527 } 528 528 … … 534 534 public RegistryValueKind getValueKind(string name) { 535 535 uint cb, type; 536 RegQueryValueEx(hKey_, name.to Utf16z(), null, &type, null, &cb);536 RegQueryValueEx(hKey_, name.toString16z(), null, &type, null, &cb); 537 537 return cast(RegistryValueKind)type; 538 538 } … … 548 548 public T getValue(T)(string name, T defaultValue = T.init, bool doNotExpand = false) { 549 549 uint cb, type; 550 if (RegQueryValueEx(hKey_, name.to Utf16z(), null, &type, null, &cb) == 0) {550 if (RegQueryValueEx(hKey_, name.toString16z(), null, &type, null, &cb) == 0) { 551 551 static if (is(T == int)) { 552 552 if (type == REG_DWORD) { 553 553 int b; 554 RegQueryValueEx(hKey_, name.to Utf16z(), null, &type, cast(ubyte*)&b, &cb);554 RegQueryValueEx(hKey_, name.toString16z(), null, &type, cast(ubyte*)&b, &cb); 555 555 return b; 556 556 } … … 559 559 if (type == REG_QWORD) { 560 560 long b; 561 RegQueryValueEx(hKey_, name.to Utf16z(), null, &type, cast(ubyte*)&b, &cb);561 RegQueryValueEx(hKey_, name.toString16z(), null, &type, cast(ubyte*)&b, &cb); 562 562 return b; 563 563 } … … 566 566 if (type == REG_SZ || type == REG_EXPAND_SZ) { 567 567 wchar[] b = new wchar[cb / 2]; 568 RegQueryValueEx(hKey_, name.to Utf16z(), null, &type, cast(ubyte*)b.ptr, &cb);569 string result = .to Utf8(b.ptr);568 RegQueryValueEx(hKey_, name.toString16z(), null, &type, cast(ubyte*)b.ptr, &cb); 569 string result = .toString(b.ptr); 570 570 571 571 if (!doNotExpand && type == REG_EXPAND_SZ) … … 580 580 581 581 wchar[] b = new wchar[cb / 2]; 582 RegQueryValueEx(hKey_, name.to Utf16z(), null, &type, cast(ubyte*)b.ptr, &cb);582 RegQueryValueEx(hKey_, name.toString16z(), null, &type, cast(ubyte*)b.ptr, &cb); 583 583 584 584 uint index = 0; … … 589 589 590 590 if (pos < end) { 591 if (pos - index > 0) result ~= .to Utf8(b.ptr, index, pos);591 if (pos - index > 0) result ~= .toString(b.ptr, index, pos); 592 592 else if (pos != end - 1) result ~= ""; 593 593 } 594 else result ~= .to Utf8(b.ptr, index, end);594 else result ~= .toString(b.ptr, index, end); 595 595 596 596 index = pos + 1; … … 603 603 if (type == REG_BINARY || type == REG_DWORD_BIG_ENDIAN) { 604 604 ubyte[] b = new ubyte[cb]; 605 RegQueryValueEx(hKey_, name.to Utf16z(), null, &type, b.ptr, &cb);605 RegQueryValueEx(hKey_, name.toString16z(), null, &type, b.ptr, &cb); 606 606 return b; 607 607 } … … 643 643 else 644 644 s = value; 645 r = RegSetValueEx(hKey_, name.to Utf16z(), 0, REG_SZ, cast(ubyte*)s.toUtf16z(), (s.length * 2) + 2);645 r = RegSetValueEx(hKey_, name.toString16z(), 0, REG_SZ, cast(ubyte*)s.toString16z(), (s.length * 2) + 2); 646 646 break; 647 647 case RegistryValueKind.MultiString: 648 648 break; 649 649 case RegistryValueKind.Binary: 650 r = RegSetValueEx(hKey_, name.to Utf16z(), 0, REG_BINARY, cast(ubyte*)value.ptr, value.length);650 r = RegSetValueEx(hKey_, name.toString16z(), 0, REG_BINARY, cast(ubyte*)value.ptr, value.length); 651 651 break; 652 652 case RegistryValueKind.DWord: 653 r = RegSetValueEx(hKey_, name.to Utf16z(), 0, REG_DWORD, cast(ubyte*)&value, int.sizeof);653 r = RegSetValueEx(hKey_, name.toString16z(), 0, REG_DWORD, cast(ubyte*)&value, int.sizeof); 654 654 break; 655 655 case RegistryValueKind.QWord: 656 r = RegSetValueEx(hKey_, name.to Utf16z(), 0, REG_QWORD, cast(ubyte*)&value, long.sizeof);656 r = RegSetValueEx(hKey_, name.toString16z(), 0, REG_QWORD, cast(ubyte*)&value, long.sizeof); 657 657 break; 658 658 default: … … 692 692 uint cch = buffer.length; 693 693 RegEnumKeyEx(hKey_, index, buffer.ptr, &cch, null, null, null, null); 694 result[index] = .to Utf8(buffer.ptr);694 result[index] = .toString(buffer.ptr); 695 695 } 696 696 } … … 722 722 uint cch = buffer.length; 723 723 RegEnumValue(hKey_, index, buffer.ptr, &cch, null, null, null, null); 724 result[index] = .to Utf8(buffer.ptr);724 result[index] = .toString(buffer.ptr); 725 725 } 726 726 } … … 749 749 uint r = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_IGNORE_INSERTS, null, error, LOCALE_USER_DEFAULT, buffer.ptr, buffer.length + 1, null); 750 750 if (r != 0) { 751 return to Utf8(buffer.ptr, 0, r);751 return toString(buffer.ptr, 0, r); 752 752 } 753 753 return format("Unspecified error (0x{0:X8})", error); trunk/tango/scrapple/text/convert/TimeStamp.d
r10 r39 13 13 module tango.scrapple.text.convert.TimeStamp; 14 14 15 import tango. util.time.Date;15 import tango.time.Time; 16 16 17 17 /******************************************************************************* trunk/tango/scrapple/util/Test.d
r33 r39 65 65 private import tango.io.Stdout; 66 66 private import tango.text.Util; 67 private import tango. util.time.StopWatch;67 private import tango.time.StopWatch; 68 68 private import tango.core.Array; 69 69 private import Float = tango.text.convert.Float; … … 266 266 Stdout.format(" ({})", join(tc._messages[i], ", ")); 267 267 if (config.caseTime) 268 Stdout.format(" [{}{}]", Float.to Utf8(tc._time[i], config.timing.precision), config.timing.postfix);268 Stdout.format(" [{}{}]", Float.toString(tc._time[i], config.timing.precision), config.timing.postfix); 269 269 Stdout.newline; 270 270 } … … 275 275 { 276 276 _outputLevel(outLevel); 277 Stdout.format("-Avg: [{}{}], Total: [{}{}]", Float.to Utf8((totalCaseTime / tc._iterations), config.timing.precision), config.timing.postfix, Float.toUtf8(totalCaseTime, config.timing.precision), config.timing.postfix).newline;277 Stdout.format("-Avg: [{}{}], Total: [{}{}]", Float.toString((totalCaseTime / tc._iterations), config.timing.precision), config.timing.postfix, Float.toString(totalCaseTime, config.timing.precision), config.timing.postfix).newline; 278 278 } 279 279 outLevel--; … … 281 281 } 282 282 if (config.incremental && config.testTime) 283 Stdout.format("[{}{}]", Float.to Utf8(totalTime, config.timing.precision), config.timing.postfix).newline;283 Stdout.format("[{}{}]", Float.toString(totalTime, config.timing.precision), config.timing.postfix).newline; 284 284 if (config.incremental) 285 285 Stdout.newline; … … 303 303 Stdout.format("{}", this._name); 304 304 if (config.testTime) 305 Stdout.format(" ({}{})", Float.to Utf8(totalTime, config.timing.precision), config.timing.postfix);305 Stdout.format(" ({}{})", Float.toString(totalTime, config.timing.precision), config.timing.postfix); 306 306 if (config.testName || config.testTime) 307 307 Stdout.newline; … … 321 321 Stdout.format(" [{}]", config.status.text[tc._status[i]]); 322 322 if (config.caseTime) 323 Stdout.format(" ({}{})", Float.to Utf8(tc._time[i], config.timing.precision), config.timing.postfix);323 Stdout.format(" ({}{})", Float.toString(tc._time[i], config.timing.precision), config.timing.postfix); 324 324 if (config.caseName) 325 325 { trunk/tango/scrapple/util/uuid/Uuid.d
r10 r39 140 140 Returns the string representation of this UUID. 141 141 */ 142 char[] to Utf8(char[] output = null)142 char[] toString(char[] output = null) 143 143 { 144 144 if (output.length < 36) … … 179 179 char[] toUrn() 180 180 { 181 return "urn:uuid:" ~ to Utf8();181 return "urn:uuid:" ~ toString(); 182 182 } 183 183 … … 316 316 char[] opCast() 317 317 { 318 return to Utf8;318 return toString; 319 319 } 320 320 … … 397 397 char[] toCLSIDString() 398 398 { 399 return "{" ~ to Utf8~ "}";399 return "{" ~ toString ~ "}"; 400 400 } 401 401 … … 435 435 436 436 char[36] buffer; 437 uuid.to Utf8(buffer);437 uuid.toString(buffer); 438 438 assert(buffer == TEST_UUID_STR); 439 439 … … 441 441 assert(uuid.ver == UuidVersion.TIME_BASED); 442 442 443 auto uuid2 = Uuid(uuid.to Utf8);443 auto uuid2 = Uuid(uuid.toString); 444 444 assert(uuid == uuid2); 445 445 446 446 uuid = TEST_UUID_STR; 447 assert(uuid.to Utf8== TEST_UUID_STR);447 assert(uuid.toString == TEST_UUID_STR); 448 448 assert(TEST_UUID_STR == cast(char[])uuid); 449 449 trunk/tango/scrapple/util/uuid/Uuid2.d
r17 r39 198 198 Returns the string representation of this UUID. 199 199 */ 200 char[] to Utf8(char[] output = null)200 char[] toString(char[] output = null) 201 201 { 202 202 if (output.length < 36) … … 237 237 char[] toUrn() 238 238 { 239 return "urn:uuid:" ~ to Utf8();239 return "urn:uuid:" ~ toString(); 240 240 } 241 241 … … 368 368 char[] opCast() 369 369 { 370 return to Utf8;370 return toString; 371 371 } 372 372 … … 449 449 char[] toCLSIDString() 450 450 { 451 return "{" ~ to Utf8~ "}";451 return "{" ~ toString ~ "}"; 452 452 } 453 453 … … 487 487 488 488 char[36] buffer; 489 uuid.to Utf8(buffer);489 uuid.toString(buffer); 490 490 assert(buffer == TEST_UUID_STR); 491 491 … … 493 493 assert(uuid.ver == UuidVersion.TIME_BASED); 494 494 495 auto uuid2 = Uuid(uuid.to Utf8);495 auto uuid2 = Uuid(uuid.toString); 496 496 assert(uuid == uuid2); 497 497 498 498 uuid = TEST_UUID_STR; 499 assert(uuid.to Utf8== TEST_UUID_STR);499 assert(uuid.toString == TEST_UUID_STR); 500 500 assert(TEST_UUID_STR == cast(char[])uuid); 501 501 trunk/tango/scrapple/util/uuid/Uuid3.d
r17 r39 198 198 Returns the string representation of this UUID. 199 199 */ 200 char[] to Utf8(char[] output = null)200 char[] toString(char[] output = null) 201 201 { 202 202 if (output.length < 36) … … 237 237 char[] toUrn() 238 238 { 239 return "urn:uuid:" ~ to Utf8();239 return "urn:uuid:" ~ toString(); 240 240 } 241 241 … … 368 368 char[] opCast() 369 369 { 370 return to Utf8;370 return toString; 371 371 } 372 372 … … 449 449 char[] toCLSIDString() 450 450 { 451 return "{" ~ to Utf8~ "}";451 return "{" ~ toString ~ "}"; 452 452 } 453 453 … … 487 487 488 488 char[36] buffer; 489 uuid.to Utf8(buffer);489 uuid.toString(buffer); 490 490 assert(buffer == TEST_UUID_STR); 491 491 … … 493 493 assert(uuid.ver == UuidVersion.TIME_BASED); 494 494 495 auto uuid2 = Uuid(uuid.to Utf8);495 auto uuid2 = Uuid(uuid.toString); 496 496 assert(uuid == uuid2); 497 497 498 498 uuid = TEST_UUID_STR; 499 assert(uuid.to Utf8== TEST_UUID_STR);499 assert(uuid.toString == TEST_UUID_STR); 500 500 assert(TEST_UUID_STR == cast(char[])uuid); 501 501
