Lines Matching refs:iter
34 noopGetIndex(UCharIterator * /*iter*/, UCharIteratorOrigin /*origin*/) {
39 noopMove(UCharIterator * /*iter*/, int32_t /*delta*/, UCharIteratorOrigin /*origin*/) {
44 noopHasNext(UCharIterator * /*iter*/) {
49 noopCurrent(UCharIterator * /*iter*/) {
54 noopGetState(const UCharIterator * /*iter*/) {
59 noopSetState(UCharIterator * /*iter*/, uint32_t /*state*/, UErrorCode *pErrorCode) {
87 stringIteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin) {
92 return iter->start;
94 return iter->index;
96 return iter->limit;
98 return iter->length;
107 stringIteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin) {
115 pos=iter->start+delta;
118 pos=iter->index+delta;
121 pos=iter->limit+delta;
124 pos=iter->length+delta;
130 if(pos<iter->start) {
131 pos=iter->start;
132 } else if(pos>iter->limit) {
133 pos=iter->limit;
136 return iter->index=pos;
140 stringIteratorHasNext(UCharIterator *iter) {
141 return iter->index<iter->limit;
145 stringIteratorHasPrevious(UCharIterator *iter) {
146 return iter->index>iter->start;
150 stringIteratorCurrent(UCharIterator *iter) {
151 if(iter->index<iter->limit) {
152 return ((const UChar *)(iter->context))[iter->index];
159 stringIteratorNext(UCharIterator *iter) {
160 if(iter->index<iter->limit) {
161 return ((const UChar *)(iter->context))[iter->index++];
168 stringIteratorPrevious(UCharIterator *iter) {
169 if(iter->index>iter->start) {
170 return ((const UChar *)(iter->context))[--iter->index];
177 stringIteratorGetState(const UCharIterator *iter) {
178 return (uint32_t)iter->index;
182 stringIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode) {
185 } else if(iter==NULL) {
187 } else if((int32_t)state<iter->start || iter->limit<(int32_t)state) {
190 iter->index=(int32_t)state;
209 uiter_setString(UCharIterator *iter, const UChar *s, int32_t length) {
210 if(iter!=0) {
212 *iter=stringIterator;
213 iter->context=s;
215 iter->length=length;
217 iter->length=u_strlen(s);
219 iter->limit=iter->length;
221 *iter=noopIterator;
240 utf16BEIteratorGet(UCharIterator *iter, int32_t index) {
241 const uint8_t *p=(const uint8_t *)iter->context;
246 utf16BEIteratorCurrent(UCharIterator *iter) {
249 if((index=iter->index)<iter->limit) {
250 return utf16BEIteratorGet(iter, index);
257 utf16BEIteratorNext(UCharIterator *iter) {
260 if((index=iter->index)<iter->limit) {
261 iter->index=index+1;
262 return utf16BEIteratorGet(iter, index);
269 utf16BEIteratorPrevious(UCharIterator *iter) {
272 if((index=iter->index)>iter->start) {
273 iter->index=--index;
274 return utf16BEIteratorGet(iter, index);
320 uiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length) {
321 if(iter!=NULL) {
329 uiter_setString(iter, (const UChar *)s, length);
333 *iter=utf16BEIterator;
334 iter->context=s;
336 iter->length=length;
338 iter->length=utf16BE_strlen(s);
340 iter->limit=iter->length;
342 *iter=noopIterator;
357 characterIteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin) {
362 return ((CharacterIterator *)(iter->context))->startIndex();
364 return ((CharacterIterator *)(iter->context))->getIndex();
366 return ((CharacterIterator *)(iter->context))->endIndex();
368 return ((CharacterIterator *)(iter->context))->getLength();
377 characterIteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin) {
380 ((CharacterIterator *)(iter->context))->setIndex(delta);
381 return ((CharacterIterator *)(iter->context))->getIndex();
385 return ((CharacterIterator *)(iter->context))->move(delta, (CharacterIterator::EOrigin)origin);
387 ((CharacterIterator *)(iter->context))->setIndex(((CharacterIterator *)(iter->context))->getLength()+delta);
388 return ((CharacterIterator *)(iter->context))->getIndex();
397 characterIteratorHasNext(UCharIterator *iter) {
398 return ((CharacterIterator *)(iter->context))->hasNext();
402 characterIteratorHasPrevious(UCharIterator *iter) {
403 return ((CharacterIterator *)(iter->context))->hasPrevious();
407 characterIteratorCurrent(UCharIterator *iter) {
410 c=((CharacterIterator *)(iter->context))->current();
411 if(c!=0xffff || ((CharacterIterator *)(iter->context))->hasNext()) {
419 characterIteratorNext(UCharIterator *iter) {
420 if(((CharacterIterator *)(iter->context))->hasNext()) {
421 return ((CharacterIterator *)(iter->context))->nextPostInc();
428 characterIteratorPrevious(UCharIterator *iter) {
429 if(((CharacterIterator *)(iter->context))->hasPrevious()) {
430 return ((CharacterIterator *)(iter->context))->previous();
437 characterIteratorGetState(const UCharIterator *iter) {
438 return ((CharacterIterator *)(iter->context))->getIndex();
442 characterIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode) {
445 } else if(iter==NULL || iter->context==NULL) {
447 } else if((int32_t)state<((CharacterIterator *)(iter->context))->startIndex() || ((CharacterIterator *)(iter->context))->endIndex()<(int32_t)state) {
450 ((CharacterIterator *)(iter->context))->setIndex((int32_t)state);
469 uiter_setCharacterIterator(UCharIterator *iter, CharacterIterator *charIter) {
470 if(iter!=0) {
472 *iter=characterIteratorWrapper;
473 iter->context=charIter;
475 *iter=noopIterator;
492 replaceableIteratorCurrent(UCharIterator *iter) {
493 if(iter->index<iter->limit) {
494 return ((Replaceable *)(iter->context))->charAt(iter->index);
501 replaceableIteratorNext(UCharIterator *iter) {
502 if(iter->index<iter->limit) {
503 return ((Replaceable *)(iter->context))->charAt(iter->index++);
510 replaceableIteratorPrevious(UCharIterator *iter) {
511 if(iter->index>iter->start) {
512 return ((Replaceable *)(iter->context))->charAt(--iter->index);
533 uiter_setReplaceable(UCharIterator *iter, const Replaceable *rep) {
534 if(iter!=0) {
536 *iter=replaceableIterator;
537 iter->context=rep;
538 iter->limit=iter->length=rep->length();
540 *iter=noopIterator;
552 * to introduce a uiter_close(iter).
584 utf8IteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin) {
590 if(iter->index<0) {
596 s=(const uint8_t *)iter->context;
598 limit=iter->start; /* count up to the UTF-8 index */
608 iter->start=i; /* just in case setState() did not get us to a code point boundary */
609 if(i==iter->limit) {
610 iter->length=index; /* in case it was <0 or wrong */
612 if(iter->reservedField!=0) {
615 iter->index=index;
617 return iter->index;
620 if(iter->length<0) {
625 s=(const uint8_t *)iter->context;
626 if(iter->index<0) {
632 limit=iter->start;
644 /* assume i==limit==iter->start, set the UTF-16 index */
645 iter->start=i; /* just in case setState() did not get us to a code point boundary */
646 iter->index= iter->reservedField!=0 ? length-1 : length;
648 i=iter->start;
649 length=iter->index;
650 if(iter->reservedField!=0) {
656 limit=iter->limit;
665 iter->length=length;
667 return iter->length;
676 utf8IteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin) {
689 /* iter->index<0 (unknown) is possible */
692 if(iter->index>=0) {
693 pos=iter->index+delta;
703 if(iter->length>=0) {
704 pos=iter->length+delta;
708 iter->index=-1;
709 iter->start=iter->limit;
710 iter->reservedField=0;
727 iter->index=iter->start=iter->reservedField=0;
729 } else if(iter->length>=0 && pos>=iter->length) {
730 iter->index=iter->length;
731 iter->start=iter->limit;
732 iter->reservedField=0;
733 return iter->index;
737 if(iter->index<0 || pos<iter->index/2) {
739 iter->index=iter->start=iter->reservedField=0;
740 } else if(iter->length>=0 && (iter->length-pos)<(pos-iter->index)) {
746 iter->index=iter->length;
747 iter->start=iter->limit;
748 iter->reservedField=0;
751 delta=pos-iter->index;
753 return iter->index; /* nothing to do */
759 } else if(-delta>=iter->start) {
761 iter->index=iter->start=iter->reservedField=0;
763 } else if(delta>=(iter->limit-iter->start)) {
765 iter->index=iter->length; /* may or may not be <0 (unknown) */
766 iter->start=iter->limit;
767 iter->reservedField=0;
768 return iter->index>=0 ? iter->index : (int32_t)UITER_UNKNOWN_INDEX;
775 s=(const uint8_t *)iter->context;
776 pos=iter->index; /* could be <0 (unknown) */
777 i=iter->start;
780 int32_t limit=iter->limit;
781 if(iter->reservedField!=0) {
782 iter->reservedField=0;
796 iter->reservedField=c;
802 if(iter->length<0 && iter->index>=0) {
803 iter->length= iter->reservedField==0 ? pos : pos+1;
804 } else if(iter->index<0 && iter->length>=0) {
805 iter->index= iter->reservedField==0 ? iter->length : iter->length-1;
810 if(iter->reservedField!=0) {
811 iter->reservedField=0;
827 iter->reservedField=c;
834 iter->start=i;
835 if(iter->index>=0) {
836 return iter->index=pos;
840 return iter->index=i; /* reached the beginning */
849 utf8IteratorHasNext(UCharIterator *iter) {
850 return iter->start<iter->limit || iter->reservedField!=0;
854 utf8IteratorHasPrevious(UCharIterator *iter) {
855 return iter->start>0;
859 utf8IteratorCurrent(UCharIterator *iter) {
860 if(iter->reservedField!=0) {
861 return U16_TRAIL(iter->reservedField);
862 } else if(iter->start<iter->limit) {
863 const uint8_t *s=(const uint8_t *)iter->context;
865 int32_t i=iter->start;
867 U8_NEXT(s, i, iter->limit, c);
881 utf8IteratorNext(UCharIterator *iter) {
884 if(iter->reservedField!=0) {
885 UChar trail=U16_TRAIL(iter->reservedField);
886 iter->reservedField=0;
887 if((index=iter->index)>=0) {
888 iter->index=index+1;
891 } else if(iter->start<iter->limit) {
892 const uint8_t *s=(const uint8_t *)iter->context;
895 U8_NEXT(s, iter->start, iter->limit, c);
896 if((index=iter->index)>=0) {
897 iter->index=++index;
898 if(iter->length<0 && iter->start==iter->limit) {
899 iter->length= c<=0xffff ? index : index+1;
901 } else if(iter->start==iter->limit && iter->length>=0) {
902 iter->index= c<=0xffff ? iter->length : iter->length-1;
909 iter->reservedField=c;
918 utf8IteratorPrevious(UCharIterator *iter) {
921 if(iter->reservedField!=0) {
922 UChar lead=U16_LEAD(iter->reservedField);
923 iter->reservedField=0;
924 iter->start-=4; /* we stayed behind the supplementary code point; go before it now */
925 if((index=iter->index)>0) {
926 iter->index=index-1;
929 } else if(iter->start>0) {
930 const uint8_t *s=(const uint8_t *)iter->context;
933 U8_PREV(s, 0, iter->start, c);
934 if((index=iter->index)>0) {
935 iter->index=index-1;
936 } else if(iter->start<=1) {
937 iter->index= c<=0xffff ? iter->start : iter->start+1;
944 iter->start+=4; /* back to behind this supplementary code point for consistent state */
945 iter->reservedField=c;
954 utf8IteratorGetState(const UCharIterator *iter) {
955 uint32_t state=(uint32_t)(iter->start<<1);
956 if(iter->reservedField!=0) {
963 utf8IteratorSetState(UCharIterator *iter,
969 } else if(iter==NULL) {
971 } else if(state==utf8IteratorGetState(iter)) {
977 if((state==0 ? index<0 : index<4) || iter->limit<index) {
980 iter->start=index; /* restore UTF-8 byte index */
982 iter->index=index;
984 iter->index=-1; /* unknown UTF-16 index */
987 iter->reservedField=0;
991 U8_PREV((const uint8_t *)iter->context, 0, index, c);
995 iter->reservedField=c;
1017 uiter_setUTF8(UCharIterator *iter, const char *s, int32_t length) {
1018 if(iter!=0) {
1020 *iter=utf8Iterator;
1021 iter->context=s;
1023 iter->limit=length;
1025 iter->limit=(int32_t)uprv_strlen(s);
1027 iter->length= iter->limit<=1 ? iter->limit : -1;
1029 *iter=noopIterator;
1037 uiter_current32(UCharIterator *iter) {
1040 c=iter->current(iter);
1047 iter->move(iter, 1, UITER_CURRENT);
1048 if(UTF_IS_SECOND_SURROGATE(c2=iter->current(iter))) {
1053 iter->move(iter, -1, UITER_CURRENT);
1055 if(UTF_IS_FIRST_SURROGATE(c2=iter->previous(iter))) {
1060 iter->move(iter, 1, UITER_CURRENT);
1068 uiter_next32(UCharIterator *iter) {
1071 c=iter->next(iter);
1073 if(UTF_IS_SECOND_SURROGATE(c2=iter->next(iter))) {
1077 iter->move(iter, -1, UITER_CURRENT);
1084 uiter_previous32(UCharIterator *iter) {
1087 c=iter->previous(iter);
1089 if(UTF_IS_FIRST_SURROGATE(c2=iter->previous(iter))) {
1093 iter->move(iter, 1, UITER_CURRENT);
1100 uiter_getState(const UCharIterator *iter) {
1101 if(iter==NULL || iter->getState==NULL) {
1104 return iter->getState(iter);
1109 uiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode) {
1112 } else if(iter==NULL) {
1114 } else if(iter->setState==NULL) {
1117 iter->setState(iter, state, pErrorCode);