1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 #if !defined(DOMSTRINGHELPER_HEADER_GUARD_1357924680)
19 #define DOMSTRINGHELPER_HEADER_GUARD_1357924680
20
21
22
23 // Base include file. Must be first.
24 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp>
25
26
27
28 #include <algorithm>
29 #include <cassert>
30 #include <functional>
31 #include <iosfwd>
32
33
34
35 #include <xalanc/Include/XalanVector.hpp>
36 #include <xalanc/Include/XalanMap.hpp>
37 #include <xalanc/Include/XalanMemoryManagement.hpp>
38 #include <xalanc/Include/STLHelper.hpp>
39
40
41
42 #include <xalanc/XalanDOM/XalanDOMString.hpp>
43
44
45
46 #include <xalanc/PlatformSupport/FormatterListener.hpp>
47 #include <xalanc/PlatformSupport/XalanUnicode.hpp>
48 #include <xalanc/PlatformSupport/XalanXMLChar.hpp>
49
50
51
52 namespace XALAN_CPP_NAMESPACE {
53
54
55
56 using xercesc::MemoryManager;
57
58
59
60 class XalanOutputStream;
61
62
63
64 template<class InputIteratorType, class OutputIteratorType>
65 inline OutputIteratorType
XalanCopy(InputIteratorType begin,InputIteratorType end,OutputIteratorType iterator)66 XalanCopy(
67 InputIteratorType begin,
68 InputIteratorType end,
69 OutputIteratorType iterator)
70 {
71 return std::copy(begin, end, iterator);
72 }
73
74
75
76 template<class InputIteratorType, class OutputIteratorType, class UnaryFunction>
77 inline OutputIteratorType
XalanTransform(InputIteratorType begin,InputIteratorType end,OutputIteratorType iterator,UnaryFunction function)78 XalanTransform(
79 InputIteratorType begin,
80 InputIteratorType end,
81 OutputIteratorType iterator,
82 UnaryFunction function)
83 {
84 return std::transform(begin, end, iterator, function);
85 }
86
87
88
89 /**
90 * Get the underlying representation of the target XalanDOMString as a
91 * null-terminated string
92 *
93 * @deprecated This function is deprecated.
94 *
95 * @param theString target string
96 * @return null-terminated string of XalanDOMChar
97 */
98 inline const XalanDOMChar*
c_wstr(const XalanDOMString & theString)99 c_wstr(const XalanDOMString& theString)
100 {
101 return theString.c_str();
102 }
103
104
105
106 /**
107 * Get the underlying representation of the target CharVectorType as a
108 * null-terminated string
109 *
110 * @param theString target string
111 * @return null-terminated string of chars
112 */
113 inline const char*
c_str(const CharVectorType & theString)114 c_str(const CharVectorType& theString)
115 {
116 if (theString.empty() == true)
117 {
118 return 0;
119 }
120 else
121 {
122 const char* const ptr = &theString[0];
123
124 assert(ptr[theString.size() - 1] == '\0');
125
126 return ptr;
127 }
128 }
129
130
131
132 /**
133 * Get the underlying representation of the wide string as a
134 * UNICODE null-terminated string. This is here simply for
135 * consistency in the code. On certain platforms, compiler-
136 * generated wide strings will not contain Unicode code
137 * points. Another macro converts those into XalanDOMStrings,
138 * which are then transcoded. In these cases, the previous
139 * defined c_sstr() function gets called.
140 *
141 * On platforms where the compiler does generate Unicode wide
142 * strings, this function will be called instead.
143 *
144 * @deprecated This function is deprecated.
145 *
146 * @param theString target string
147 * @return null-terminated string of XalanDOMChar
148 */
149 inline const XalanDOMChar*
c_wstr(const XalanDOMChar * theString)150 c_wstr(const XalanDOMChar* theString)
151 {
152 return theString;
153 }
154
155
156
157 /**
158 * Get the underlying representation of the target XalanDOMString as an array of
159 * XalanDOMChar, not guaranteed to be null-terminated.
160 *
161 * @deprecated This function is deprecated.
162 *
163 * @param theString target string
164 * @return array of XalanDOMChar
165 */
166 inline const XalanDOMChar*
toCharArray(const XalanDOMString & theString)167 toCharArray(const XalanDOMString& theString)
168 {
169 return theString.c_str();
170 }
171
172
173
174 /**
175 * Get the underlying representation of a XalanDOMChar.
176 *
177 * @deprecated This function is deprecated.
178 *
179 * @param theString target string
180 * @return array of XalanDOMChar
181 */
182 inline const XalanDOMChar*
toCharArray(const XalanDOMChar * theString)183 toCharArray(const XalanDOMChar* theString)
184 {
185 return theString;
186 }
187
188
189
190 /**
191 * Get the underlying representation of the target CharVectorType as a
192 * pointer to an array of characters
193 *
194 * @deprecated This function is deprecated.
195 *
196 * @param theString target string
197 * @return the pointer
198 */
199 inline const char*
toCharArray(const CharVectorType & theString)200 toCharArray(const CharVectorType& theString)
201 {
202 return theString.empty() == true ? 0 : &theString[0];
203 }
204
205
206
207 /**
208 * Reserve some space in the string for more efficient
209 * concatenation...
210 *
211 * @deprecated This function is deprecated.
212 *
213 * @param theString target string
214 * @param theCount The amount of space to reserve
215 */
216 inline void
reserve(XalanDOMString & theString,XalanDOMString::size_type theCount)217 reserve(
218 XalanDOMString& theString,
219 XalanDOMString::size_type theCount)
220 {
221 theString.reserve(theCount);
222 }
223
224
225
226 /**
227 * Get the length of a XalanDOMString
228 *
229 * @deprecated This function is deprecated.
230 *
231 * @param theString target string
232 * @return the length of the target string
233 */
234 inline XalanDOMString::size_type
length(const XalanDOMString & theString)235 length(const XalanDOMString& theString)
236 {
237 return theString.length();
238 }
239
240
241
242 /**
243 * Get the length of a null-terminated string of
244 * XalanDOMChar characters
245 *
246 * @param theString target string
247 * @return the length of the target string
248 */
249 inline XalanDOMString::size_type
length(const XalanDOMChar * theString)250 length(const XalanDOMChar* theString)
251 {
252 assert(theString != 0);
253
254 const XalanDOMChar* theBufferPointer = theString;
255
256 while(*theBufferPointer != 0)
257 {
258 theBufferPointer++;
259 }
260
261 return XalanDOMString::size_type(theBufferPointer - theString);
262 }
263
264
265
266 /**
267 * Get the length of a null-terminated string.
268 *
269 * @param theString target string
270 * @return the length of the target string
271 */
272 inline XalanDOMString::size_type
length(const char * theString)273 length(const char* theString)
274 {
275 assert(theString != 0);
276
277 return XalanDOMString::length(theString);
278 }
279
280
281
282 /**
283 * Determines if the target string contains any elements
284 *
285 * @deprecated This function is deprecated.
286 *
287 * @param str target string
288 * @return true if the target string has a non-zero length
289 */
290 inline bool
isEmpty(const XalanDOMString & str)291 isEmpty(const XalanDOMString& str)
292 {
293 return str.empty();
294 }
295
296
297
298 /**
299 * Simulates the java String method indexOf().
300 *
301 * @param theString string to search
302 * @param theChar character searched for
303 * @return the index of theChar in theString,
304 * or length(theString) if the character is not
305 * found.
306 */
307 inline XalanDOMString::size_type
indexOf(const XalanDOMChar * theString,XalanDOMChar theChar)308 indexOf(
309 const XalanDOMChar* theString,
310 XalanDOMChar theChar)
311 {
312 assert(theString != 0);
313
314 const XalanDOMChar* thePointer = theString;
315
316 while(*thePointer != theChar && *thePointer != 0)
317 {
318 ++thePointer;
319 }
320
321 return XalanDOMString::size_type(thePointer - theString);
322 }
323
324
325
326 /**
327 * Simulates the java String method indexOf().
328 *
329 * @param theString string to search
330 * @param theStringLength the length of theString
331 * @param theChar character searched for
332 * @return the index of theChar in theString,
333 * or length(theString) if the character is not
334 * found.
335 */
336 inline XalanDOMString::size_type
indexOf(const XalanDOMChar * theString,XalanDOMString::size_type theStringLength,XalanDOMChar theChar)337 indexOf(
338 const XalanDOMChar* theString,
339 XalanDOMString::size_type theStringLength,
340 XalanDOMChar theChar)
341 {
342 assert(theString != 0);
343
344 const XalanDOMChar* thePointer = theString;
345 const XalanDOMChar* const theEndPointer = theString + theStringLength;
346
347 while(*thePointer != theChar && thePointer != theEndPointer)
348 {
349 ++thePointer;
350 }
351
352 return XalanDOMString::size_type(thePointer - theString);
353 }
354
355
356
357 /**
358 * Simulates the java String method indexOf().
359 *
360 * @param theString string to search
361 * @param theChar character searched for
362 * @return the index of theChar in theString,
363 * or length(theString) if the character is not
364 * found.
365 */
366 inline XalanDOMString::size_type
indexOf(const XalanDOMString & theString,XalanDOMChar theChar)367 indexOf(
368 const XalanDOMString& theString,
369 XalanDOMChar theChar)
370 {
371 return theString.length() == 0 ? 0 : indexOf(theString.c_str(), theChar);
372 }
373
374
375
376 /**
377 * Simulates the java String method indexOf().
378 *
379 * @param theString string to search
380 * @param theStringLength length of the string to search
381 * @param theSubstring substring searched for
382 * @param theSubstringLength length of the substring searched for
383 * @return the index of theSubstring in theString,
384 * or length(theString) if the string is not
385 * found.
386 */
387 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type)
388 indexOf(
389 const XalanDOMChar* theString,
390 XalanDOMString::size_type theStringLength,
391 const XalanDOMChar* theSubstring,
392 XalanDOMString::size_type theSubstringLength);
393
394
395
396 /**
397 * Simulates the java String method indexOf().
398 *
399 * @param theString string to search
400 * @param theSubstring substring searched for
401 * @return the index of theSubstring in theString,
402 * or length(theString) if the string is not
403 * found.
404 */
405 inline XalanDOMString::size_type
indexOf(const XalanDOMChar * theString,const XalanDOMChar * theSubstring)406 indexOf(
407 const XalanDOMChar* theString,
408 const XalanDOMChar* theSubstring)
409 {
410 assert(theString != 0 && theSubstring != 0);
411
412 return indexOf(theString, length(theString), theSubstring, length(theSubstring));
413 }
414
415
416
417 /**
418 * Simulates the java String method indexOf().
419 *
420 * @param theString string to search
421 * @param theSubstring substring searched for
422 * @return the index of theSubstring in theString,
423 * or length(theString) if the string is not
424 * found.
425 */
426 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type)
427 indexOf(
428 const XalanDOMString& theString,
429 const XalanDOMString& theSubstring);
430
431
432
433 /**
434 * Simulates the java String method lastIndexOf().
435 *
436 * @param theString string to search
437 * @param theChar character searched for
438 * @return the index of theChar in theString,
439 * or length(theString) if the character is not
440 * found.
441 */
442
443 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type)
444 lastIndexOf(
445 const XalanDOMChar* theString,
446 XalanDOMChar theChar);
447
448
449
450 /**
451 * Simulates the java String method lastIndexOf().
452 *
453 * @param theString string to search
454 * @param theChar character searched for
455 * @return the index of theChar in theString,
456 * or length(theString) if the character is not
457 * found.
458 */
459 inline XalanDOMString::size_type
lastIndexOf(const XalanDOMString & theString,XalanDOMChar theChar)460 lastIndexOf(
461 const XalanDOMString& theString,
462 XalanDOMChar theChar)
463 {
464 return lastIndexOf(theString.c_str(), theChar);
465 }
466
467
468
469 /**
470 * Simulates the java String method startsWith().
471 *
472 * @param theString target string to search
473 * @param theStringLength the length of theString
474 * @param theSubstring substring searched for
475 * @param theSubstringLength the length of theSubstring
476 * @return true if the target string begins with the substring
477 */
478 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
479 startsWith(
480 const XalanDOMChar* theString,
481 XalanDOMString::size_type theStringLength,
482 const XalanDOMChar* theSubstring,
483 XalanDOMString::size_type theSubstringLength);
484
485
486
487 /**
488 * Simulates the java String method startsWith().
489 *
490 * @param theDOMString target string to search
491 * @param theSubstring substring searched for
492 * @return true if the target string begins with the substring
493 */
494 inline bool
startsWith(const XalanDOMChar * theString,const XalanDOMChar * theSubstring)495 startsWith(
496 const XalanDOMChar* theString,
497 const XalanDOMChar* theSubstring)
498 {
499 assert(theString != 0 && theSubstring != 0);
500
501 return startsWith(theString, length(theString), theSubstring, length(theSubstring));
502 }
503
504
505
506 /**
507 * Simulates the java String method startsWith().
508 *
509 * @param theDOMString target string to search
510 * @param theSubstring substring searched for
511 * @return true if the target string begins with the substring
512 */
513 inline bool
startsWith(const XalanDOMChar * theString,const XalanDOMString & theSubstring)514 startsWith(
515 const XalanDOMChar* theString,
516 const XalanDOMString& theSubstring)
517 {
518 assert(theString != 0);
519
520 return startsWith(
521 theString,
522 length(theString),
523 theSubstring.c_str(),
524 theSubstring.length());
525 }
526
527
528
529 /**
530 * Simulates the java String method startsWith().
531 *
532 * @param theDOMString target string to search
533 * @param theSubstring substring searched for
534 * @return true if the target string begins with the substring
535 */
536 inline bool
startsWith(const XalanDOMString & theString,const XalanDOMChar * theSubstring)537 startsWith(
538 const XalanDOMString& theString,
539 const XalanDOMChar* theSubstring)
540 {
541 assert(theSubstring != 0);
542
543 return startsWith(
544 theString.c_str(),
545 theString.length(),
546 theSubstring,
547 length(theSubstring));
548 }
549
550
551
552 /**
553 * Simulates the java String method startsWith().
554 *
555 * @param theDOMString target string to search
556 * @param theSubstring substring searched for
557 * @param theSubstringLength the length of theSubstring
558 * @return true if the target string begins with the substring
559 */
560 inline bool
startsWith(const XalanDOMString & theString,const XalanDOMChar * theSubstring,XalanDOMString::size_type theSubstringLength)561 startsWith(
562 const XalanDOMString& theString,
563 const XalanDOMChar* theSubstring,
564 XalanDOMString::size_type theSubstringLength)
565 {
566 assert(theSubstring != 0);
567
568 return startsWith(
569 theString.c_str(),
570 theString.length(),
571 theSubstring,
572 theSubstringLength);
573 }
574
575
576
577 /**
578 * Simulates the java String method startsWith().
579 *
580 * @param theDOMString target string to search
581 * @param theSubstring substring searched for
582 * @return true if the target string begins with the substring
583 */
584 inline bool
startsWith(const XalanDOMString & theString,const XalanDOMString & theSubstring)585 startsWith(
586 const XalanDOMString& theString,
587 const XalanDOMString& theSubstring)
588 {
589 return startsWith(
590 theString.c_str(),
591 theString.length(),
592 theSubstring.c_str(),
593 theSubstring.length());
594 }
595
596
597
598 /**
599 * Simulates the java String method endsWith().
600 *
601 * @param theString target string to search
602 * @param theSubstring substring searched for
603 * @return true if the target string ends with the substring
604 */
605 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
606 endsWith(
607 const XalanDOMChar* theString,
608 XalanDOMString::size_type theStringLength,
609 const XalanDOMChar* theSubstring,
610 XalanDOMString::size_type theSubstringLength);
611
612
613
614 /**
615 * Simulates the java String method endsWith().
616 *
617 * @param theString target string to search
618 * @param theSubstring substring searched for
619 * @return true if the target string ends with the substring
620 */
621 inline bool
endsWith(const XalanDOMChar * theString,const XalanDOMChar * theSubstring)622 endsWith(
623 const XalanDOMChar* theString,
624 const XalanDOMChar* theSubstring)
625 {
626 assert(theString != 0 && theSubstring != 0);
627
628 return endsWith(
629 theString,
630 length(theString),
631 theSubstring,
632 length(theSubstring));
633 }
634
635
636
637 /**
638 * Simulates the java String method endsWith().
639 *
640 * @param theString target string to search
641 * @param theSubstring substring searched for
642 * @return true if the target string ends with the substring
643 */
644 inline bool
endsWith(const XalanDOMString & theString,const XalanDOMString & theSubstring)645 endsWith(
646 const XalanDOMString& theString,
647 const XalanDOMString& theSubstring)
648 {
649 return endsWith(
650 theString.c_str(),
651 theString.length(),
652 theSubstring.c_str(),
653 theSubstring.length());
654 }
655
656
657
658 /**
659 * Converts a pointer into a XalanDOMString
660 *
661 * @param theValue pointer to be converted
662 * @param theResult the string to append with the result
663 * @return a reference to the passed string result.
664 */
665 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
666 PointerToDOMString(
667 const void* theValue,
668 XalanDOMString& theResult);
669
670
671
672 class XALAN_PLATFORMSUPPORT_EXPORT DOMStringHelper
673 {
674 public:
675
676 typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const FormatterListener::size_type);
677
678
679 static void
680 initialize(MemoryManager& theMemoryManager);
681
682 static void
683 terminate();
684
685 static void
686 NumberToCharacters(
687 double theValue,
688 FormatterListener& formatterListener,
689 MemberFunctionPtr function);
690
691 static void
692 NumberToCharacters(
693 XMLInt32 theValue,
694 FormatterListener& formatterListener,
695 MemberFunctionPtr function);
696
697 static void
698 NumberToCharacters(
699 XMLInt64 theValue,
700 FormatterListener& formatterListener,
701 MemberFunctionPtr function);
702 };
703
704
705
706 /**
707 * Converts a double value into a XalanDOMString
708 *
709 * @param theValue number to be converted
710 * @param theResult the string to append with the result
711 * @return a reference to the passed string result.
712 */
713 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
714 NumberToDOMString(
715 double theValue,
716 XalanDOMString& theResult);
717
718
719
720 /**
721 * Converts an 64-bit unsigned int value into a XalanDOMString
722 *
723 * @param theValue number to be converted
724 * @param theResult the string to append with the result
725 * @return a reference to the passed string result.
726 */
727 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
728 NumberToDOMString(
729 XMLUInt64 theValue,
730 XalanDOMString& theResult);
731
732
733
734 /**
735 * Converts an 64-bit signed int value into a XalanDOMString
736 *
737 * @param theValue number to be converted
738 * @param theResult the string to append with the result
739 * @return a reference to the passed string result.
740 */
741 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
742 NumberToDOMString(
743 XMLInt64 theValue,
744 XalanDOMString& theResult);
745
746
747
748 /**
749 * Converts a 32-bit unsigned int value into a XalanDOMString
750 *
751 * @param theValue number to be converted
752 * @param theResult the string to append with the result
753 * @return a reference to the passed string result.
754 */
755 inline XalanDOMString&
NumberToDOMString(XMLUInt32 theValue,XalanDOMString & theResult)756 NumberToDOMString(
757 XMLUInt32 theValue,
758 XalanDOMString& theResult)
759 {
760 return NumberToDOMString(
761 static_cast<XMLUInt64>(theValue),
762 theResult);
763 }
764
765
766
767 /**
768 * Converts a 32-bit int value into a XalanDOMString
769 *
770 * @param theValue number to be converted
771 * @param theResult the string to append with the result
772 * @return a reference to the passed string result.
773 */
774 inline XalanDOMString&
NumberToDOMString(XMLInt32 theValue,XalanDOMString & theResult)775 NumberToDOMString(
776 XMLInt32 theValue,
777 XalanDOMString& theResult)
778 {
779 return NumberToDOMString(
780 static_cast<XMLInt64>(theValue),
781 theResult);
782 }
783
784
785
786 /**
787 * Converts a 16-bit unsigned int value into a XalanDOMString
788 *
789 * @param theValue number to be converted
790 * @param theResult the string to append with the result
791 * @return a reference to the passed string result.
792 */
793 inline XalanDOMString&
NumberToDOMString(XMLUInt16 theValue,XalanDOMString & theResult)794 NumberToDOMString(
795 XMLUInt16 theValue,
796 XalanDOMString& theResult)
797 {
798 return NumberToDOMString(
799 static_cast<XMLUInt64>(theValue),
800 theResult);
801 }
802
803
804
805 /**
806 * Converts a 16-bit int value into a XalanDOMString
807 *
808 * @param theValue number to be converted
809 * @param theResult the string to append with the result
810 * @return a reference to the passed string result.
811 */
812 inline XalanDOMString&
NumberToDOMString(XMLInt16 theValue,XalanDOMString & theResult)813 NumberToDOMString(
814 XMLInt16 theValue,
815 XalanDOMString& theResult)
816 {
817 return NumberToDOMString(
818 static_cast<XMLInt64>(theValue),
819 theResult);
820 }
821
822
823
824 /**
825 * Converts an 64-bit unsigned int value into a XalanDOMString
826 *
827 * @param theValue number to be converted
828 * @param theResult the string to append with the result
829 * @return a reference to the passed string result.
830 */
831 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
832 NumberToHexDOMString(
833 XMLUInt64 theValue,
834 XalanDOMString& theResult);
835
836
837
838 /**
839 * Converts an 64-bit signed int value into a XalanDOMString
840 *
841 * @param theValue number to be converted
842 * @param theResult the string to append with the result
843 * @return a reference to the passed string result.
844 */
845 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
846 NumberToHexDOMString(
847 XMLInt64 theValue,
848 XalanDOMString& theResult);
849
850
851
852 /**
853 * Converts a 32-bit unsigned int value into a XalanDOMString
854 *
855 * @param theValue number to be converted
856 * @param theResult the string to append with the result
857 * @return a reference to the passed string result.
858 */
859 inline XalanDOMString&
NumberToHexDOMString(XMLUInt32 theValue,XalanDOMString & theResult)860 NumberToHexDOMString(
861 XMLUInt32 theValue,
862 XalanDOMString& theResult)
863 {
864 return NumberToHexDOMString(
865 static_cast<XMLUInt64>(theValue),
866 theResult);
867 }
868
869
870
871 /**
872 * Converts a 32-bit signed int value into a XalanDOMString
873 *
874 * @param theValue number to be converted
875 * @param theResult the string to append with the result
876 * @return a reference to the passed string result.
877 */
878 inline XalanDOMString&
NumberToHexDOMString(XMLInt32 theValue,XalanDOMString & theResult)879 NumberToHexDOMString(
880 XMLInt32 theValue,
881 XalanDOMString& theResult)
882 {
883 return NumberToHexDOMString(
884 static_cast<XMLInt64>(theValue),
885 theResult);
886 }
887
888
889
890 /**
891 * Converts a 16-bit unsigned int value into a XalanDOMString
892 *
893 * @param theValue number to be converted
894 * @param theResult the string to append with the result
895 * @return a reference to the passed string result.
896 */
897 inline XalanDOMString&
NumberToHexDOMString(XMLUInt16 theValue,XalanDOMString & theResult)898 NumberToHexDOMString(
899 XMLUInt16 theValue,
900 XalanDOMString& theResult)
901 {
902 return NumberToHexDOMString(
903 static_cast<XMLUInt64>(theValue),
904 theResult);
905 }
906
907
908
909 /**
910 * Converts a 16-bit signed int value into a XalanDOMString
911 *
912 * @param theValue number to be converted
913 * @param theResult the string to append with the result
914 * @return a reference to the passed string result.
915 */
916 inline XalanDOMString&
NumberToHexDOMString(XMLInt16 theValue,XalanDOMString & theResult)917 NumberToHexDOMString(
918 XMLInt16 theValue,
919 XalanDOMString& theResult)
920 {
921 return NumberToHexDOMString(
922 static_cast<XMLInt64>(theValue),
923 theResult);
924 }
925
926
927
928 /**
929 * Converts a wide string into an integer value
930 *
931 * @param theString target string
932 * @return integer value of target string
933 */
934 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
935 WideStringToInt(const XalanDOMChar* theString);
936
937
938
939 /**
940 * Converts a wide string into a long value
941 *
942 * @param theString target string
943 * @return long value of target string
944 */
945 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(long)
946 WideStringToLong(const XalanDOMChar* theString);
947
948
949
950 /**
951 * Converts a wide string into an unsigned long value
952 *
953 * @param theString target string
954 * @return unsigned long value of target string
955 */
956 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned long)
957 WideStringToUnsignedLong(const XalanDOMChar* theString);
958
959
960
961 /**
962 * Converts a wide string into a double value
963 *
964 * @param theString target string
965 * @param theMemoryManager The MemoryManager instance to use.
966 * @return double value of target string
967 */
968 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(double)
969 WideStringToDouble(
970 const XalanDOMChar* theString,
971 MemoryManager& theMemoryManager);
972
973
974
975 /**
976 * Converts a XalanDOMString into an integer value
977 *
978 * @param theString target string
979 * @return integer value of target string
980 */
981 inline int
DOMStringToInt(const XalanDOMString & theString)982 DOMStringToInt(const XalanDOMString& theString)
983 {
984 return WideStringToInt(theString.c_str());
985 }
986
987
988
989 /**
990 * Converts a XalanDOMString into a long value
991 *
992 * @param theString target string
993 * @return long value of target string
994 */
995 inline long
DOMStringToLong(const XalanDOMString & theString)996 DOMStringToLong(const XalanDOMString& theString)
997 {
998 return WideStringToLong(theString.c_str());
999 }
1000
1001
1002
1003 /**
1004 * Converts a XalanDOMString into a long value
1005 *
1006 * @param theString target string
1007 * @return unsigned long value of target string
1008 */
1009 inline unsigned long
DOMStringToUnsignedLong(const XalanDOMString & theString)1010 DOMStringToUnsignedLong(const XalanDOMString& theString)
1011 {
1012 return WideStringToUnsignedLong(theString.c_str());
1013 }
1014
1015
1016
1017 /**
1018 * Converts a XalanDOMString into a double value
1019 *
1020 * @param theString target string
1021 * @param theMemoryManager The MemoryManager instance to use.
1022 * @return double value of target string
1023 */
1024 inline double
DOMStringToDouble(const XalanDOMString & theString,MemoryManager & theMemoryManager)1025 DOMStringToDouble(
1026 const XalanDOMString& theString,
1027 MemoryManager& theMemoryManager)
1028 {
1029 return WideStringToDouble(
1030 theString.c_str(),
1031 theMemoryManager);
1032 }
1033
1034
1035
1036 /**
1037 * Outputs the target string to the specified stream
1038 *
1039 * @param theStream output stream
1040 * @param theString target string
1041 * @see operator<<
1042 */
1043 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
1044 OutputString(
1045 XalanOutputStream& theStream,
1046 const CharVectorType& theString);
1047
1048
1049
1050 /**
1051 * Outputs the target string to the specified stream
1052 *
1053 * @param theStream output stream
1054 * @param theString target string
1055 * @see operator<<
1056 */
1057 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
1058 OutputString(
1059 std::ostream& theStream,
1060 const CharVectorType& theString);
1061
1062
1063
1064 /**
1065 * Outputs the target string to the specified stream
1066 *
1067 * @param theStream output stream
1068 * @param theString target string
1069 * @see operator<<
1070 */
1071 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
1072 OutputString(
1073 XalanOutputStream& theStream,
1074 const XalanDOMChar* theString);
1075
1076
1077
1078 /**
1079 * Outputs the target string to the specified stream
1080 *
1081 * @param theStream output stream
1082 * @param theString target string
1083 * @see operator<<
1084 */
1085 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
1086 OutputString(
1087 std::ostream& theStream,
1088 const XalanDOMChar* theString,
1089 MemoryManager& theMemoryManager);
1090
1091
1092
1093 /**
1094 * Outputs the target string to the specified stream
1095 *
1096 * @param theStream output stream
1097 * @param theString target string
1098 * @see operator<<
1099 */
1100 inline void
OutputString(XalanOutputStream & theStream,const XalanDOMString & theString)1101 OutputString(
1102 XalanOutputStream& theStream,
1103 const XalanDOMString& theString)
1104 {
1105 if (theString.empty() == false)
1106 {
1107 OutputString(
1108 theStream,
1109 theString.c_str());
1110 }
1111 }
1112
1113
1114
1115 /**
1116 * Outputs the target string to the specified stream
1117 *
1118 * @param theStream output stream
1119 * @param theString target string
1120 * @param theMemoryManager The MemoryManager instance to use.
1121 * @see operator<<
1122 */
1123 inline void
OutputString(std::ostream & theStream,const XalanDOMString & theString,MemoryManager & theMemoryManager)1124 OutputString(
1125 std::ostream& theStream,
1126 const XalanDOMString& theString,
1127 MemoryManager& theMemoryManager)
1128 {
1129 OutputString(
1130 theStream,
1131 theString.c_str(),
1132 theMemoryManager);
1133 }
1134
1135
1136
1137 /**
1138 * Outputs the string to the specified stream
1139 *
1140 * @param theStream output stream
1141 * @param theString the string to output
1142 * @see OutputString
1143 */
1144 inline XalanOutputStream&
operator <<(XalanOutputStream & theStream,const CharVectorType & theString)1145 operator<<(
1146 XalanOutputStream& theStream,
1147 const CharVectorType& theString)
1148 {
1149 OutputString(
1150 theStream,
1151 theString);
1152
1153 return theStream;
1154 }
1155
1156
1157
1158 /**
1159 * Outputs the string to the specified stream
1160 *
1161 * @param theStream output stream
1162 * @param theString the string to output
1163 * @see OutputString
1164 */
1165 inline std::ostream&
operator <<(std::ostream & theStream,const CharVectorType & theString)1166 operator<<(
1167 std::ostream& theStream,
1168 const CharVectorType& theString)
1169 {
1170 OutputString(
1171 theStream,
1172 theString);
1173
1174 return theStream;
1175 }
1176
1177
1178
1179 /**
1180 * Outputs the target string to the specified stream
1181 *
1182 * @param theStream output stream
1183 * @param theString target string
1184 * @see OutputString
1185 */
1186 inline XalanOutputStream&
operator <<(XalanOutputStream & theStream,const XalanDOMChar * theString)1187 operator<<(
1188 XalanOutputStream& theStream,
1189 const XalanDOMChar* theString)
1190 {
1191 OutputString(
1192 theStream,
1193 theString);
1194
1195 return theStream;
1196 }
1197
1198
1199
1200 /**
1201 * Outputs the target string to the specified stream
1202 *
1203 * @param theStream output stream
1204 * @param theString target string
1205 * @see OutputString
1206 */
1207 inline std::ostream&
operator <<(std::ostream & theStream,const XalanDOMChar * theString)1208 operator<<(
1209 std::ostream& theStream,
1210 const XalanDOMChar* theString)
1211 {
1212 OutputString(
1213 theStream,
1214 theString,
1215 XalanMemMgrs::getDefault());
1216
1217 return theStream;
1218 }
1219
1220
1221
1222 /**
1223 * Outputs the target string to the specified stream
1224 *
1225 * @param theStream output stream
1226 * @param theString target string
1227 * @see OutputString
1228 */
1229 inline XalanOutputStream&
operator <<(XalanOutputStream & theStream,const XalanDOMString & theString)1230 operator<<(
1231 XalanOutputStream& theStream,
1232 const XalanDOMString& theString)
1233 {
1234 OutputString(theStream,
1235 theString);
1236
1237 return theStream;
1238 }
1239
1240
1241
1242 /**
1243 * Outputs the target string to the specified stream
1244 *
1245 * @param theStream output stream
1246 * @param theString target string
1247 * @see OutputString
1248 */
1249 inline std::ostream&
operator <<(std::ostream & theStream,const XalanDOMString & theString)1250 operator<<(
1251 std::ostream& theStream,
1252 const XalanDOMString& theString)
1253 {
1254 OutputString(
1255 theStream,
1256 theString,
1257 XalanMemMgrs::getDefault());
1258
1259 return theStream;
1260 }
1261
1262
1263
1264 /**
1265 * Outputs the target string to the specified stream
1266 *
1267 * @param theStream output stream
1268 * @param theString target string
1269 * @see OutputString
1270 */
1271 inline std::ostream&
operator <<(std::ostream & theStream,XalanDOMString & theString)1272 operator<<(
1273 std::ostream& theStream,
1274 XalanDOMString& theString)
1275 {
1276 OutputString(
1277 theStream,
1278 theString,
1279 theString.getMemoryManager());
1280
1281 return theStream;
1282 }
1283
1284
1285
1286 /**
1287 * Retrieves a character at a specified index in the target string
1288 *
1289 * @deprecated This function is deprecated.
1290 *
1291 * @param theString target string
1292 * @param theIndex index of character
1293 * @return character at specified index
1294 */
1295 inline XalanDOMChar
charAt(const XalanDOMString & theString,XalanDOMString::size_type theIndex)1296 charAt(
1297 const XalanDOMString& theString,
1298 XalanDOMString::size_type theIndex)
1299 {
1300 return theString[theIndex];
1301 }
1302
1303
1304
1305 /**
1306 * Determines whether character represents white space
1307 *
1308 * @param theChar target character
1309 * @return true if character represents white space
1310 */
1311 inline bool
isXMLWhitespace(XalanDOMChar theChar)1312 isXMLWhitespace(XalanDOMChar theChar)
1313 {
1314 return XalanXMLChar::isWhitespace(theChar);
1315 }
1316
1317
1318
1319 /**
1320 * Determines whether character represents a digit
1321 *
1322 * @param theChar target character
1323 * @return true if character represents a digit
1324 */
1325 inline bool
isXMLDigit(XalanDOMChar theChar)1326 isXMLDigit(XalanDOMChar theChar)
1327 {
1328 return XalanXMLChar::isDigit(theChar);
1329 }
1330
1331
1332
1333 /**
1334 * Determines whether character represents a letter or digit
1335 *
1336 * @param theChar target character
1337 * @return true if character represents a letter or digit
1338 */
1339 inline bool
isXMLLetterOrDigit(XalanDOMChar theChar)1340 isXMLLetterOrDigit(XalanDOMChar theChar)
1341 {
1342 return XalanXMLChar::isDigit(theChar) ||
1343 XalanXMLChar::isLetter(theChar);
1344 }
1345
1346
1347
1348
1349
1350
1351 /**
1352 * Simulates the java String method substring(). Returns a new string that is
1353 * a substring of this string. The substring begins at the specified
1354 * theStartIndex and extends to the character at index theEndIndex - 1. Thus
1355 * the length of the substring is theEndIndex - theStartIndex.
1356 *
1357 * @param theString source string
1358 * @param theSubstring target string
1359 * @param theStartIndex starting index, inclusive
1360 * @param theEndIndex ending index, exclusive
1361 * @return A reference to theSubstring
1362 */
1363 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
1364 substring(
1365 const XalanDOMChar* theString,
1366 XalanDOMString& theSubstring,
1367 XalanDOMString::size_type theStartIndex,
1368 XalanDOMString::size_type theEndIndex = XalanDOMString::npos);
1369
1370
1371
1372 /**
1373 * Simulates the java String method substring(). Returns a new string that is
1374 * a substring of this string. The substring begins at the specified
1375 * theStartIndex and extends to the character at index theEndIndex - 1. Thus
1376 * the length of the substring is theEndIndex - theStartIndex.
1377 *
1378 * @param theString source string
1379 * @param theSubstring target string
1380 * @param theStartIndex starting index, inclusive
1381 * @param theEndIndex ending index, exclusive
1382 */
1383 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
1384 substring(
1385 const XalanDOMString& theString,
1386 XalanDOMString& theSubstring,
1387 XalanDOMString::size_type theStartIndex,
1388 XalanDOMString::size_type theEndIndex = XalanDOMString::npos);
1389
1390
1391
1392 /**
1393 * Simulates the java String method substring(). Returns a new string that is
1394 * a substring of this string. The substring begins at the specified
1395 * theStartIndex and extends to the character at index theEndIndex - 1. Thus
1396 * the length of the substring is theEndIndex-theStartIndex.
1397 *
1398 * @param theString source string
1399 * @param theStartIndex starting index, inclusive
1400 * @param theEndIndex ending index, exclusive
1401 * @return string containing the specified range of characters from target
1402 */
1403 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
1404 substring(
1405 const XalanDOMString& theString,
1406 XalanDOMString::size_type theStartIndex,
1407 XalanDOMString& theResult,
1408 XalanDOMString::size_type theEndIndex = XalanDOMString::npos);
1409
1410
1411
1412 /**
1413 * Converts ASCII alphabetic characters from upper case to
1414 * lower case. This function works only with the Unicode
1415 * characters A-Z.
1416 *
1417 * @param theString target string
1418 * @return string containing lower case characters
1419 */
1420 inline XalanDOMChar
toLowerASCII(XalanDOMChar theChar)1421 toLowerASCII(XalanDOMChar theChar)
1422 {
1423 if (theChar >= XalanUnicode::charLetter_A && theChar <= XalanUnicode::charLetter_Z)
1424 {
1425 return XalanDOMChar(theChar - (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a));
1426 }
1427 else
1428 {
1429 return theChar;
1430 }
1431 }
1432
1433
1434
1435 /**
1436 * Converts ASCII alphabetic characters from lower case to
1437 * upper case. This function works only with the Unicode
1438 * characters a-z.
1439 *
1440 * @param theString target string
1441 * @return string containing upper case characters
1442 */
1443 inline XalanDOMChar
toUpperASCII(XalanDOMChar theChar)1444 toUpperASCII(XalanDOMChar theChar)
1445 {
1446 if (theChar >= XalanUnicode::charLetter_a && theChar <= XalanUnicode::charLetter_z)
1447 {
1448 return XalanDOMChar(theChar + (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a));
1449 }
1450 else
1451 {
1452 return theChar;
1453 }
1454 }
1455
1456
1457
1458 /**
1459 * Flips the case to of the supplied character. This function works only with
1460 * the Unicode characters A-Z and a-z.
1461 *
1462 * @param theString target string
1463 * @return string containing lower case characters
1464 */
1465 inline XalanDOMChar
flipCaseASCII(XalanDOMChar theChar)1466 flipCaseASCII(XalanDOMChar theChar)
1467 {
1468 if (theChar >= XalanUnicode::charLetter_A && theChar <= XalanUnicode::charLetter_Z)
1469 {
1470 return XalanDOMChar(theChar - (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a));
1471 }
1472 else if (theChar >= XalanUnicode::charLetter_a && theChar <= XalanUnicode::charLetter_z)
1473 {
1474 return XalanDOMChar(theChar + (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a));
1475 }
1476 else
1477 {
1478 return theChar;
1479 }
1480 }
1481
1482
1483
1484 /**
1485 * Converts ASCII alphabetic characters from upper case to
1486 * lower case. This function works only with the characters
1487 * a-z and A-Z.
1488 *
1489 * @param theString The source string
1490 * @param theResult The target string
1491 * @return A reference to theResult
1492 */
1493 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
1494 toLowerCaseASCII(
1495 const XalanDOMChar* theString,
1496 XalanDOMString& theResult);
1497
1498
1499
1500 /**
1501 * Converts ASCII alphabetic characters from upper case to
1502 * lower case. This function works only with the characters
1503 * a-z and A-Z.
1504 *
1505 * @param theString The source string
1506 * @param theResult The target string
1507 * @return A reference to theResult
1508 */
1509 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
1510 toLowerCaseASCII(
1511 const XalanDOMString& theString,
1512 XalanDOMString& theResult);
1513
1514
1515
1516 /**
1517 * Converts ASCII alphabetic characters from upper case to
1518 * lower case. This function works only with the characters
1519 * a-z and A-Z.
1520 *
1521 * @param theString The string to convert
1522 * @return A reference to theString
1523 */
1524 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
1525 toLowerCaseASCII(XalanDOMString& theString);
1526
1527
1528
1529 /**
1530 * Converts ASCII alphabetic characters from lower case to
1531 * upper case. This function works only with the characters
1532 * a-z and A-Z.
1533 *
1534 * @param theString The source string
1535 * @param theResult The target string
1536 * @return A reference to theResult
1537 */
1538 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
1539 toUpperCaseASCII(
1540 const XalanDOMChar* theString,
1541 XalanDOMString& theResult);
1542
1543
1544
1545 /**
1546 * Converts ASCII alphabetic characters from lower case to
1547 * upper case. This function works only with the characters
1548 * a-z and A-Z.
1549 *
1550 * @param theString The source string
1551 * @param theResult The target string
1552 * @return A reference to theResult
1553 */
1554 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
1555 toUpperCaseASCII(
1556 const XalanDOMString& theString,
1557 XalanDOMString& theResult);
1558
1559
1560
1561 /**
1562 * Converts ASCII alphabetic characters from lower case to
1563 * upper case. This function works only with the characters
1564 * a-z and A-Z.
1565 *
1566 * @param theString The string to convert
1567 * @return A reference to theString
1568 */
1569 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
1570 toUpperCaseASCII(XalanDOMString& theString);
1571
1572
1573
1574 /**
1575 * Compare the contents of two strings.
1576 *
1577 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY
1578 * OTHER "COLLATION" ALGORITHM.
1579 *
1580 * @param theLHS first string to compare
1581 * @param theRHS second string to compare
1582 * @return Returns 0 for equal strings, less than 0 if theLHS is less
1583 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1584 * @see operator<()
1585 */
1586 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
1587 compare(
1588 const CharVectorType& theLHS,
1589 const CharVectorType& theRHS);
1590
1591
1592
1593 /**
1594 * Compare the contents of two character arrays.
1595 *
1596 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY
1597 * OTHER "COLLATION" ALGORITHM.
1598 *
1599 * @param theLHS first array to compare
1600 * @param theLHSLength the length of the first array
1601 * @param theRHS second array to compare
1602 * @param theRHSLength the length of the second array
1603 * @return Returns 0 for equal arrays, less than 0 if theLHS is less
1604 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1605 */
1606 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
1607 compare(
1608 const XalanDOMChar* theLHS,
1609 XalanDOMString::size_type theLHSLength,
1610 const XalanDOMChar* theRHS,
1611 XalanDOMString::size_type theRHSLength);
1612
1613
1614
1615 /**
1616 * Compare the contents of two null-terminated strings.
1617 *
1618 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY
1619 * OTHER "COLLATION" ALGORITHM.
1620 *
1621 * @param theLHS first string to compare
1622 * @param theRHS second string to compare
1623 * @return Returns 0 for equal strings, less than 0 if theLHS is less
1624 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1625 */
1626 inline int
compare(const XalanDOMChar * theLHS,const XalanDOMChar * theRHS)1627 compare(
1628 const XalanDOMChar* theLHS,
1629 const XalanDOMChar* theRHS)
1630 {
1631 return compare(theLHS, length(theLHS), theRHS, length(theRHS));
1632 }
1633
1634
1635
1636 /**
1637 * Compare the contents of two strings.
1638 *
1639 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY
1640 * OTHER "COLLATION" ALGORITHM.
1641 *
1642 * @param theLHS first string to compare
1643 * @param theRHS second string to compare
1644 * @return Returns 0 for equal strings, less than 0 if theLHS is less
1645 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1646 * @see operator<()
1647 * @see collationCompare()
1648 */
1649 inline int
compare(const XalanDOMString & theLHS,const XalanDOMString & theRHS)1650 compare(
1651 const XalanDOMString& theLHS,
1652 const XalanDOMString& theRHS)
1653 {
1654 return compare(
1655 theLHS.c_str(),
1656 theLHS.length(),
1657 theRHS.c_str(),
1658 theRHS.length());
1659 }
1660
1661
1662
1663 /**
1664 * Compare the contents of two strings.
1665 *
1666 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY
1667 * OTHER "COLLATION" ALGORITHM.
1668 *
1669 * @param theLHS first string to compare
1670 * @param theRHS second string to compare
1671 * @return Returns 0 for equal strings, less than 0 if theLHS is less
1672 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1673 */
1674 inline int
compare(const XalanDOMChar * theLHS,const XalanDOMString & theRHS)1675 compare(
1676 const XalanDOMChar* theLHS,
1677 const XalanDOMString& theRHS)
1678 {
1679 return compare(
1680 theLHS,
1681 length(theLHS),
1682 theRHS.c_str(),
1683 theRHS.length());
1684 }
1685
1686
1687
1688 /**
1689 * Compare the contents of two strings.
1690 *
1691 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY
1692 * OTHER "COLLATION" ALGORITHM.
1693 *
1694 * @param theLHS first string to compare
1695 * @param theRHS second string to compare
1696 * @return Returns 0 for equal strings, less than 0 if theLHS is less
1697 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1698 */
1699 inline int
compare(const XalanDOMString & theLHS,const XalanDOMChar * theRHS)1700 compare(
1701 const XalanDOMString& theLHS,
1702 const XalanDOMChar* theRHS)
1703 {
1704 return compare(
1705 theLHS.c_str(),
1706 theLHS.length(),
1707 theRHS,
1708 length(theRHS));
1709 }
1710
1711
1712
1713 /**
1714 * Compare the contents of two arrays in a case insensitive
1715 * manner. Only the characters a-z and A-Z are considered as
1716 * characters with "case".
1717 *
1718 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY
1719 * OTHER "COLLATION" ALGORITHM.
1720 *
1721 * @param theLHS first array to compare
1722 * @param theLHSLength the length of the first array
1723 * @param theRHS second array to compare
1724 * @param theRHSLength the length of the second array
1725 * @return Returns 0 for equal arrays, less than 0 if theLHS is less
1726 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1727 */
1728 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
1729 compareIgnoreCaseASCII(
1730 const XalanDOMChar* theLHS,
1731 XalanDOMString::size_type theLHSLength,
1732 const XalanDOMChar* theRHS,
1733 XalanDOMString::size_type theRHSLength);
1734
1735
1736
1737 /**
1738 * Compare the contents of two strings, in a case insensitive
1739 * manner. Only the characters a-z and A-Z are considered as
1740 * characters with "case".
1741 *
1742 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY
1743 * OTHER "COLLATION" ALGORITHM.
1744 *
1745 * @param theLHS first string to compare
1746 * @param theRHS second string to compare
1747 * @return Returns 0 for equal strings, less than 0 if theLHS is less
1748 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1749 */
1750 inline int
compareIgnoreCaseASCII(const XalanDOMChar * theLHS,const XalanDOMChar * theRHS)1751 compareIgnoreCaseASCII(
1752 const XalanDOMChar* theLHS,
1753 const XalanDOMChar* theRHS)
1754 {
1755 return compareIgnoreCaseASCII(theLHS, length(theLHS), theRHS, length(theRHS));
1756 }
1757
1758
1759
1760 /**
1761 * Compare the contents of two strings, in a case insensitive
1762 * manner. Only the characters a-z and A-Z are considered as
1763 * characters with "case".
1764 *
1765 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY
1766 * OTHER "COLLATION" ALGORITHM.
1767 *
1768 * @param theLHS first string to compare
1769 * @param theRHS second string to compare
1770 * @return Returns 0 for equal strings, less than 0 if theLHS is less
1771 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1772 * @see operator<
1773 * @see collationCompare
1774 */
1775 inline int
compareIgnoreCaseASCII(const XalanDOMString & theLHS,const XalanDOMString & theRHS)1776 compareIgnoreCaseASCII(
1777 const XalanDOMString& theLHS,
1778 const XalanDOMString& theRHS)
1779 {
1780 return compareIgnoreCaseASCII(
1781 theLHS.c_str(),
1782 theLHS.length(),
1783 theRHS.c_str(),
1784 theRHS.length());
1785 }
1786
1787
1788
1789 /**
1790 * Compare the contents of two strings, in a case insensitive
1791 * manner. Only the characters a-z and A-Z are considered as
1792 * characters with "case".
1793 *
1794 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY
1795 * OTHER "COLLATION" ALGORITHM.
1796 *
1797 * @param theLHS first string to compare
1798 * @param theRHS second string to compare
1799 * @return Returns 0 for equal strings, less than 0 if theLHS is less
1800 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1801 */
1802 inline int
compareIgnoreCaseASCII(const XalanDOMString & theLHS,const XalanDOMChar * theRHS)1803 compareIgnoreCaseASCII(
1804 const XalanDOMString& theLHS,
1805 const XalanDOMChar* theRHS)
1806 {
1807 return compareIgnoreCaseASCII(
1808 theLHS.c_str(),
1809 theLHS.length(),
1810 theRHS,
1811 length(theRHS));
1812 }
1813
1814
1815
1816 /**
1817 * Compare the contents of two strings, in a case insensitive
1818 * manner. Only the characters a-z and A-Z are considered for
1819 * the comparison.
1820 *
1821 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY
1822 * OTHER "COLLATION" ALGORITHM.
1823 *
1824 * @param theLHS first string to compare
1825 * @param theRHS second string to compare
1826 * @return Returns 0 for equal strings, less than 0 if theLHS is less
1827 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1828 */
1829 inline int
compareIgnoreCaseASCII(const XalanDOMChar * theLHS,const XalanDOMString & theRHS)1830 compareIgnoreCaseASCII(
1831 const XalanDOMChar* theLHS,
1832 const XalanDOMString& theRHS)
1833 {
1834 return compareIgnoreCaseASCII(
1835 theLHS,
1836 length(theLHS),
1837 theRHS.c_str(),
1838 theRHS.length());
1839 }
1840
1841
1842
1843 /**
1844 * Compare the contents of two character arrays.
1845 *
1846 * @param theLHS first array to compare
1847 * @param theLHSLength the length of the first array
1848 * @param theRHS second array to compare
1849 * @param theRHSLength the length of the second array
1850 * @return Returns 0 for equal arrays, less than 0 if theLHS is less
1851 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1852 */
1853 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
1854 collationCompare(
1855 const XalanDOMChar* theLHS,
1856 XalanDOMString::size_type theLHSLength,
1857 const XalanDOMChar* theRHS,
1858 XalanDOMString::size_type theRHSLength);
1859
1860
1861
1862 /**
1863 * Compare the contents of two strings.
1864 *
1865 * @param theLHS first string to compare
1866 * @param theRHS second string to compare
1867 * @return Returns 0 for equal strings, less than 0 if theLHS is less
1868 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1869 * @see operator<()
1870 * @see compare()
1871 */
1872 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
1873 collationCompare(
1874 const XalanDOMChar* theLHS,
1875 const XalanDOMChar* theRHS);
1876
1877
1878
1879 /**
1880 * Compare the contents of two strings.
1881 *
1882 * @param theLHS first string to compare
1883 * @param theRHS second string to compare
1884 * @return Returns 0 for equal strings, less than 0 if theLHS is less
1885 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1886 * @see operator<()
1887 * @see compare()
1888 */
1889 inline int
collationCompare(const XalanDOMString & theLHS,const XalanDOMString & theRHS)1890 collationCompare(
1891 const XalanDOMString& theLHS,
1892 const XalanDOMString& theRHS)
1893 {
1894 return collationCompare(theLHS.c_str(), theRHS.c_str());
1895 }
1896
1897
1898
1899 /**
1900 * Compare the contents of two strings.
1901 *
1902 * @param theLHS first string to compare
1903 * @param theRHS second string to compare
1904 * @return Returns 0 for equal strings, less than 0 if theLHS is less
1905 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1906 */
1907 inline int
collationCompare(const XalanDOMChar * theLHS,const XalanDOMString & theRHS)1908 collationCompare(
1909 const XalanDOMChar* theLHS,
1910 const XalanDOMString& theRHS)
1911 {
1912 return collationCompare(theLHS, theRHS.c_str());
1913 }
1914
1915
1916
1917 /**
1918 * Compare the contents of two strings.
1919 *
1920 * @param theLHS first string to compare
1921 * @param theRHS second string to compare
1922 * @return Returns 0 for equal strings, less than 0 if theLHS is less
1923 * than theRHS, or greater than 0 if theRHS is greater than theLHS.
1924 */
1925 inline int
collationCompare(const XalanDOMString & theLHS,const XalanDOMChar * theRHS)1926 collationCompare(
1927 const XalanDOMString& theLHS,
1928 const XalanDOMChar* theRHS)
1929 {
1930 return collationCompare(
1931 theLHS.c_str(),
1932 theLHS.length(),
1933 theRHS,
1934 length(theRHS));
1935 }
1936
1937
1938
1939 /**
1940 * Compare the contents of two arrays for equality
1941 *
1942 * @param theLHS first array to compare
1943 * @param theRHS second array to compare
1944 * @param theLength the length of the arrays
1945 * @return true if the contents of both arrays are identical
1946 */
1947 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
1948 equals(
1949 const XalanDOMChar* theLHS,
1950 const XalanDOMChar* theRHS,
1951 XalanDOMString::size_type theLength);
1952
1953
1954
1955 /**
1956 * Compare the contents of two arrays for equality
1957 *
1958 * @param theLHS first array to compare
1959 * @param theLHSLength the length of the theLHS
1960 * @param theRHS second array to compare
1961 * @param theRHSLength the length of the theRHS
1962 * @return true if the contents of both arrays are identical
1963 */
1964 inline bool
equals(const XalanDOMChar * theLHS,XalanDOMString::size_type theLHSLength,const XalanDOMChar * theRHS,XalanDOMString::size_type theRHSLength)1965 equals(
1966 const XalanDOMChar* theLHS,
1967 XalanDOMString::size_type theLHSLength,
1968 const XalanDOMChar* theRHS,
1969 XalanDOMString::size_type theRHSLength)
1970 {
1971 return theLHSLength != theRHSLength ? false : equals(theLHS, theRHS, theLHSLength);
1972 }
1973
1974
1975
1976 /**
1977 * Compare the contents of two strings for equality
1978 *
1979 * @param theLHS first string to compare
1980 * @param theRHS second string to compare
1981 * @return true if the contents of both strings are identical
1982 */
1983 inline bool
equals(const XalanDOMChar * theLHS,const XalanDOMChar * theRHS)1984 equals(
1985 const XalanDOMChar* theLHS,
1986 const XalanDOMChar* theRHS)
1987 {
1988 const XalanDOMString::size_type theLHSLength = length(theLHS);
1989
1990 return theLHSLength != length(theRHS) ? false : equals(theLHS, theRHS, theLHSLength);
1991 }
1992
1993
1994
1995 /**
1996 * Compare the contents of two strings for equality
1997 *
1998 * @param theLHS first string to compare
1999 * @param theRHS second string to compare
2000 * @return true if the contents of both strings are identical
2001 */
2002 inline bool
equals(const XalanDOMString & theLHS,const XalanDOMString & theRHS)2003 equals(
2004 const XalanDOMString& theLHS,
2005 const XalanDOMString& theRHS)
2006 {
2007 return theLHS == theRHS;
2008 }
2009
2010
2011
2012 /**
2013 * Compare the contents of two strings for equality
2014 *
2015 * @param theLHS first string to compare
2016 * @param theRHS second string to compare
2017 * @return true if the contents of both strings are identical
2018 */
2019 inline bool
equals(const XalanDOMChar * theLHS,const XalanDOMString & theRHS)2020 equals(
2021 const XalanDOMChar* theLHS,
2022 const XalanDOMString& theRHS)
2023 {
2024 assert(theLHS != 0);
2025
2026 // Swap them...
2027 return theRHS == theLHS;
2028 }
2029
2030
2031
2032 /**
2033 * Compare the contents of two strings for equality
2034 *
2035 * @param theLHS first string to compare
2036 * @param theRHS second string to compare
2037 * @return true if the contents of both strings are identical
2038 */
2039 inline bool
equals(const XalanDOMString & theLHS,const XalanDOMChar * theRHS)2040 equals(const XalanDOMString& theLHS,
2041 const XalanDOMChar* theRHS)
2042 {
2043 return equals(theRHS, theLHS);
2044 }
2045
2046
2047
2048 /**
2049 * Compare the contents of two strings for equality
2050 *
2051 * @param theLHS first string to compare
2052 * @param theRHS second string to compare
2053 * @param theRHSLength the length of the theRHS
2054 * @return true if the contents of both strings are identical
2055 */
2056 inline bool
equals(const XalanDOMString & theLHS,const XalanDOMChar * theRHS,XalanDOMString::size_type theRHSLength)2057 equals(
2058 const XalanDOMString& theLHS,
2059 const XalanDOMChar* theRHS,
2060 XalanDOMString::size_type theRHSLength)
2061 {
2062 return theRHSLength != theLHS.length() ? false : equals(theLHS.c_str(), theRHSLength, theRHS, theRHSLength);
2063 }
2064
2065
2066
2067
2068 /**
2069 * Compare the contents of two arrays for equality, without regard for case.
2070 * Only the characters a-z and A-Z are considered characters with "case".
2071 *
2072 * @param theLHS first string to compare
2073 * @param theRHS second string to compare
2074 * @return true if the case-insensitive contents of both strings are identical
2075 */
2076 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
2077 equalsIgnoreCaseASCII(
2078 const XalanDOMChar* theLHS,
2079 const XalanDOMChar* theRHS,
2080 XalanDOMString::size_type theLength);
2081
2082
2083
2084 /**
2085 * Compare the contents of two strings for equality, without regard for case.
2086 * Only the characters a-z and A-Z are considered characters with "case".
2087 *
2088 * @param theLHS first string to compare
2089 * @param theLHSLength the length of the theLHS
2090 * @param theRHS second string to compare
2091 * @param theRHSLength the length of the theRHS
2092 * @return true if both strings are identical
2093 */
2094 inline bool
equalsIgnoreCaseASCII(const XalanDOMChar * theLHS,XalanDOMString::size_type theLHSLength,const XalanDOMChar * theRHS,XalanDOMString::size_type theRHSLength)2095 equalsIgnoreCaseASCII(
2096 const XalanDOMChar* theLHS,
2097 XalanDOMString::size_type theLHSLength,
2098 const XalanDOMChar* theRHS,
2099 XalanDOMString::size_type theRHSLength)
2100 {
2101 return theLHSLength != theRHSLength ? false :
2102 equalsIgnoreCaseASCII(theLHS, theRHS, theLHSLength);
2103 }
2104
2105
2106
2107 /**
2108 * Compare the contents of two strings for equality, without regard for case.
2109 * Only the characters a-z and A-Z are considered characters with "case".
2110 *
2111 * @param theLHS first string to compare
2112 * @param theRHS second string to compare
2113 * @return true if both strings are identical
2114 */
2115 inline bool
equalsIgnoreCaseASCII(const XalanDOMChar * theLHS,const XalanDOMChar * theRHS)2116 equalsIgnoreCaseASCII(
2117 const XalanDOMChar* theLHS,
2118 const XalanDOMChar* theRHS)
2119 {
2120 const XalanDOMString::size_type theLength = length(theLHS);
2121
2122 return theLength != length(theRHS) ? false :
2123 equalsIgnoreCaseASCII(theLHS, theRHS, theLength);
2124 }
2125
2126
2127
2128 /**
2129 * Compare the contents of two strings for equality, without regard for case
2130 * Only the characters A-Z and a-z are considered.
2131 *
2132 * @param theLHS first string to compare
2133 * @param theRHS second string to compare
2134 * @return true if the case-insensitive contents of both strings are identical
2135 */
2136 inline bool
equalsIgnoreCaseASCII(const XalanDOMString & theLHS,const XalanDOMString & theRHS)2137 equalsIgnoreCaseASCII(
2138 const XalanDOMString& theLHS,
2139 const XalanDOMString& theRHS)
2140 {
2141 const XalanDOMString::size_type theLength = theLHS.length();
2142
2143 return theLength != theRHS.length() ? false :
2144 equalsIgnoreCaseASCII(
2145 theLHS.c_str(),
2146 theRHS.c_str(),
2147 theLength);
2148 }
2149
2150
2151
2152 /**
2153 * Compare the contents of two strings for equality, without regard for case.
2154 * Only the characters a-z and A-Z are considered characters with "case".
2155 *
2156 * @param theLHS first string to compare
2157 * @param theRHS second string to compare
2158 * @return true if the case-insensitive contents of both strings are identical
2159 */
2160 inline bool
equalsIgnoreCaseASCII(const XalanDOMChar * theLHS,const XalanDOMString & theRHS)2161 equalsIgnoreCaseASCII(
2162 const XalanDOMChar* theLHS,
2163 const XalanDOMString& theRHS)
2164 {
2165 const XalanDOMString::size_type theRHSLength = theRHS.length();
2166
2167 return theRHSLength != length(theLHS) ? false :
2168 equalsIgnoreCaseASCII(
2169 theLHS,
2170 theRHS.c_str(),
2171 theRHSLength);
2172 }
2173
2174
2175
2176 /**
2177 * Compare the contents of two strings for equality, without regard for case.
2178 * Only the characters A-Z and a-z are considered.
2179 *
2180 * @param theLHS first string to compare
2181 * @param theRHS second string to compare
2182 * @return true if the case-insensitive contents of both strings are identical
2183 */
2184 inline bool
equalsIgnoreCaseASCII(const XalanDOMString & theLHS,const XalanDOMChar * theRHS)2185 equalsIgnoreCaseASCII(
2186 const XalanDOMString& theLHS,
2187 const XalanDOMChar* theRHS)
2188 {
2189 return equalsIgnoreCaseASCII(theRHS, theLHS);
2190 }
2191
2192
2193
2194 /**
2195 * Implements operator< for CharVectorType.
2196 *
2197 * @param theLHS first string to compare
2198 * @param theRHS second string to compare
2199 * @return Returns true if theLHS is lexically
2200 * less than theRHS
2201 * @see compare
2202 */
2203 inline bool
operator <(const CharVectorType & theLHS,const CharVectorType & theRHS)2204 operator<(
2205 const CharVectorType& theLHS,
2206 const CharVectorType& theRHS)
2207 {
2208 return compare(theLHS, theRHS) < 0 ? true : false;
2209 }
2210
2211
2212
2213 /**
2214 * Implements operator< for DOMStrings.
2215 *
2216 * @param theLHS first string to compare
2217 * @param theRHS second string to compare
2218 * @return Returns true if theLHS is lexically
2219 * less than theRHS
2220 * @see compare
2221 */
2222 inline bool
operator <(const XalanDOMString & theLHS,const XalanDOMString & theRHS)2223 operator<(
2224 const XalanDOMString& theLHS,
2225 const XalanDOMString& theRHS)
2226 {
2227 return compare(theLHS, theRHS) < 0 ? true : false;
2228 }
2229
2230
2231
2232 /**
2233 * Assign one string to another
2234 *
2235 * @deprecated This function is deprecated.
2236 *
2237 * @param theString target string
2238 * @param theStringToAppend string to assign
2239 * @param theStringToAppendLength length of the string (XalanDOMString::npos implies the string is null-terminated)
2240 * @return a reference to the target string
2241 */
2242 inline XalanDOMString&
assign(XalanDOMString & theString,const XalanDOMString & theStringToAssign)2243 assign(
2244 XalanDOMString& theString,
2245 const XalanDOMString& theStringToAssign)
2246 {
2247 theString = theStringToAssign;
2248
2249 return theString;
2250 }
2251
2252
2253
2254 /**
2255 * Assign one string to another
2256 *
2257 * @deprecated This function is deprecated.
2258 *
2259 * @param theString target string
2260 * @param theStringToAppend string to assign
2261 * @param theStringToAppendLength length of the string (XalanDOMString::npos implies the string is null-terminated)
2262 * @return a reference to the target string
2263 */
2264 inline XalanDOMString&
assign(XalanDOMString & theString,const XalanDOMChar * theStringToAssign,XalanDOMString::size_type theStringToAssignLength=XalanDOMString::npos)2265 assign(
2266 XalanDOMString& theString,
2267 const XalanDOMChar* theStringToAssign,
2268 XalanDOMString::size_type theStringToAssignLength = XalanDOMString::npos)
2269 {
2270 if (theStringToAssignLength == XalanDOMString::npos)
2271 {
2272 theString.assign(theStringToAssign);
2273 }
2274 else
2275 {
2276 theString.assign(theStringToAssign, theStringToAssignLength);
2277 }
2278
2279 return theString;
2280 }
2281
2282
2283
2284 /**
2285 * Concatenate two strings
2286 *
2287 * @deprecated This function is deprecated.
2288 *
2289 * @param theString target string
2290 * @param theStringToAppend string to add to target
2291 * @return a reference to the target string
2292 */
2293 inline XalanDOMString&
append(XalanDOMString & theString,const XalanDOMString & theStringToAppend)2294 append(
2295 XalanDOMString& theString,
2296 const XalanDOMString& theStringToAppend)
2297 {
2298 theString.append(theStringToAppend);
2299
2300 return theString;
2301 }
2302
2303
2304
2305 /**
2306 * Concatenate two strings
2307 *
2308 * @deprecated This function is deprecated.
2309 *
2310 * @param theString target string
2311 * @param theStringToAppend string to add to target
2312 * @param theStringToAppendLength length of the string (XalanDOMString::npos implies the string is null-terminated)
2313 * @return a reference to the target string
2314 */
2315 inline XalanDOMString&
append(XalanDOMString & theString,const XalanDOMChar * theStringToAppend,XalanDOMString::size_type theStringToAppendLength=XalanDOMString::npos)2316 append(
2317 XalanDOMString& theString,
2318 const XalanDOMChar* theStringToAppend,
2319 XalanDOMString::size_type theStringToAppendLength = XalanDOMString::npos)
2320 {
2321 assert(theStringToAppend != 0);
2322
2323 if (theStringToAppendLength == XalanDOMString::npos)
2324 {
2325 theString.append(theStringToAppend);
2326 }
2327 else
2328 {
2329 theString.append(theStringToAppend, theStringToAppendLength);
2330 }
2331
2332 return theString;
2333 }
2334
2335
2336
2337 /**
2338 * Concatenate two strings
2339 *
2340 * @deprecated This function is deprecated.
2341 *
2342 * @param theString target string
2343 * @param theStringToAppend string to add to target
2344 * @param theStringToAppendLength length of the string (XalanDOMString::npos implies the string is null-terminated)
2345 * @return string with contents of 'theStringToAppend' added to target string
2346 */
2347 inline XalanDOMString&
append(XalanDOMString & theString,const char * theStringToAppend,XalanDOMString::size_type theStringToAppendLength=XalanDOMString::npos)2348 append(
2349 XalanDOMString& theString,
2350 const char* theStringToAppend,
2351 XalanDOMString::size_type theStringToAppendLength = XalanDOMString::npos)
2352 {
2353 XalanDOMString tmp(theString.getMemoryManager());
2354
2355 TranscodeFromLocalCodePage(theStringToAppend, tmp, theStringToAppendLength);
2356
2357 theString.append(tmp);
2358
2359 return theString;
2360 }
2361
2362
2363
2364 /**
2365 * Concatenate a string and a character
2366 *
2367 * @deprecated This function is deprecated.
2368 *
2369 * @param theString target string
2370 * @param theCharToAppend the character to add to the target
2371 * @return string with the character appended
2372 */
2373 inline XalanDOMString&
append(XalanDOMString & theString,const XalanDOMChar theCharToAppend)2374 append(
2375 XalanDOMString& theString,
2376 const XalanDOMChar theCharToAppend)
2377 {
2378 theString.append(1, theCharToAppend);
2379
2380 return theString;
2381 }
2382
2383
2384
2385 /**
2386 * Concatenate a string and a character
2387 *
2388 * @deprecated This function is deprecated.
2389 *
2390 * @param theString target string
2391 * @param theCharToAppend the character to add to the target
2392 * @return string with the character appended
2393 */
2394 inline XalanDOMString&
append(XalanDOMString & theString,char theCharToAppend)2395 append(
2396 XalanDOMString& theString,
2397 char theCharToAppend)
2398 {
2399 // We have to transcode before appending...
2400 char theTempBuffer[] = { theCharToAppend, '\0' };
2401
2402 return append(theString, theTempBuffer);
2403 }
2404
2405
2406
2407 /**
2408 * Insert a string into another string.
2409 *
2410 * @deprecated This function is deprecated.
2411 *
2412 * @param theString target string
2413 * @param thePosition The position in the target string to insert
2414 * @param theStringToInsert The string to insert
2415 * @return A reference to the target string
2416 */
2417 inline XalanDOMString&
insert(XalanDOMString & theString,XalanDOMString::size_type thePosition,const XalanDOMString & theStringToInsert)2418 insert(
2419 XalanDOMString& theString,
2420 XalanDOMString::size_type thePosition,
2421 const XalanDOMString& theStringToInsert)
2422 {
2423 theString.insert(thePosition, theStringToInsert);
2424
2425 return theString;
2426 }
2427
2428
2429
2430 /**
2431 * Insert a string into another string.
2432 *
2433 * @deprecated This function is deprecated.
2434 *
2435 * @param theString target string
2436 * @param thePosition The position in the target string to insert
2437 * @param theStringToInsert The string to insert
2438 * @return A reference to the target string
2439 */
2440 inline XalanDOMString&
insert(XalanDOMString & theString,XalanDOMString::size_type thePosition,const XalanDOMChar * theStringToInsert)2441 insert(
2442 XalanDOMString& theString,
2443 XalanDOMString::size_type thePosition,
2444 const XalanDOMChar* theStringToInsert)
2445 {
2446 theString.insert(thePosition, theStringToInsert);
2447
2448 return theString;
2449 }
2450
2451
2452
2453 /**
2454 * Remove leading and trailing whitespace.
2455 *
2456 * @param theString The string to trim.
2457 * @param theResult The result string.
2458 * @return A reference to theResult.
2459 */
2460 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&)
2461 trim(
2462 const XalanDOMString& theString,
2463 XalanDOMString& theResult);
2464
2465
2466
2467 /**
2468 * Remove all elements from target string
2469 *
2470 * @deprecated This function is deprecated.
2471 *
2472 * @param theString target string
2473 */
2474 inline void
clear(XalanDOMString & theString)2475 clear(XalanDOMString& theString)
2476 {
2477 theString.clear();
2478 }
2479
2480
2481
2482 /**
2483 * Remove all elements from target string
2484 *
2485 * @deprecated This function is deprecated.
2486 *
2487 * @param theString target string
2488 */
2489 inline void
erase(XalanDOMString & theString)2490 erase(XalanDOMString& theString)
2491 {
2492 theString.erase();
2493 }
2494
2495
2496
2497 /**
2498 * Remove all elements from target string
2499 * and frees all allocated memory.
2500 *
2501 * @param theString target string
2502 */
2503 inline void
releaseMemory(XalanDOMString & theString,MemoryManager & theManager)2504 releaseMemory(XalanDOMString& theString,MemoryManager& theManager)
2505 {
2506 XalanDOMString(theManager).swap(theString);
2507 }
2508
2509
2510
2511 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
2512 CopyWideStringToVector(
2513 const XalanDOMChar* theString,
2514 CharVectorType& theVector);
2515
2516
2517
2518 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void)
2519 CopyStringToVector(
2520 const char* theString,
2521 CharVectorType& theVector);
2522
2523
2524
2525 /**
2526 * Utility function to make a null-terminated vector of XMLChs, from a
2527 * null-terminated array of chars, via transcoding, if requested.
2528 *
2529 * @param data array to be converted
2530 * @param whether or not to transcode
2531 * @return null-terminated vector of XalanDOMChar
2532 */
2533 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType&)
2534 MakeXalanDOMCharVector(
2535 const char* data,
2536 XalanDOMCharVectorType& result,
2537 bool fTranscode = true);
2538
2539
2540
2541 /**
2542 * Utility function to make a null-terminated vector of XMLChs, from a
2543 * null-terminated array of XalanDOMChar.
2544 *
2545 * @param data array to be converted
2546 * @return null-terminated vector of XalanDOMChar
2547 */
2548 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType&)
2549 MakeXalanDOMCharVector(const XalanDOMChar* data,
2550 XalanDOMCharVectorType& result);
2551
2552
2553
2554 /**
2555 * Utility function to make a null-terminated vector of XMLChs, from a
2556 * XalanDOMString
2557 *
2558 * @param data XalanDOMString to be converted
2559 * @return null-terminated vector of XalanDOMChar
2560 */
2561 inline XalanDOMCharVectorType&
MakeXalanDOMCharVector(const XalanDOMString & data,XalanDOMCharVectorType & result)2562 MakeXalanDOMCharVector(const XalanDOMString& data,
2563 XalanDOMCharVectorType& result)
2564 {
2565 return MakeXalanDOMCharVector(data.c_str(),result);
2566 }
2567
2568
2569
2570 struct c_wstr_functor
2571 {
2572 const XalanDOMChar*
operator ()XALAN_CPP_NAMESPACE::c_wstr_functor2573 operator() (const XalanDOMString& theString) const
2574 {
2575 return theString.c_str();
2576 }
2577 };
2578
2579
2580
2581 /**
2582 * Less than functor for DOMStrings which ignores case for the characters a-z and A-Z
2583 *
2584 * @param theLHS first string to compare
2585 * @param theRHS second string to compare
2586 * @return true if the theLHS is less than theRHS, without respect to case.
2587 */
2588 struct DOMStringLessThanIgnoreCaseASCIIFunction
2589 {
2590 bool
operator ()XALAN_CPP_NAMESPACE::DOMStringLessThanIgnoreCaseASCIIFunction2591 operator() (const XalanDOMString& theLHS,
2592 const XalanDOMString& theRHS) const
2593 {
2594 return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false;
2595 }
2596 };
2597
2598
2599
2600 /**
2601 * Less than or equal functor for DOMStrings
2602 *
2603 * @param theLHS first string to compare
2604 * @param theRHS second string to compare
2605 * @return true if the theLHS is less than or equal to theRHS
2606 */
2607 struct DOMStringLessThanOrEqualFunction
2608 {
2609 bool
operator ()XALAN_CPP_NAMESPACE::DOMStringLessThanOrEqualFunction2610 operator() (const XalanDOMString& theLHS,
2611 const XalanDOMString& theRHS) const
2612 {
2613 return compare(theLHS, theRHS) <= 0 ? true : false;
2614 }
2615 };
2616
2617
2618
2619 /**
2620 * Greater than functor for DOMStrings
2621 *
2622 * @param theLHS first string to compare
2623 * @param theRHS second string to compare
2624 * @return true if the theLHS is greater than theRHS
2625 */
2626 struct DOMStringGreaterThanFunction
2627 {
2628 bool
operator ()XALAN_CPP_NAMESPACE::DOMStringGreaterThanFunction2629 operator() (const XalanDOMString& theLHS,
2630 const XalanDOMString& theRHS) const
2631 {
2632 return compare(theLHS, theRHS) > 0 ? true : false;
2633 }
2634 };
2635
2636
2637
2638 /**
2639 * Greater than or equal functor for DOMStrings
2640 *
2641 * @param theLHS first string to compare
2642 * @param theRHS second string to compare
2643 * @return true if the theLHS is greater than or equal to theRHS
2644 */
2645 struct DOMStringGreaterThanOrEqualFunction
2646 {
2647 bool
operator ()XALAN_CPP_NAMESPACE::DOMStringGreaterThanOrEqualFunction2648 operator() (const XalanDOMString& theLHS,
2649 const XalanDOMString& theRHS) const
2650 {
2651 return compare(theLHS, theRHS) >= 0 ? true : false;
2652 }
2653 };
2654
2655
2656
2657 /**
2658 * This functor is designed to compare 0-terminated wide strings in a case-insensitive
2659 * manner. It substitutes for the default less<type*> so that the contents of wide strings
2660 * can be compared, rather than just the pointers.
2661 */
2662 struct less_no_case_ascii_wide_string
2663 {
2664 /**
2665 * Compare the values of two objects.
2666 *
2667 *
2668 * @param theLHS first object to compare
2669 * @param theRHS second object to compare
2670 * @return true if objects are the same
2671 */
2672 bool
operator ()XALAN_CPP_NAMESPACE::less_no_case_ascii_wide_string2673 operator()(
2674 const XalanDOMChar* theLHS,
2675 const XalanDOMChar* theRHS) const
2676 {
2677 return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false;
2678 }
2679 };
2680
2681
2682
2683 /**
2684 * Determines if the string contains only whitespace
2685 *
2686 * @param theString target string
2687 * @return true if string contains only whitespace
2688 */
2689 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
2690 isXMLWhitespace(const XalanDOMString& string);
2691
2692
2693
2694 /**
2695 * Determines if a range in an array contains only whitespace
2696 *
2697 * @param ch target array
2698 * @param start starting index to examine
2699 * @param length number of characters to examine
2700 * @return true if specified range contains only whitespace
2701 */
2702 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool)
2703 isXMLWhitespace(
2704 const XalanDOMChar ch[],
2705 XalanDOMString::size_type start,
2706 XalanDOMString::size_type length);
2707
2708
2709
2710 /**
2711 * Determines if a null-terminated string contains only whitespace
2712 *
2713 * @param theString target string
2714 * @return true if the string contains only whitespace
2715 */
2716 inline bool
isXMLWhitespace(const XalanDOMChar * theString)2717 isXMLWhitespace(const XalanDOMChar* theString)
2718 {
2719 assert(theString != 0);
2720
2721 return isXMLWhitespace(theString, 0, length(theString));
2722 }
2723
2724
2725
2726 }
2727
2728
2729
2730 #endif // DOMSTRINGHELPER_HEADER_GUARD_1357924680
2731