1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
20 #ifndef _Standard_String_HeaderFile
21 # define _Standard_String_HeaderFile
23 # ifndef _Standard_TypeDef_HeaderFile
24 # include <Standard_TypeDef.hxx>
27 #define INF(X,Y) (((X)<(Y))?(X):(Y))
31 #define STRLEN(s,i) {(i) = 0;while((s)[(i)++] != '\0');(i)--;}
32 #define EXTSTRLEN(s,i) {(i) = 0;while((s)[(i)++] != 0);(i)--;}
33 #define STRCPY(s1,s2,i) {for(LoopIndex=0; LoopIndex<(i); LoopIndex++)(s1)[LoopIndex] = (s2)[LoopIndex];}
34 #define STRCAT(s1,i,s2,j) {for(LoopIndex=0; LoopIndex<(j); LoopIndex++) (s1)[(i)+LoopIndex] = (s2)[LoopIndex];}
36 //# ifdef __Standard_DLL
37 # ifdef _Standard_CString_SourceFile
38 __Standard_API const Standard_Integer *MaskEndIntegerString = static_MaskEndIntegerString ;
40 __Standard_APIEXTERN const Standard_Integer *MaskEndIntegerString ;
43 //Standard_IMPORT const Standard_Integer *MaskEndIntegerString ;
47 // Algorithme utilise pour le calcul des longueurs de strings
48 // Je suppose que les octets sont de l'ascii 7 bits.
49 // Si un des octets d'un mot est a zero et si on soustrait 0x01010101 a ce
50 // mot, l'octet a zero change de signe.
51 // Reciproquement si (( Word - 0x01010101 ) & 0x80808080 ) != 0
52 // alors Word a un octet a zero.
54 // Si on a des octets negatifs et si on applique le resultat ci-dessus a
55 // ( Word & 0x7f7f7f7f ), cela sera vrai sauf si un des octets vaut 0x80
56 // auquel cas on trouvera un octet a zero a tort.
58 // Conclusion : il suffit de controler la presence d'un octet a zero a partir
59 // du debut du mot ou l'on croira en avoir trouve un pour traiter
60 // correctement les octets qui valent 0x80.
62 // La meme chose est vraie pour les extendedstrings.
64 // D'autre part afin d'accelerer les traitements, on teste si les chaines
65 // sont alignees sur des mots de 32 bits ( AND de l'adresse avec 3 ) ou
66 // sont alignees sur des shorts de 16 bits ( AND de l'adresse avec 1 ).
68 inline Standard_Boolean CStringTestOfZero(const Standard_Integer aString )
70 return ( ((( aString & 0x7f7f7f7f ) - \
71 0x01010101 ) & 0x80808080 ) == 0 ) ;
74 inline Standard_Boolean HalfCStringTestOfZero(const Standard_ExtCharacter anExtCharacter )
76 return ( ((( anExtCharacter & 0x7f7f ) - 0x0101 ) & 0x8080 ) == 0 ) ;
79 inline Standard_Boolean ExtStringTestOfZero(const Standard_Integer anExtString )
81 return ( ((( anExtString & 0x7fff7fff ) - \
82 0x00010001 ) & 0x80008000 ) == 0 ) ;
85 #define STRINGLEN( aString , LoopIndex ) { \
86 if ((ptrdiff_t(aString) & 1) == 0) { \
88 if ((ptrdiff_t(aString) & 3) == 0) { \
89 while (CStringTestOfZero(((Standard_Integer *)aString)[LoopIndex++])); \
90 LoopIndex = ( LoopIndex << 2 ) - 4 ; \
93 while (HalfCStringTestOfZero(((Standard_ExtCharacter *)aString)[LoopIndex++])); \
94 LoopIndex = ( LoopIndex << 1 ) - 2 ; \
96 while (aString[LoopIndex++] != '\0'); \
100 STRLEN( aString , LoopIndex ) ; \
103 #define EXTSTRINGLEN( anExtString , LoopIndex ) { \
104 if ((ptrdiff_t(anExtString) & 3) == 0) { \
106 while (ExtStringTestOfZero(((Standard_Integer *)anExtString)[LoopIndex++]));\
107 LoopIndex = ( LoopIndex << 1 ) - 2 ; \
108 if ( anExtString[ LoopIndex ] != 0 ) \
112 EXTSTRLEN( anExtString , LoopIndex ) ; \
115 // aStringOut is an AsciiString and is word aligned
116 // aStringIn is a CString and may be not word aligned
117 #define CSTRINGCOPY( aStringOut , aStringIn , aStringLen ) { \
118 Standard_Integer LoopIndex = (Standard_Integer)(ptrdiff_t(aStringIn) & 3) ; \
119 if ( ( LoopIndex & 1 ) == 0 ) { \
120 if ( LoopIndex == 0 ) { \
121 for (; LoopIndex <= ( aStringLen >> 2 ) ; LoopIndex++ ) { \
122 ((Standard_Integer *) aStringOut )[ LoopIndex ] = \
123 ((Standard_Integer *) aStringIn )[ LoopIndex ] ; \
127 for ( LoopIndex = 0 ; LoopIndex <= ( aStringLen >> 1) ; LoopIndex++ ) { \
128 ((Standard_ExtCharacter *) aStringOut )[ LoopIndex ] = \
129 ((Standard_ExtCharacter *) aStringIn )[ LoopIndex ] ; \
134 STRCPY( aStringOut , aStringIn , aStringLen + 1 ) ; \
137 // aStringOut is an AsciiString and is word aligned
138 // aStringIn is an AsciiString and is word aligned
139 #define ASCIISTRINGCOPY( aStringOut , aStringIn , aStringLen ) { \
140 Standard_Integer LoopIndex ; \
142 for(; LoopIndex <= ( aStringLen >> 2 ) ; LoopIndex++ ) { \
143 ((Standard_Integer *) aStringOut )[ LoopIndex ] = \
144 ((Standard_Integer *) aStringIn )[ LoopIndex ] ; \
148 #define STRINGCAT( aStringOut , aStringOutLen , aStringIn , aStringInLen ) { \
149 Standard_Integer LoopIndex ; \
150 if ((ptrdiff_t(&aStringOut[ aStringOutLen ]) & 1) == 0 && \
151 (ptrdiff_t(aStringIn) & 1 ) == 0 ) { \
153 if ((ptrdiff_t(&aStringOut[ aStringOutLen ]) & 3 ) == 0 && \
154 (ptrdiff_t(aStringIn) & 3 ) == 0 ) { \
155 for (; LoopIndex <= ( aStringInLen >> 2 ) ; LoopIndex++ ) { \
156 ((Standard_Integer *) aStringOut )[ ( aStringOutLen >> 2 ) + \
157 LoopIndex ] = ((Standard_Integer *) aStringIn )[ LoopIndex ] ; \
161 for (; LoopIndex <= ( aStringInLen >> 1 ) ; LoopIndex++ ) { \
162 ((Standard_ExtCharacter *) aStringOut )[ ( aStringOutLen >> 1 ) + \
163 LoopIndex ] = ((Standard_ExtCharacter *) aStringIn )[ LoopIndex ] ; \
168 STRCPY( &aStringOut[ aStringOutLen ] , aStringIn , aStringInLen + 1 ) ; \
171 // aString is an AsciiString and is word aligned
172 // anOtherString is aCString and may be not word aligned
173 // aStringLen is the length of aString and anOtherString
174 #define CSTRINGEQUAL( aString , anOtherString , aStringLen , KEqual ) { \
175 KEqual = Standard_True ; \
176 Standard_Integer LoopIndex = Standard_Integer(ptrdiff_t(anOtherString) & 3); \
177 if ( ( LoopIndex & 1 ) == 0 ) { \
178 if ( LoopIndex == 0 ) { \
179 for (; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
180 if (((Standard_Integer *) aString )[ LoopIndex ] != \
181 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
182 KEqual = Standard_False ; \
186 if ( KEqual == Standard_True && \
187 (((Standard_Integer *) aString )[ LoopIndex ] & \
188 MaskEndIntegerString[ aStringLen & 3 ]) != \
189 (((Standard_Integer *) anOtherString )[ LoopIndex ] & \
190 MaskEndIntegerString[ aStringLen & 3 ] ) ) \
191 KEqual = Standard_False ; \
194 for ( LoopIndex = 0 ; LoopIndex < (( aStringLen + 1) >> 1) ; LoopIndex++ ) { \
195 if (((Standard_ExtCharacter *) aString )[ LoopIndex ] != \
196 ((Standard_ExtCharacter *) anOtherString )[ LoopIndex ] ) { \
197 KEqual = Standard_False ; \
204 for ( LoopIndex = 0 ; LoopIndex < aStringLen ; LoopIndex++ ) { \
205 if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
206 KEqual = Standard_False ; \
213 // aString is an AsciiString and is word aligned
214 // anOtherString is aCString and may be not word aligned
215 // aStringLen is the length of aString.
216 // The length of anOtherString is unknown
217 #define LCSTRINGEQUAL( aString , aStringLen , anOtherString , KEqual ) { \
218 KEqual = Standard_True ; \
219 Standard_Integer LoopIndex = Standard_Integer(ptrdiff_t(anOtherString) & 3); \
220 if ( ( LoopIndex & 1 ) == 0 ) { \
221 if ( LoopIndex == 0 ) { \
222 for (; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
223 if (((Standard_Integer *) aString )[ LoopIndex ] != \
224 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
225 KEqual = Standard_False ; \
229 LoopIndex = ( LoopIndex << 2) ; \
232 for ( LoopIndex = 0 ; LoopIndex < (( aStringLen + 1) >> 1) ; LoopIndex++ ) { \
233 if (((Standard_ExtCharacter *) aString )[ LoopIndex ] != \
234 ((Standard_ExtCharacter *) anOtherString )[ LoopIndex ] ) { \
235 KEqual = Standard_False ; \
239 LoopIndex = ( LoopIndex << 1) ; \
242 for (; LoopIndex <= aStringLen ; LoopIndex++ ) { \
243 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) { \
244 KEqual = Standard_False ; \
251 for ( LoopIndex = 0 ; LoopIndex <= aStringLen ; LoopIndex++ ) { \
252 if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
253 KEqual = Standard_False ; \
260 // aString is an AsciiString and is word aligned
261 // anOtherString is an AsciiString and is word aligned
262 #define ASCIISTRINGEQUAL( aString , anOtherString , aStringLen , KEqual ) { \
263 Standard_Integer LoopIndex ; \
264 KEqual = Standard_True ; \
266 for(; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
267 if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
268 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
269 KEqual = Standard_False ; \
273 if ( KEqual == Standard_True && \
274 (((Standard_Integer *) aString )[ LoopIndex ] & \
275 MaskEndIntegerString[ aStringLen & 3 ]) != \
276 (((Standard_Integer *) anOtherString )[ LoopIndex ] & \
277 MaskEndIntegerString[ aStringLen & 3 ] ) ) \
278 KEqual = Standard_False ; \
281 // aString is an AsciiString and is word aligned
282 // anOtherString is aCString and may be not word aligned
283 #define CSTRINGLESS( aString , aStringLen , anOtherString , \
284 anOtherStringLen , MinLen , KLess ) { \
285 Standard_Integer LoopIndex ; \
286 KLess = Standard_True ; \
287 LoopIndex = ptrdiff_t(anOtherString) & 3 ; \
288 if ( ( LoopIndex & 1 ) == 0 && MinLen > 3 ) { \
289 if ( LoopIndex == 0 ) { \
290 for (; LoopIndex < ( MinLen >> 2 ) ; LoopIndex++ ) { \
291 if (((Standard_Integer *) aString )[ LoopIndex ] != \
292 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
297 LoopIndex = ( LoopIndex - 1 ) << 2 ; \
300 for ( LoopIndex = 0 ; LoopIndex < ( MinLen >> 1 ) ; LoopIndex++ ) { \
301 if (((Standard_ExtCharacter *) aString )[ LoopIndex ] != \
302 ((Standard_ExtCharacter *) anOtherString )[ LoopIndex ] ) { \
307 LoopIndex = ( LoopIndex - 1 ) << 1 ; \
312 for (; LoopIndex < MinLen ; LoopIndex++ ) { \
313 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
316 if ( LoopIndex != MinLen ) { \
317 if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
318 KLess = Standard_False ; \
320 else if ( aStringLen >= anOtherStringLen ) \
321 KLess = Standard_False ; \
324 // aString is an AsciiString and is word aligned
325 // anOtherString is aCString and may be not word aligned
326 // aStringLen is the length of aString
327 // The length of anOtherString is unknown
328 #define LCSTRINGLESS( aString , aStringLen , anOtherString , KLess ) { \
329 KLess = Standard_True ; \
330 Standard_Integer LoopIndex = Standard_Integer(ptrdiff_t(anOtherString) & 3); \
331 if ( ( LoopIndex & 1 ) == 0 && aStringLen > 3 ) { \
332 if ( LoopIndex == 0 ) { \
333 for (; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
334 if (((Standard_Integer *) aString )[ LoopIndex ] != \
335 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
340 LoopIndex = ( LoopIndex - 1 ) << 2 ; \
343 for ( LoopIndex = 0 ; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
344 if (((Standard_ExtCharacter *) aString )[ LoopIndex ] != \
345 ((Standard_ExtCharacter *) anOtherString )[ LoopIndex ] ) { \
350 LoopIndex = ( LoopIndex - 1 ) << 1 ; \
355 for (; LoopIndex < aStringLen ; LoopIndex++ ) { \
356 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
359 if ( LoopIndex != aStringLen ) { \
360 if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
361 KLess = Standard_False ; \
363 else if ( anOtherString[ LoopIndex ] == '\0' ) \
364 KLess = Standard_False ; \
367 // aString is an AsciiString and is word aligned
368 // anOtherString is an AsciiString and is word aligned
369 #define ASCIISTRINGLESS( aString , aStringLen , anOtherString , \
370 anOtherStringLen , MinLen , KLess ) { \
371 Standard_Integer LoopIndex ; \
372 KLess = Standard_True ; \
374 if ( MinLen > 3 ) { \
375 for(; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
376 if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
377 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
382 LoopIndex = ( LoopIndex - 1 ) << 2 ; \
384 for (; LoopIndex < MinLen ; LoopIndex++ ) { \
385 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
388 if ( LoopIndex != MinLen ) { \
389 if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
390 KLess = Standard_False ; \
392 else if ( aStringLen >= anOtherStringLen ) \
393 KLess = Standard_False ; \
396 // aString is an AsciiString and is word aligned
397 // anOtherString is aCString and may be not word aligned
398 #define CSTRINGGREATER( aString , aStringLen , anOtherString , \
399 anOtherStringLen , MinLen , KGreater ) { \
400 KGreater = Standard_True ; \
401 Standard_Integer LoopIndex = Standard_Integer(ptrdiff_t(anOtherString) & 3); \
402 if ( ( LoopIndex & 1 ) == 0 && MinLen > 3 ) { \
403 if ( LoopIndex == 0 ) { \
404 for (; LoopIndex < ( MinLen >> 2 ) ; LoopIndex++ ) { \
405 if (((Standard_Integer *) aString )[ LoopIndex ] != \
406 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
411 LoopIndex = ( LoopIndex - 1 ) << 2 ; \
414 for ( LoopIndex = 0 ; LoopIndex < ( MinLen >> 1 ) ; LoopIndex++ ) { \
415 if (((Standard_ExtCharacter *) aString )[ LoopIndex ] != \
416 ((Standard_ExtCharacter *) anOtherString )[ LoopIndex ] ) { \
421 LoopIndex = ( LoopIndex - 1 ) << 1 ; \
426 for (; LoopIndex < MinLen ; LoopIndex++ ) { \
427 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
430 if ( LoopIndex != MinLen ) { \
431 if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
432 KGreater = Standard_False ; \
434 else if ( aStringLen <= anOtherStringLen ) \
435 KGreater = Standard_False ; \
438 // aString is an AsciiString and is word aligned
439 // anOtherString is aCString and may be not word aligned
440 // aStringLen is the length of aString
441 // The length of anOtherString is unknown
442 #define LCSTRINGGREATER( aString , aStringLen , anOtherString , KGreater ) { \
443 Standard_Integer LoopIndex ; \
444 KGreater = Standard_True ; \
445 LoopIndex = (Standard_Integer)(ptrdiff_t(anOtherString) & 3) ; \
446 if ( ( LoopIndex & 1 ) == 0 && aStringLen > 3 ) { \
447 if ( LoopIndex == 0 ) { \
448 for (; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
449 if (((Standard_Integer *) aString )[ LoopIndex ] != \
450 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
455 LoopIndex = ( LoopIndex - 1 ) << 2 ; \
458 for ( LoopIndex = 0 ; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
459 if (((Standard_ExtCharacter *) aString )[ LoopIndex ] != \
460 ((Standard_ExtCharacter *) anOtherString )[ LoopIndex ] ) { \
465 LoopIndex = ( LoopIndex - 1 ) << 1 ; \
470 for (; LoopIndex < aStringLen ; LoopIndex++ ) { \
471 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
474 if ( LoopIndex != aStringLen ) { \
475 if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
476 KGreater = Standard_False ; \
479 KGreater = Standard_False ; \
482 // aString is an AsciiString and is word aligned
483 // anOtherString is an AsciiString and is word aligned
484 #define ASCIISTRINGGREATER( aString , aStringLen , anOtherString , \
485 anOtherStringLen , MinLen , KGreater ) { \
486 Standard_Integer LoopIndex ; \
487 KGreater = Standard_True ; \
489 if ( MinLen > 3 ) { \
490 for(; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
491 if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
492 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
497 LoopIndex = ( LoopIndex - 1 ) << 2 ; \
499 for (; LoopIndex < MinLen ; LoopIndex++ ) { \
500 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
503 if ( LoopIndex != MinLen ) { \
504 if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
505 KGreater = Standard_False ; \
507 else if ( aStringLen <= anOtherStringLen ) \
508 KGreater = Standard_False ; \
511 // anExtStringOut is an ExtendedString and is word aligned
512 // anExtStringIn is an ExtString and may be not word aligned
513 #define EXTSTRINGCOPY( anExtStringOut , anExtStringIn , anExtStringLen ) { \
514 Standard_Integer LoopIndex ; \
515 LoopIndex = (Standard_Integer)(ptrdiff_t(anExtStringIn) & 3) ; \
516 if ( LoopIndex == 0 ) { \
517 for (; LoopIndex <= ( anExtStringLen >> 1 ) ; LoopIndex++ ) { \
518 ((Standard_Integer *) anExtStringOut )[ LoopIndex ] = \
519 ((Standard_Integer *) anExtStringIn )[ LoopIndex ] ; \
523 STRCPY( anExtStringOut , anExtStringIn , anExtStringLen + 1 ) ; \
526 // anExtStringOut is an ExtendedString and is word aligned
527 // anExtStringIn is an ExtendedString and is word aligned
528 // We copy the ending zero and possibly the ExtCharacter folowing
529 #define EXTENDEDSTRINGCOPY( anExtStringOut , anExtStringIn , anExtStringLen ) {\
530 Standard_Integer LoopIndex ; \
531 for (LoopIndex = 0 ; LoopIndex <= ( anExtStringLen >> 1 ) ; LoopIndex++ ) { \
532 ((Standard_Integer *) anExtStringOut )[ LoopIndex ] = \
533 ((Standard_Integer *) anExtStringIn )[ LoopIndex ] ; \
537 // anExtStringOut is an ExtendedString and is word aligned
538 // anExtStringIn is an ExtendedString and is word aligned
539 // We copy the ending zero and possibly the ExtCharacter folowing
540 #define EXTENDEDSTRINGCAT( anExtStringOut , anExtStringOutLen , anExtStringIn , anExtStringInLen ) {\
541 Standard_Integer LoopIndex ; \
542 if ( ( anExtStringOutLen & 1 ) == 0 ) { \
543 for (LoopIndex = 0 ; LoopIndex <= ( anExtStringInLen >> 1 ) ; LoopIndex++ ) { \
544 ((Standard_Integer *) anExtStringOut )[ ( anExtStringOutLen >> 1 ) + LoopIndex ] = \
545 ((Standard_Integer *) anExtStringIn )[ LoopIndex ] ; \
549 STRCAT( anExtStringOut , anExtStringOutLen , anExtStringIn , anExtStringInLen + 1 ) ; \
553 // aString is an ExtendedString and is word aligned
554 // anOtherString is an ExtString and may be not word aligned
555 // We compare the last two ExtCharacters or the last ExtCharacter and the
556 // ending zero if it's word aligned
557 // aStringLen is the length of aString and anOtherString
558 #define EXTSTRINGEQUAL( aString , anOtherString , aStringLen , KEqual ) { \
559 Standard_Integer LoopIndex ; \
560 KEqual = Standard_True ; \
562 if ((ptrdiff_t(anOtherString) & 3 ) == 0 ) { \
563 for(; LoopIndex < (( aStringLen + 1) >> 1 ) ; LoopIndex++ ) { \
564 if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
565 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
566 KEqual = Standard_False ; \
572 for(; LoopIndex < aStringLen ; LoopIndex++ ) { \
573 if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
574 KEqual = Standard_False ; \
581 // aString is an ExtendedString and is word aligned
582 // anOtherString is an ExtString and may be not word aligned
583 // We compare the last two ExtCharacters or the last ExtCharacter and the
584 // ending zero if it's word aligned
585 // aStringLen is the length of aString.
586 // The length of anOtherString is unknown
587 #define LEXTSTRINGEQUAL( aString , aStringLen , anOtherString , KEqual ) { \
588 Standard_Integer LoopIndex ; \
589 KEqual = Standard_True ; \
591 if ((ptrdiff_t(anOtherString) & 3 ) == 0 ) { \
592 for(; LoopIndex < (( aStringLen + 1) >> 1 ) ; LoopIndex++ ) { \
593 if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
594 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
595 KEqual = Standard_False ; \
599 if ( KEqual && aString [ aStringLen ] != anOtherString [ aStringLen ] ) \
600 KEqual = Standard_False ; \
603 for(; LoopIndex <= aStringLen ; LoopIndex++ ) { \
604 if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
605 KEqual = Standard_False ; \
612 // aString is an ExtendedString and is word aligned
613 // anOtherString is an ExtendedString and is word aligned
614 // We compare the last two ExtCharacters or the last ExtCharacter and the
616 #define EXTENDEDSTRINGEQUAL( aString , anOtherString , aStringLen , KEqual ) { \
617 Standard_Integer LoopIndex ; \
618 KEqual = Standard_True ; \
620 for(; LoopIndex < (( aStringLen + 1) >> 1 ) ; LoopIndex++ ) { \
621 if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
622 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
623 KEqual = Standard_False ; \
629 // aString is an ExtendedString and is word aligned
630 // anOtherString is an ExtendedString and may be not word aligned
631 #define EXTSTRINGLESS( aString , aStringLen , anOtherString , \
632 anOtherStringLen , MinLen , KLess ) { \
633 Standard_Integer LoopIndex ; \
634 KLess = Standard_True ; \
636 if ((ptrdiff_t(anOtherString) & 3 ) == 0 ) { \
637 if ( MinLen > 1 ) { \
638 for(; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
639 if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
640 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
645 LoopIndex = ( LoopIndex - 1 ) << 1 ; \
647 for (; LoopIndex < MinLen ; LoopIndex++ ) { \
648 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
651 if ( LoopIndex != MinLen ) { \
652 if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
653 KLess = Standard_False ; \
655 else if ( aStringLen >= anOtherStringLen ) \
656 KLess = Standard_False ; \
659 if ( MinLen > 1 ) { \
660 for(; LoopIndex < aStringLen ; LoopIndex++ ) { \
661 if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
666 LoopIndex = LoopIndex - 1 ; \
668 for (; LoopIndex < MinLen ; LoopIndex++ ) { \
669 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
672 if ( LoopIndex != MinLen ) { \
673 if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
674 KLess = Standard_False ; \
676 else if ( aStringLen >= anOtherStringLen ) \
677 KLess = Standard_False ; \
681 // aString is an ExtendedString and is word aligned
682 // anOtherString is an ExtendedString and may be not word aligned
683 // aStringLen is the length of aString
684 // The length of anOtherString is unknown
685 #define LEXTSTRINGLESS( aString , aStringLen , anOtherString , KLess ) { \
686 Standard_Integer LoopIndex ; \
687 KLess = Standard_True ; \
689 if ((ptrdiff_t(anOtherString) & 3 ) == 0 ) { \
690 if ( aStringLen > 1 ) { \
691 for(; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
692 if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
693 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
698 LoopIndex = ( LoopIndex - 1 ) << 1 ; \
700 for (; LoopIndex < aStringLen ; LoopIndex++ ) { \
701 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
704 if ( LoopIndex != aStringLen ) { \
705 if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
706 KLess = Standard_False ; \
708 else if ( anOtherString[ LoopIndex ] == 0 ) \
709 KLess = Standard_False ; \
712 if ( aStringLen > 1 ) { \
713 for(; LoopIndex < aStringLen ; LoopIndex++ ) { \
714 if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
719 LoopIndex = LoopIndex - 1 ; \
721 for (; LoopIndex < aStringLen ; LoopIndex++ ) { \
722 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
725 if ( LoopIndex != aStringLen ) { \
726 if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
727 KLess = Standard_False ; \
729 else if ( anOtherString[ LoopIndex ] == 0 ) \
730 KLess = Standard_False ; \
734 // aString is an ExtendedString and is word aligned
735 // anOtherString is an ExtendedString and is word aligned
736 #define EXTENDEDSTRINGLESS( aString , aStringLen , anOtherString , \
737 anOtherStringLen , MinLen , KLess ) { \
738 Standard_Integer LoopIndex ; \
739 KLess = Standard_True ; \
741 if ( MinLen > 1 ) { \
742 for(; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
743 if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
744 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
749 LoopIndex = ( LoopIndex - 1 ) << 1 ; \
751 for (; LoopIndex < MinLen ; LoopIndex++ ) { \
752 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
755 if ( LoopIndex != MinLen ) { \
756 if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
757 KLess = Standard_False ; \
759 else if ( aStringLen >= anOtherStringLen ) \
760 KLess = Standard_False ; \
763 // aString is an ExtendedString and is word aligned
764 // anOtherString is an ExtendedString and may be not word aligned
765 #define EXTSTRINGGREATER( aString , aStringLen , anOtherString , \
766 anOtherStringLen , MinLen , KGreater ) { \
767 Standard_Integer LoopIndex ; \
768 KGreater = Standard_True ; \
770 if ((ptrdiff_t(anOtherString) & 3 ) == 0 ) { \
771 if ( MinLen > 1 ) { \
772 for(; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
773 if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
774 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
779 LoopIndex = ( LoopIndex - 1 ) << 1 ; \
781 for (; LoopIndex < MinLen ; LoopIndex++ ) { \
782 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
785 if ( LoopIndex != MinLen ) { \
786 if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
787 KGreater = Standard_False ; \
789 else if ( aStringLen <= anOtherStringLen ) \
790 KGreater = Standard_False ; \
793 if ( MinLen > 1 ) { \
794 for(; LoopIndex < aStringLen ; LoopIndex++ ) { \
795 if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
800 LoopIndex = LoopIndex - 1 ; \
802 for (; LoopIndex < MinLen ; LoopIndex++ ) { \
803 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
806 if ( LoopIndex != MinLen ) { \
807 if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
808 KGreater = Standard_False ; \
810 else if ( aStringLen <= anOtherStringLen ) \
811 KGreater = Standard_False ; \
815 // aString is an ExtendedString and is word aligned
816 // anOtherString is an ExtendedString and may be not word aligned
817 // aStringLen is the length of aString
818 // The length of anOtherString is unknown
819 #define LEXTSTRINGGREATER( aString , aStringLen , anOtherString , KGreater ) { \
820 Standard_Integer LoopIndex ; \
821 KGreater = Standard_True ; \
823 if ((ptrdiff_t(anOtherString) & 3 ) == 0 ) { \
824 if ( aStringLen > 1 ) { \
825 for(; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
826 if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
827 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
832 LoopIndex = ( LoopIndex - 1 ) << 1 ; \
834 for (; LoopIndex < aStringLen ; LoopIndex++ ) { \
835 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
838 if ( LoopIndex != aStringLen ) { \
839 if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
840 KGreater = Standard_False ; \
843 KGreater = Standard_False ; \
846 if ( aStringLen > 1 ) { \
847 for(; LoopIndex < aStringLen ; LoopIndex++ ) { \
848 if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
853 LoopIndex = LoopIndex - 1 ; \
855 for (; LoopIndex < aStringLen ; LoopIndex++ ) { \
856 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
859 if ( LoopIndex != aStringLen ) { \
860 if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
861 KGreater = Standard_False ; \
864 KGreater = Standard_False ; \
868 // aString is an ExtendedString and is word aligned
869 // anOtherString is an ExtendedString and is word aligned
870 #define EXTENDEDSTRINGGREATER( aString , aStringLen , anOtherString , \
871 anOtherStringLen , MinLen , KGreater ) { \
872 Standard_Integer LoopIndex ; \
873 KGreater = Standard_True ; \
875 if ( MinLen > 1 ) { \
876 for(; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
877 if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
878 ((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
883 LoopIndex = ( LoopIndex - 1 ) << 1 ; \
885 for (; LoopIndex < MinLen ; LoopIndex++ ) { \
886 if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
889 if ( LoopIndex != MinLen ) { \
890 if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
891 KGreater = Standard_False ; \
893 else if ( aStringLen <= anOtherStringLen ) \
894 KGreater = Standard_False ; \
899 #define STRLEN(s,i) {(i) = 0;while((s)[(i)++] != '\0');(i)--;}
900 #define EXTSTRLEN(s,i) {(i) = 0;while((s)[(i)++] != 0);(i)--;}
901 #define STRCPY(s1,s2,i) {for(int j=0; j<(i); j++)(s1)[j] = (s2)[j];}
902 #define STRCAT(s1,i,s2,j) {for(int k=0; k<(j); k++) (s1)[(i)+k] = (s2)[k];}