550 |
550 |
551 skipThroughAll:aCollection |
551 skipThroughAll:aCollection |
552 "skip for and through the sequence given by the argument, aCollection; |
552 "skip for and through the sequence given by the argument, aCollection; |
553 return nil if not found, self otherwise. |
553 return nil if not found, self otherwise. |
554 On a successful match, the next read will return elements after aCollection; |
554 On a successful match, the next read will return elements after aCollection; |
555 if no match was found, the receiver will be positioned at the end." |
555 if no match was found, the receiver will be positioned at the end. |
|
556 This is redefined here, to make use of positioning." |
556 |
557 |
557 |oldPos buffer l first idx| |
558 |oldPos buffer l first idx| |
558 |
559 |
559 oldPos := self position. |
560 oldPos := self position. |
560 |
561 |
561 l := aCollection size. |
562 l := aCollection size. |
562 first := aCollection at:1. |
563 first := aCollection at:1. |
563 [self atEnd] whileFalse:[ |
564 [self atEnd] whileFalse:[ |
564 buffer := self next:l. |
565 buffer := self nextAvailable:l. |
565 buffer = aCollection ifTrue:[ |
566 buffer = aCollection ifTrue:[ |
566 ^ self |
567 ^ self |
567 ]. |
568 ]. |
568 idx := buffer indexOf:first startingAt:2. |
569 idx := buffer indexOf:first startingAt:2. |
569 idx == 0 ifFalse:[ |
570 idx == 0 ifFalse:[ |
570 self position:(self position - l + idx - 1) |
571 self position:(self position - l + idx - 1) |
571 ] |
572 ] |
572 ]. |
573 ]. |
573 ^ nil |
574 ^ nil |
574 |
575 |
575 " |
576 " |
576 |s| |
577 |s| |
577 s := ReadStream on:'12345678901234567890'. |
578 s := ReadStream on:'12345678901234567890'. |
578 s skipThroughAll:'901'. |
579 s skipThroughAll:'901'. |
579 s upToEnd |
580 s upToEnd |
580 " |
581 " |
581 |
582 " |
582 "Modified: 26.6.1996 / 09:27:25 / cg" |
583 |s| |
|
584 s := ReadStream on:'12345678901234567890'. |
|
585 s skipThroughAll:'1234'. |
|
586 s upToEnd |
|
587 " |
|
588 " |
|
589 |s| |
|
590 s := ReadStream on:'12345678901234567890'. |
|
591 s skipThroughAll:'999'. |
|
592 s atEnd |
|
593 " |
|
594 |
583 "Created: 26.6.1996 / 09:35:35 / cg" |
595 "Created: 26.6.1996 / 09:35:35 / cg" |
|
596 "Modified: 11.1.1997 / 19:10:26 / cg" |
584 ! |
597 ! |
585 |
598 |
586 skipToAll:aCollection |
599 skipToAll:aCollection |
587 "skip for the sequence given by the argument, aCollection; |
600 "skip for the sequence given by the argument, aCollection; |
588 return nil if not found, self otherwise. |
601 return nil if not found, self otherwise. |