| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * [StringBase] contains common methods used by concrete String implementations, | 6 * [StringBase] contains common methods used by concrete String implementations, |
| 7 * e.g., OneByteString. | 7 * e.g., OneByteString. |
| 8 */ | 8 */ |
| 9 class StringBase { | 9 class StringBase { |
| 10 | 10 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 // Checks for one-byte whitespaces only. | 406 // Checks for one-byte whitespaces only. |
| 407 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid | 407 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid |
| 408 // whitespaces. Add checking for multi-byte whitespace codepoints. | 408 // whitespaces. Add checking for multi-byte whitespace codepoints. |
| 409 bool _isWhitespace(int codePoint) { | 409 bool _isWhitespace(int codePoint) { |
| 410 return | 410 return |
| 411 (codePoint === 32) || // Space. | 411 (codePoint === 32) || // Space. |
| 412 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. | 412 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. |
| 413 } | 413 } |
| 414 } | 414 } |
| 415 | 415 |
| 416 |
| 417 class ExternalOneByteString extends StringBase implements String { |
| 418 // Checks for one-byte whitespaces only. |
| 419 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid |
| 420 // whitespaces for one byte strings. |
| 421 bool _isWhitespace(int codePoint) { |
| 422 return |
| 423 (codePoint === 32) || // Space. |
| 424 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. |
| 425 } |
| 426 } |
| 427 |
| 428 |
| 429 class ExternalTwoByteString extends StringBase implements String { |
| 430 // Checks for one-byte whitespaces only. |
| 431 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid |
| 432 // whitespaces. Add checking for multi-byte whitespace codepoints. |
| 433 bool _isWhitespace(int codePoint) { |
| 434 return |
| 435 (codePoint === 32) || // Space. |
| 436 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. |
| 437 } |
| 438 } |
| 439 |
| 440 |
| 441 class ExternalFourByteString extends StringBase implements String { |
| 442 // Checks for one-byte whitespaces only. |
| 443 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid |
| 444 // whitespaces. Add checking for multi-byte whitespace codepoints. |
| 445 bool _isWhitespace(int codePoint) { |
| 446 return |
| 447 (codePoint === 32) || // Space. |
| 448 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. |
| 449 } |
| 450 } |
| 451 |
| 452 |
| 416 class _StringMatch implements Match { | 453 class _StringMatch implements Match { |
| 417 const _StringMatch(int this._start, | 454 const _StringMatch(int this._start, |
| 418 String this.str, | 455 String this.str, |
| 419 String this.pattern); | 456 String this.pattern); |
| 420 | 457 |
| 421 int start() => _start; | 458 int start() => _start; |
| 422 int end() => _start + pattern.length; | 459 int end() => _start + pattern.length; |
| 423 String operator[](int g) => group(g); | 460 String operator[](int g) => group(g); |
| 424 int groupCount() => 0; | 461 int groupCount() => 0; |
| 425 | 462 |
| 426 String group(int group) { | 463 String group(int group) { |
| 427 if (group != 0) { | 464 if (group != 0) { |
| 428 throw new IndexOutOfRangeException(group); | 465 throw new IndexOutOfRangeException(group); |
| 429 } | 466 } |
| 430 return pattern; | 467 return pattern; |
| 431 } | 468 } |
| 432 | 469 |
| 433 List<String> groups(List<int> groups) { | 470 List<String> groups(List<int> groups) { |
| 434 List<String> result = new List<String>(); | 471 List<String> result = new List<String>(); |
| 435 for (int g in groups) { | 472 for (int g in groups) { |
| 436 result.add(group(g)); | 473 result.add(group(g)); |
| 437 } | 474 } |
| 438 return result; | 475 return result; |
| 439 } | 476 } |
| 440 | 477 |
| 441 final int _start; | 478 final int _start; |
| 442 final String str; | 479 final String str; |
| 443 final String pattern; | 480 final String pattern; |
| 444 } | 481 } |
| OLD | NEW |