Lines Matching refs:iter
39 noopGetIndex(UCharIterator * /*iter*/, UCharIteratorOrigin /*origin*/) {
44 noopMove(UCharIterator * /*iter*/, int32_t /*delta*/, UCharIteratorOrigin /*origin*/) {
49 noopHasNext(UCharIterator * /*iter*/) {
54 noopCurrent(UCharIterator * /*iter*/) {
59 noopGetState(const UCharIterator * /*iter*/) {
64 noopSetState(UCharIterator * /*iter*/, uint32_t /*state*/, UErrorCode *pErrorCode) {
92 stringIteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin) {
97 return iter->start;
99 return iter->index;
101 return iter->limit;
103 return iter->length;
112 stringIteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin) {
120 pos=iter->start+delta;
123 pos=iter->index+delta;
126 pos=iter->limit+delta;
129 pos=iter->length+delta;
135 if(pos<iter->start) {
136 pos=iter->start;
137 } else if(pos>iter->limit) {
138 pos=iter->limit;
141 return iter->index=pos;
145 stringIteratorHasNext(UCharIterator *iter) {
146 return iter->index<iter->limit;
150 stringIteratorHasPrevious(UCharIterator *iter) {
151 return iter->index>iter->start;
155 stringIteratorCurrent(UCharIterator *iter) {
156 if(iter->index<iter->limit) {
157 return ((const UChar *)(iter->context))[iter->index];
164 stringIteratorNext(UCharIterator *iter) {
165 if(iter->index<iter->limit) {
166 return ((const UChar *)(iter->context))[iter->index++];
173 stringIteratorPrevious(UCharIterator *iter) {
174 if(iter->index>iter->start) {
175 return ((const UChar *)(iter->context))[--iter->index];
182 stringIteratorGetState(const UCharIterator *iter) {
183 return (uint32_t)iter->index;
187 stringIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode) {
190 } else if(iter==NULL) {
192 } else if((int32_t)state<iter->start || iter->limit<(int32_t)state) {
195 iter->index=(int32_t)state;
214 uiter_setString(UCharIterator *iter, const UChar *s, int32_t length) {
215 if(iter!=0) {
217 *iter=stringIterator;
218 iter->context=s;
220 iter->length=length;
222 iter->length=u_strlen(s);
224 iter->limit=iter->length;
226 *iter=noopIterator;
245 utf16BEIteratorGet(UCharIterator *iter, int32_t index) {
246 const uint8_t *p=(const uint8_t *)iter->context;
251 utf16BEIteratorCurrent(UCharIterator *iter) {
254 if((index=iter->index)<iter->limit) {
255 return utf16BEIteratorGet(iter, index);
262 utf16BEIteratorNext(UCharIterator *iter) {
265 if((index=iter->index)<iter->limit) {
266 iter->index=index+1;
267 return utf16BEIteratorGet(iter, index);
274 utf16BEIteratorPrevious(UCharIterator *iter) {
277 if((index=iter->index)>iter->start) {
278 iter->index=--index;
279 return utf16BEIteratorGet(iter, index);
325 uiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length) {
326 if(iter!=NULL) {
334 uiter_setString(iter, (const UChar *)s, length);
338 *iter=utf16BEIterator;
339 iter->context=s;
341 iter->length=length;
343 iter->length=utf16BE_strlen(s);
345 iter->limit=iter->length;
347 *iter=noopIterator;
362 characterIteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin) {
367 return ((CharacterIterator *)(iter->context))->startIndex();
369 return ((CharacterIterator *)(iter->context))->getIndex();
371 return ((CharacterIterator *)(iter->context))->endIndex();
373 return ((CharacterIterator *)(iter->context))->getLength();
382 characterIteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin) {
385 ((CharacterIterator *)(iter->context))->setIndex(delta);
386 return ((CharacterIterator *)(iter->context))->getIndex();
390 return ((CharacterIterator *)(iter->context))->move(delta, (CharacterIterator::EOrigin)origin);
392 ((CharacterIterator *)(iter->context))->setIndex(((CharacterIterator *)(iter->context))->getLength()+delta);
393 return ((CharacterIterator *)(iter->context))->getIndex();
402 characterIteratorHasNext(UCharIterator *iter) {
403 return ((CharacterIterator *)(iter->context))->hasNext();
407 characterIteratorHasPrevious(UCharIterator *iter) {
408 return ((CharacterIterator *)(iter->context))->hasPrevious();
412 characterIteratorCurrent(UCharIterator *iter) {
415 c=((CharacterIterator *)(iter->context))->current();
416 if(c!=0xffff || ((CharacterIterator *)(iter->context))->hasNext()) {
424 characterIteratorNext(UCharIterator *iter) {
425 if(((CharacterIterator *)(iter->context))->hasNext()) {
426 return ((CharacterIterator *)(iter->context))->nextPostInc();
433 characterIteratorPrevious(UCharIterator *iter) {
434 if(((CharacterIterator *)(iter->context))->hasPrevious()) {
435 return ((CharacterIterator *)(iter->context))->previous();
442 characterIteratorGetState(const UCharIterator *iter) {
443 return ((CharacterIterator *)(iter->context))->getIndex();
447 characterIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode) {
450 } else if(iter==NULL || iter->context==NULL) {
452 } else if((int32_t)state<((CharacterIterator *)(iter->context))->startIndex() || ((CharacterIterator *)(iter->context))->endIndex()<(int32_t)state) {
455 ((CharacterIterator *)(iter->context))->setIndex((int32_t)state);
474 uiter_setCharacterIterator(UCharIterator *iter, CharacterIterator *charIter) {
475 if(iter!=0) {
477 *iter=characterIteratorWrapper;
478 iter->context=charIter;
480 *iter=noopIterator;
497 replaceableIteratorCurrent(UCharIterator *iter) {
498 if(iter->index<iter->limit) {
499 return ((Replaceable *)(iter->context))->charAt(iter->index);
506 replaceableIteratorNext(UCharIterator *iter) {
507 if(iter->index<iter->limit) {
508 return ((Replaceable *)(iter->context))->charAt(iter->index++);
515 replaceableIteratorPrevious(UCharIterator *iter) {
516 if(iter->index>iter->start) {
517 return ((Replaceable *)(iter->context))->charAt(--iter->index);
538 uiter_setReplaceable(UCharIterator *iter, const Replaceable *rep) {
539 if(iter!=0) {
541 *iter=replaceableIterator;
542 iter->context=rep;
543 iter->limit=iter->length=rep->length();
545 *iter=noopIterator;
557 * to introduce a uiter_close(iter).
589 utf8IteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin) {
595 if(iter->index<0) {
601 s=(const uint8_t *)iter->context;
603 limit=iter->start; /* count up to the UTF-8 index */
609 iter->start=i; /* just in case setState() did not get us to a code point boundary */
610 if(i==iter->limit) {
611 iter->length=index; /* in case it was <0 or wrong */
613 if(iter->reservedField!=0) {
616 iter->index=index;
618 return iter->index;
621 if(iter->length<0) {
626 s=(const uint8_t *)iter->context;
627 if(iter->index<0) {
633 limit=iter->start;
641 /* assume i==limit==iter->start, set the UTF-16 index */
642 iter->start=i; /* just in case setState() did not get us to a code point boundary */
643 iter->index= iter->reservedField!=0 ? length-1 : length;
645 i=iter->start;
646 length=iter->index;
647 if(iter->reservedField!=0) {
653 limit=iter->limit;
658 iter->length=length;
660 return iter->length;
669 utf8IteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin) {
682 /* iter->index<0 (unknown) is possible */
685 if(iter->index>=0) {
686 pos=iter->index+delta;
696 if(iter->length>=0) {
697 pos=iter->length+delta;
701 iter->index=-1;
702 iter->start=iter->limit;
703 iter->reservedField=0;
720 iter->index=iter->start=iter->reservedField=0;
722 } else if(iter->length>=0 && pos>=iter->length) {
723 iter->index=iter->length;
724 iter->start=iter->limit;
725 iter->reservedField=0;
726 return iter->index;
730 if(iter->index<0 || pos<iter->index/2) {
732 iter->index=iter->start=iter->reservedField=0;
733 } else if(iter->length>=0 && (iter->length-pos)<(pos-iter->index)) {
739 iter->index=iter->length;
740 iter->start=iter->limit;
741 iter->reservedField=0;
744 delta=pos-iter->index;
746 return iter->index; /* nothing to do */
752 } else if(-delta>=iter->start) {
754 iter->index=iter->start=iter->reservedField=0;
756 } else if(delta>=(iter->limit-iter->start)) {
758 iter->index=iter->length; /* may or may not be <0 (unknown) */
759 iter->start=iter->limit;
760 iter->reservedField=0;
761 return iter->index>=0 ? iter->index : (int32_t)UITER_UNKNOWN_INDEX;
768 s=(const uint8_t *)iter->context;
769 pos=iter->index; /* could be <0 (unknown) */
770 i=iter->start;
773 int32_t limit=iter->limit;
774 if(iter->reservedField!=0) {
775 iter->reservedField=0;
789 iter->reservedField=c;
795 if(iter->length<0 && iter->index>=0) {
796 iter->length= iter->reservedField==0 ? pos : pos+1;
797 } else if(iter->index<0 && iter->length>=0) {
798 iter->index= iter->reservedField==0 ? iter->length : iter->length-1;
803 if(iter->reservedField!=0) {
804 iter->reservedField=0;
820 iter->reservedField=c;
827 iter->start=i;
828 if(iter->index>=0) {
829 return iter->index=pos;
833 return iter->index=i; /* reached the beginning */
842 utf8IteratorHasNext(UCharIterator *iter) {
843 return iter->start<iter->limit || iter->reservedField!=0;
847 utf8IteratorHasPrevious(UCharIterator *iter) {
848 return iter->start>0;
852 utf8IteratorCurrent(UCharIterator *iter) {
853 if(iter->reservedField!=0) {
854 return U16_TRAIL(iter->reservedField);
855 } else if(iter->start<iter->limit) {
856 const uint8_t *s=(const uint8_t *)iter->context;
858 int32_t i=iter->start;
860 U8_NEXT_OR_FFFD(s, i, iter->limit, c);
872 utf8IteratorNext(UCharIterator *iter) {
875 if(iter->reservedField!=0) {
876 UChar trail=U16_TRAIL(iter->reservedField);
877 iter->reservedField=0;
878 if((index=iter->index)>=0) {
879 iter->index=index+1;
882 } else if(iter->start<iter->limit) {
883 const uint8_t *s=(const uint8_t *)iter->context;
886 U8_NEXT_OR_FFFD(s, iter->start, iter->limit, c);
887 if((index=iter->index)>=0) {
888 iter->index=++index;
889 if(iter->length<0 && iter->start==iter->limit) {
890 iter->length= c<=0xffff ? index : index+1;
892 } else if(iter->start==iter->limit && iter->length>=0) {
893 iter->index= c<=0xffff ? iter->length : iter->length-1;
898 iter->reservedField=c;
907 utf8IteratorPrevious(UCharIterator *iter) {
910 if(iter->reservedField!=0) {
911 UChar lead=U16_LEAD(iter->reservedField);
912 iter->reservedField=0;
913 iter->start-=4; /* we stayed behind the supplementary code point; go before it now */
914 if((index=iter->index)>0) {
915 iter->index=index-1;
918 } else if(iter->start>0) {
919 const uint8_t *s=(const uint8_t *)iter->context;
922 U8_PREV_OR_FFFD(s, 0, iter->start, c);
923 if((index=iter->index)>0) {
924 iter->index=index-1;
925 } else if(iter->start<=1) {
926 iter->index= c<=0xffff ? iter->start : iter->start+1;
931 iter->start+=4; /* back to behind this supplementary code point for consistent state */
932 iter->reservedField=c;
941 utf8IteratorGetState(const UCharIterator *iter) {
942 uint32_t state=(uint32_t)(iter->start<<1);
943 if(iter->reservedField!=0) {
950 utf8IteratorSetState(UCharIterator *iter,
956 } else if(iter==NULL) {
958 } else if(state==utf8IteratorGetState(iter)) {
964 if((state==0 ? index<0 : index<4) || iter->limit<index) {
967 iter->start=index; /* restore UTF-8 byte index */
969 iter->index=index;
971 iter->index=-1; /* unknown UTF-16 index */
974 iter->reservedField=0;
978 U8_PREV_OR_FFFD((const uint8_t *)iter->context, 0, index, c);
982 iter->reservedField=c;
1004 uiter_setUTF8(UCharIterator *iter, const char *s, int32_t length) {
1005 if(iter!=0) {
1007 *iter=utf8Iterator;
1008 iter->context=s;
1010 iter->limit=length;
1012 iter->limit=(int32_t)uprv_strlen(s);
1014 iter->length= iter->limit<=1 ? iter->limit : -1;
1016 *iter=noopIterator;
1024 uiter_current32(UCharIterator *iter) {
1027 c=iter->current(iter);
1034 iter->move(iter, 1, UITER_CURRENT);
1035 if(U16_IS_TRAIL(c2=iter->current(iter))) {
1040 iter->move(iter, -1, UITER_CURRENT);
1042 if(U16_IS_LEAD(c2=iter->previous(iter))) {
1047 iter->move(iter, 1, UITER_CURRENT);
1055 uiter_next32(UCharIterator *iter) {
1058 c=iter->next(iter);
1060 if(U16_IS_TRAIL(c2=iter->next(iter))) {
1064 iter->move(iter, -1, UITER_CURRENT);
1071 uiter_previous32(UCharIterator *iter) {
1074 c=iter->previous(iter);
1076 if(U16_IS_LEAD(c2=iter->previous(iter))) {
1080 iter->move(iter, 1, UITER_CURRENT);
1087 uiter_getState(const UCharIterator *iter) {
1088 if(iter==NULL || iter->getState==NULL) {
1091 return iter->getState(iter);
1096 uiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode) {
1099 } else if(iter==NULL) {
1101 } else if(iter->setState==NULL) {
1104 iter->setState(iter, state, pErrorCode);