Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

DOMStringHelper.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #if !defined(DOMSTRINGHELPER_HEADER_GUARD_1357924680)
17 #define DOMSTRINGHELPER_HEADER_GUARD_1357924680
18 
19 
20 
21 // Base include file. Must be first.
23 
24 
25 
26 #include <algorithm>
27 #include <cassert>
28 #include <functional>
29 #if defined(XALAN_CLASSIC_IOSTREAMS)
30 class ostream;
31 #else
32 #include <iosfwd>
33 #endif
34 
35 
36 
41 
42 
43 
45 
46 
47 
51 
52 
53 
54 XALAN_CPP_NAMESPACE_BEGIN
55 
56 
57 
58 XALAN_USING_XERCES(MemoryManager)
59 
60 
61 
62 class XalanOutputStream;
63 
64 
65 
66 // This macro has been defined to deal with certain C++ compilers which
67 // do not create Unicode strings when the "L" string constant prefix is
68 // used. It is meant _only_ for use with static strings.
69 #if defined(XALAN_LSTRSUPPORT) && !defined(XALAN_XALANDOMCHAR_USHORT_MISMATCH)
70 
71 #define XALAN_STATIC_UCODE_STRING(str) L##str
72 
73 #else
74 
75 #define XALAN_STATIC_UCODE_STRING(str) str
76 
77 #endif
78 
79 
80 
81 #if defined(XALAN_NO_ALGORITHMS_WITH_BUILTINS)
82 
83 template<class InputIteratorType, class OutputIteratorType>
84 inline OutputIteratorType
85 XalanCopy(
86  InputIteratorType begin,
87  InputIteratorType end,
88  OutputIteratorType iterator)
89 {
90  for(; begin != end; ++iterator, ++begin)
91  {
92  *iterator = *begin;
93  }
94 
95  return iterator;
96 }
97 
98 
99 
100 template<class InputIteratorType, class OutputIteratorType, class UnaryFunction>
101 inline OutputIteratorType
103  InputIteratorType begin,
104  InputIteratorType end,
105  OutputIteratorType iterator,
106  UnaryFunction function)
107 {
108  for(; begin != end; ++iterator, ++begin)
109  {
110  *iterator = function(*begin);
111  }
112 
113  return iterator;
114 }
115 
116 #else
117 
118 template<class InputIteratorType, class OutputIteratorType>
119 inline OutputIteratorType
121  InputIteratorType begin,
122  InputIteratorType end,
123  OutputIteratorType iterator)
124 {
125  return XALAN_STD_QUALIFIER copy(begin, end, iterator);
126 }
127 
128 
129 
130 template<class InputIteratorType, class OutputIteratorType, class UnaryFunction>
131 inline OutputIteratorType
133  InputIteratorType begin,
134  InputIteratorType end,
135  OutputIteratorType iterator,
136  UnaryFunction function)
137 {
138  return XALAN_STD_QUALIFIER transform(begin, end, iterator);
139 }
140 
141 #endif
142 
143 
144 
152 inline const XalanDOMChar*
153 c_wstr(const XalanDOMString& theString)
154 {
155  return theString.c_str();
156 }
157 
158 
159 
167 inline const char*
168 c_str(const CharVectorType& theString)
169 {
170  if (theString.empty() == true)
171  {
172  return 0;
173  }
174  else
175  {
176  const char* const ptr = &theString[0];
177 
178  assert(ptr[theString.size() - 1] == '\0');
179 
180  return ptr;
181  }
182 }
183 
184 
185 
201 inline const XalanDOMChar*
202 c_wstr(const XalanDOMChar* theString)
203 {
204  return theString;
205 }
206 
207 
208 
216 inline const XalanDOMChar*
217 toCharArray(const XalanDOMString& theString)
218 {
219  return theString.c_str();
220 }
221 
222 
223 
230 inline const XalanDOMChar*
231 toCharArray(const XalanDOMChar* theString)
232 {
233  return theString;
234 }
235 
236 
237 
245 inline const char*
246 toCharArray(const CharVectorType& theString)
247 {
248  return theString.empty() == true ? 0 : &theString[0];
249 }
250 
251 
252 
260 inline void
262  XalanDOMString& theString,
263  XalanDOMString::size_type theCount)
264 {
265  theString.reserve(theCount);
266 }
267 
268 
269 
277 length(const XalanDOMString& theString)
278 {
279  return theString.length();
280 }
281 
282 
283 
292 length(const XalanDOMChar* theString)
293 {
294  assert(theString != 0);
295 
296  const XalanDOMChar* theBufferPointer = theString;
297 
298  while(*theBufferPointer != 0)
299  {
300  theBufferPointer++;
301  }
302 
303  return XalanDOMString::size_type(theBufferPointer - theString);
304 }
305 
306 
307 
315 length(const char* theString)
316 {
317  assert(theString != 0);
318 
319  return XalanDOMString::length(theString);
320 }
321 
322 
323 
330 inline bool
332 {
333  return str.empty();
334 }
335 
336 
337 
349  const XalanDOMChar* theString,
350  XalanDOMChar theChar)
351 {
352  assert(theString != 0);
353 
354  const XalanDOMChar* thePointer = theString;
355 
356  while(*thePointer != theChar && *thePointer != 0)
357  {
358  ++thePointer;
359  }
360 
361  return XalanDOMString::size_type(thePointer - theString);
362 }
363 
364 
365 
378  const XalanDOMChar* theString,
379  XalanDOMString::size_type theStringLength,
380  XalanDOMChar theChar)
381 {
382  assert(theString != 0);
383 
384  const XalanDOMChar* thePointer = theString;
385  const XalanDOMChar* const theEndPointer = theString + theStringLength;
386 
387  while(*thePointer != theChar && thePointer != theEndPointer)
388  {
389  ++thePointer;
390  }
391 
392  return XalanDOMString::size_type(thePointer - theString);
393 }
394 
395 
396 
408  const XalanDOMString& theString,
409  XalanDOMChar theChar)
410 {
411  return length(theString) == 0 ? 0 : indexOf(c_wstr(theString), theChar);
412 }
413 
414 
415 
428 indexOf(
429  const XalanDOMChar* theString,
430  XalanDOMString::size_type theStringLength,
431  const XalanDOMChar* theSubstring,
432  XalanDOMString::size_type theSubstringLength);
433 
434 
435 
446 indexOf(
447  const XalanDOMChar* theString,
448  const XalanDOMChar* theSubstring);
449 
450 
451 
462 indexOf(
463  const XalanDOMString& theString,
464  const XalanDOMString& theSubstring);
465 
466 
467 
480  const XalanDOMChar* theString,
481  XalanDOMChar theChar);
482 
483 
484 
496  const XalanDOMString& theString,
497  XalanDOMChar theChar)
498 {
499  return lastIndexOf(c_wstr(theString), theChar);
500 }
501 
502 
503 
514 startsWith(
515  const XalanDOMChar* theString,
516  XalanDOMString::size_type theStringLength,
517  const XalanDOMChar* theSubstring,
518  XalanDOMString::size_type theSubstringLength);
519 
520 
521 
529 inline bool
531  const XalanDOMChar* theString,
532  const XalanDOMChar* theSubstring)
533 {
534  assert(theString != 0 && theSubstring != 0);
535 
536  return startsWith(theString, length(theString), theSubstring, length(theSubstring));
537 }
538 
539 
540 
548 inline bool
550  const XalanDOMChar* theString,
551  const XalanDOMString& theSubstring)
552 {
553  assert(theString != 0);
554 
555  return startsWith(theString, length(theString), c_wstr(theSubstring), length(theSubstring));
556 }
557 
558 
559 
567 inline bool
569  const XalanDOMString& theString,
570  const XalanDOMChar* theSubstring)
571 {
572  assert(theSubstring != 0);
573 
574  return startsWith(c_wstr(theString), length(theString), theSubstring, length(theSubstring));
575 }
576 
577 
578 
587 inline bool
589  const XalanDOMString& theString,
590  const XalanDOMChar* theSubstring,
591  XalanDOMString::size_type theSubstringLength)
592 {
593  assert(theSubstring != 0);
594 
595  return startsWith(c_wstr(theString), length(theString), theSubstring, theSubstringLength);
596 }
597 
598 
599 
607 inline bool
609  const XalanDOMString& theString,
610  const XalanDOMString& theSubstring)
611 {
612  return startsWith(c_wstr(theString), length(theString), c_wstr(theSubstring), length(theSubstring));
613 }
614 
615 
616 
617 
618 
619 
620 
629 endsWith(
630  const XalanDOMChar* theString,
631  XalanDOMString::size_type theStringLength,
632  const XalanDOMChar* theSubstring,
633  XalanDOMString::size_type theSubstringLength);
634 
635 
636 
644 inline bool
646  const XalanDOMChar* theString,
647  const XalanDOMChar* theSubstring)
648 {
649  assert(theString != 0 && theSubstring != 0);
650 
651  return endsWith(theString, length(theString), theSubstring, length(theSubstring));
652 }
653 
654 
655 
663 inline bool
665  const XalanDOMString& theString,
666  const XalanDOMString& theSubstring)
667 {
668  return endsWith(c_wstr(theString), length(theString), c_wstr(theSubstring), length(theSubstring));
669 }
670 
671 
672 
682  const void* theValue,
683  XalanDOMString& theResult);
684 
685 
686 
687 
688 
698  double theValue,
699  XalanDOMString& theResult);
700 
701 
702 
703 
705 {
706 public:
707 
708  typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int);
709 
710  static void
711  DoubleToCharacters(
712  double theDouble,
713  FormatterListener& formatterListener,
714  MemberFunctionPtr function);
715 
716  static void
717  LongToCharacters(
718  long theLong,
719  FormatterListener& formatterListener,
720  MemberFunctionPtr function);
721 };
722 
723 
724 
735  long theValue,
736  XalanDOMString& theResult);
737 
738 
739 
740 
741 
742 
753  unsigned long theValue,
754  XalanDOMString& theResult);
755 
756 
757 
767  long theValue,
768  XalanDOMString& theResult);
769 
770 
771 
772 
783  unsigned long theValue,
784  XalanDOMString& theResult);
785 
786 
787 
788 
789 
797 WideStringToInt(const XalanDOMChar* theString);
798 
799 
800 
808 WideStringToLong(const XalanDOMChar* theString);
809 
810 
811 
819 WideStringToUnsignedLong(const XalanDOMChar* theString);
820 
821 
822 
832  const XalanDOMChar* theString,
833  MemoryManager& theMemoryManager);
834 
835 
836 
843 inline int
845 {
846  return WideStringToInt(c_wstr(theString));
847 }
848 
849 
850 
857 inline long
859 {
860  return WideStringToLong(c_wstr(theString));
861 }
862 
863 
864 
871 inline unsigned long
873 {
874  return WideStringToUnsignedLong(c_wstr(theString));
875 }
876 
877 
878 
886 inline double
888  const XalanDOMString& theString,
889  MemoryManager& theMemoryManager)
890 {
891  return WideStringToDouble(
892  c_wstr(theString),
893  theMemoryManager);
894 }
895 
896 
897 
907  XalanOutputStream& theStream,
908  const CharVectorType& theString);
909 
910 
911 
921 #if defined(XALAN_NO_STD_NAMESPACE)
922  ostream& theStream,
923 #else
924  std::ostream& theStream,
925 #endif
926  const CharVectorType& theString);
927 
928 
929 
939  XalanOutputStream& theStream,
940  const XalanDOMChar* theString);
941 
942 
943 
953 #if defined(XALAN_NO_STD_NAMESPACE)
954  ostream& theStream,
955 #else
956  std::ostream& theStream,
957 #endif
958  const XalanDOMChar* theString,
959  MemoryManager& theMemoryManager);
960 
961 
962 
970 inline void
972  XalanOutputStream& theStream,
973  const XalanDOMString& theString)
974 {
975  if (isEmpty(theString) == false)
976  {
977  OutputString(
978  theStream,
979  c_wstr(theString));
980  }
981 }
982 
983 
984 
993 inline void
995 #if defined(XALAN_NO_STD_NAMESPACE)
996  ostream& theStream,
997 #else
998  std::ostream& theStream,
999 #endif
1000  const XalanDOMString& theString,
1001  MemoryManager& theMemoryManager)
1002 {
1003  OutputString(
1004  theStream,
1005  c_wstr(theString),
1006  theMemoryManager);
1007 }
1008 
1009 
1010 
1018 inline XalanOutputStream&
1020  XalanOutputStream& theStream,
1021  const CharVectorType& theString)
1022 {
1023  OutputString(
1024  theStream,
1025  theString);
1026 
1027  return theStream;
1028 }
1029 
1030 
1031 
1039 #if defined(XALAN_NO_STD_NAMESPACE)
1040 inline ostream&
1041 operator<<(
1042  ostream& theStream,
1043 #else
1044 inline std::ostream&
1045 operator<<(
1046  std::ostream& theStream,
1047 #endif
1048  const CharVectorType& theString)
1049 {
1050  OutputString(
1051  theStream,
1052  theString);
1053 
1054  return theStream;
1055 }
1056 
1057 
1058 
1066 inline XalanOutputStream&
1068  XalanOutputStream& theStream,
1069  const XalanDOMChar* theString)
1070 {
1071  OutputString(
1072  theStream,
1073  theString);
1074 
1075  return theStream;
1076 }
1077 
1078 
1079 
1087 #if defined(XALAN_NO_STD_NAMESPACE)
1088 inline ostream&
1089 operator<<(
1090  ostream& theStream,
1091 #else
1092 inline std::ostream&
1093 operator<<(
1094  std::ostream& theStream,
1095 #endif
1096  const XalanDOMChar* theString)
1097 {
1098  OutputString(
1099  theStream,
1100  theString,
1102 
1103  return theStream;
1104 }
1105 
1106 
1107 
1115 inline XalanOutputStream&
1117  XalanOutputStream& theStream,
1118  const XalanDOMString& theString)
1119 {
1120  OutputString(theStream,
1121  theString);
1122 
1123  return theStream;
1124 }
1125 
1126 
1127 
1135 #if defined(XALAN_NO_STD_NAMESPACE)
1136 inline ostream&
1137 operator<<(
1138  ostream& theStream,
1139 #else
1140 inline std::ostream&
1141 operator<<(
1142  std::ostream& theStream,
1143 #endif
1144  const XalanDOMString& theString)
1145 {
1146  OutputString(
1147  theStream,
1148  theString,
1150 
1151  return theStream;
1152 }
1153 
1154 
1155 
1163 #if defined(XALAN_NO_STD_NAMESPACE)
1164 inline ostream&
1165 operator<<(
1166  ostream& theStream,
1167 #else
1168 inline std::ostream&
1169 operator<<(
1170  std::ostream& theStream,
1171 #endif
1172  XalanDOMString& theString)
1173 {
1174  OutputString(
1175  theStream,
1176  theString,
1177  theString.getMemoryManager());
1178 
1179  return theStream;
1180 }
1181 
1182 
1183 
1191 inline XalanDOMChar
1193  const XalanDOMString& theString,
1194  XalanDOMString::size_type theIndex)
1195 {
1196  return theString[theIndex];
1197 }
1198 
1199 
1200 
1207 inline bool
1208 isXMLWhitespace(XalanDOMChar theChar)
1209 {
1210  return XalanXMLChar::isWhitespace(theChar);
1211 }
1212 
1213 
1214 
1221 inline bool
1222 isXMLDigit(XalanDOMChar theChar)
1223 {
1224  return XalanXMLChar::isDigit(theChar);
1225 }
1226 
1227 
1228 
1235 inline bool
1236 isXMLLetterOrDigit(XalanDOMChar theChar)
1237 {
1238  return XalanXMLChar::isDigit(theChar) ||
1239  XalanXMLChar::isLetter(theChar);
1240 }
1241 
1242 
1243 
1244 
1245 
1246 
1260 substring(
1261  const XalanDOMChar* theString,
1262  XalanDOMString& theSubstring,
1263  XalanDOMString::size_type theStartIndex,
1264  XalanDOMString::size_type theEndIndex = XalanDOMString::npos);
1265 
1266 
1267 
1280 substring(
1281  const XalanDOMString& theString,
1282  XalanDOMString& theSubstring,
1283  XalanDOMString::size_type theStartIndex,
1284  XalanDOMString::size_type theEndIndex = XalanDOMString::npos);
1285 
1286 
1287 
1300 substring(
1301  const XalanDOMString& theString,
1302  XalanDOMString::size_type theStartIndex,
1303  XalanDOMString& theResult,
1304  XalanDOMString::size_type theEndIndex = XalanDOMString::npos);
1305 
1306 
1307 
1316 inline XalanDOMChar
1317 toLowerASCII(XalanDOMChar theChar)
1318 {
1319  if (theChar >= XalanUnicode::charLetter_A && theChar <= XalanUnicode::charLetter_Z)
1320  {
1321  return XalanDOMChar(theChar - (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a));
1322  }
1323  else
1324  {
1325  return theChar;
1326  }
1327 }
1328 
1329 
1330 
1339 inline XalanDOMChar
1340 toUpperASCII(XalanDOMChar theChar)
1341 {
1342  if (theChar >= XalanUnicode::charLetter_a && theChar <= XalanUnicode::charLetter_z)
1343  {
1344  return XalanDOMChar(theChar + (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a));
1345  }
1346  else
1347  {
1348  return theChar;
1349  }
1350 }
1351 
1352 
1353 
1365  const XalanDOMChar* theString,
1366  XalanDOMString& theResult);
1367 
1368 
1369 
1381  const XalanDOMString& theString,
1382  XalanDOMString& theResult);
1383 
1384 
1385 
1395 toLowerCaseASCII(XalanDOMString& theString);
1396 
1397 
1398 
1410  const XalanDOMChar* theString,
1411  XalanDOMString& theResult);
1412 
1413 
1414 
1426  const XalanDOMString& theString,
1427  XalanDOMString& theResult);
1428 
1429 
1430 
1440 toUpperCaseASCII(XalanDOMString& theString);
1441 
1442 
1443 
1457 compare(
1458  const CharVectorType& theLHS,
1459  const CharVectorType& theRHS);
1460 
1461 
1462 
1477 compare(
1478  const XalanDOMChar* theLHS,
1479  XalanDOMString::size_type theLHSLength,
1480  const XalanDOMChar* theRHS,
1481  XalanDOMString::size_type theRHSLength);
1482 
1483 
1484 
1496 inline int
1498  const XalanDOMChar* theLHS,
1499  const XalanDOMChar* theRHS)
1500 {
1501  return compare(theLHS, length(theLHS), theRHS, length(theRHS));
1502 }
1503 
1504 
1505 
1519 inline int
1521  const XalanDOMString& theLHS,
1522  const XalanDOMString& theRHS)
1523 {
1524  return compare(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS));
1525 }
1526 
1527 
1528 
1540 inline int
1542  const XalanDOMChar* theLHS,
1543  const XalanDOMString& theRHS)
1544 {
1545  return compare(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS));
1546 }
1547 
1548 
1549 
1561 inline int
1563  const XalanDOMString& theLHS,
1564  const XalanDOMChar* theRHS)
1565 {
1566  return compare(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS));
1567 }
1568 
1569 
1570 
1588  const XalanDOMChar* theLHS,
1589  XalanDOMString::size_type theLHSLength,
1590  const XalanDOMChar* theRHS,
1591  XalanDOMString::size_type theRHSLength);
1592 
1593 
1594 
1608 inline int
1610  const XalanDOMChar* theLHS,
1611  const XalanDOMChar* theRHS)
1612 {
1613  return compareIgnoreCaseASCII(theLHS, length(theLHS), theRHS, length(theRHS));
1614 }
1615 
1616 
1617 
1633 inline int
1635  const XalanDOMString& theLHS,
1636  const XalanDOMString& theRHS)
1637 {
1638  return compareIgnoreCaseASCII(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS));
1639 }
1640 
1641 
1642 
1656 inline int
1658  const XalanDOMString& theLHS,
1659  const XalanDOMChar* theRHS)
1660 {
1661  return compareIgnoreCaseASCII(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS));
1662 }
1663 
1664 
1665 
1679 inline int
1681  const XalanDOMChar* theLHS,
1682  const XalanDOMString& theRHS)
1683 {
1684  return compareIgnoreCaseASCII(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS));
1685 }
1686 
1687 
1688 
1701  const XalanDOMChar* theLHS,
1702  XalanDOMString::size_type theLHSLength,
1703  const XalanDOMChar* theRHS,
1704  XalanDOMString::size_type theRHSLength);
1705 
1706 
1707 
1718 inline int
1720  const XalanDOMChar* theLHS,
1721  const XalanDOMChar* theRHS)
1722 {
1723  return collationCompare(theLHS, length(theLHS), theRHS, length(theRHS));
1724 }
1725 
1726 
1727 
1738 inline int
1740  const XalanDOMString& theLHS,
1741  const XalanDOMString& theRHS)
1742 {
1743  return collationCompare(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS));
1744 }
1745 
1746 
1747 
1756 inline int
1758  const XalanDOMChar* theLHS,
1759  const XalanDOMString& theRHS)
1760 {
1761  return collationCompare(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS));
1762 }
1763 
1764 
1765 
1774 inline int
1776  const XalanDOMString& theLHS,
1777  const XalanDOMChar* theRHS)
1778 {
1779  return collationCompare(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS));
1780 }
1781 
1782 
1783 
1793 equals(
1794  const XalanDOMChar* theLHS,
1795  const XalanDOMChar* theRHS,
1796  XalanDOMString::size_type theLength);
1797 
1798 
1799 
1809 inline bool
1811  const XalanDOMChar* theLHS,
1812  XalanDOMString::size_type theLHSLength,
1813  const XalanDOMChar* theRHS,
1814  XalanDOMString::size_type theRHSLength)
1815 {
1816  return theLHSLength != theRHSLength ? false : equals(theLHS, theRHS, theLHSLength);
1817 }
1818 
1819 
1820 
1828 inline bool
1830  const XalanDOMChar* theLHS,
1831  const XalanDOMChar* theRHS)
1832 {
1833  const XalanDOMString::size_type theLHSLength = length(theLHS);
1834 
1835  return theLHSLength != length(theRHS) ? false : equals(theLHS, theRHS, theLHSLength);
1836 }
1837 
1838 
1839 
1847 inline bool
1849  const XalanDOMString& theLHS,
1850  const XalanDOMString& theRHS)
1851 {
1852  return theLHS == theRHS;
1853 }
1854 
1855 
1856 
1864 inline bool
1866  const XalanDOMChar* theLHS,
1867  const XalanDOMString& theRHS)
1868 {
1869  assert(theLHS != 0);
1870 
1871  // Swap them...
1872  return theRHS == theLHS;
1873 }
1874 
1875 
1876 
1884 inline bool
1885 equals(const XalanDOMString& theLHS,
1886  const XalanDOMChar* theRHS)
1887 {
1888  return equals(theRHS, theLHS);
1889 }
1890 
1891 
1892 
1901 inline bool
1903  const XalanDOMString& theLHS,
1904  const XalanDOMChar* theRHS,
1905  XalanDOMString::size_type theRHSLength)
1906 {
1907  return theRHSLength != length(theLHS) ? false : equals(c_wstr(theLHS), theRHSLength, theRHS, theRHSLength);
1908 }
1909 
1910 
1911 
1912 
1923  const XalanDOMChar* theLHS,
1924  const XalanDOMChar* theRHS,
1925  XalanDOMString::size_type theLength);
1926 
1927 
1928 
1939 inline bool
1941  const XalanDOMChar* theLHS,
1942  XalanDOMString::size_type theLHSLength,
1943  const XalanDOMChar* theRHS,
1944  XalanDOMString::size_type theRHSLength)
1945 {
1946  return theLHSLength != theRHSLength ? false :
1947  equalsIgnoreCaseASCII(theLHS, theRHS, theLHSLength);
1948 }
1949 
1950 
1951 
1960 inline bool
1962  const XalanDOMChar* theLHS,
1963  const XalanDOMChar* theRHS)
1964 {
1965  const XalanDOMString::size_type theLength = length(theLHS);
1966 
1967  return theLength != length(theRHS) ? false :
1968  equalsIgnoreCaseASCII(theLHS, theRHS, theLength);
1969 }
1970 
1971 
1972 
1981 inline bool
1983  const XalanDOMString& theLHS,
1984  const XalanDOMString& theRHS)
1985 {
1986  const XalanDOMString::size_type theLength = length(theLHS);
1987 
1988  return theLength != length(theRHS) ? false :
1989  equalsIgnoreCaseASCII(toCharArray(theLHS), toCharArray(theRHS), theLength);
1990 }
1991 
1992 
1993 
2002 inline bool
2004  const XalanDOMChar* theLHS,
2005  const XalanDOMString& theRHS)
2006 {
2007  const XalanDOMString::size_type theRHSLength = length(theRHS);
2008 
2009  return theRHSLength != length(theLHS) ? false :
2010  equalsIgnoreCaseASCII(theLHS, toCharArray(theRHS), theRHSLength);
2011 }
2012 
2013 
2014 
2023 inline bool
2025  const XalanDOMString& theLHS,
2026  const XalanDOMChar* theRHS)
2027 {
2028  return equalsIgnoreCaseASCII(theRHS, theLHS);
2029 }
2030 
2031 
2032 
2042 inline bool
2044  const CharVectorType& theLHS,
2045  const CharVectorType& theRHS)
2046 {
2047  return compare(theLHS, theRHS) < 0 ? true : false;
2048 }
2049 
2050 
2051 
2061 inline bool
2063  const XalanDOMString& theLHS,
2064  const XalanDOMString& theRHS)
2065 {
2066  return compare(theLHS, theRHS) < 0 ? true : false;
2067 }
2068 
2069 
2070 
2079 inline XalanDOMString&
2081  XalanDOMString& theString,
2082  const XalanDOMString& theStringToAssign)
2083 {
2084  theString = theStringToAssign;
2085 
2086  return theString;
2087 }
2088 
2089 
2090 
2099 inline XalanDOMString&
2101  XalanDOMString& theString,
2102  const XalanDOMChar* theStringToAssign,
2103  XalanDOMString::size_type theStringToAssignLength = XalanDOMString::npos)
2104 {
2105  if (theStringToAssignLength == XalanDOMString::npos)
2106  {
2107  theString.assign(theStringToAssign);
2108  }
2109  else
2110  {
2111  theString.assign(theStringToAssign, theStringToAssignLength);
2112  }
2113 
2114  return theString;
2115 }
2116 
2117 
2118 
2126 inline XalanDOMString&
2128  XalanDOMString& theString,
2129  const XalanDOMString& theStringToAppend)
2130 {
2131  theString.append(theStringToAppend);
2132 
2133  return theString;
2134 }
2135 
2136 
2137 
2146 inline XalanDOMString&
2148  XalanDOMString& theString,
2149  const XalanDOMChar* theStringToAppend,
2150  XalanDOMString::size_type theStringToAppendLength = XalanDOMString::npos)
2151 {
2152  assert(theStringToAppend != 0);
2153 
2154  if (theStringToAppendLength == XalanDOMString::npos)
2155  {
2156  theString.append(theStringToAppend);
2157  }
2158  else
2159  {
2160  theString.append(theStringToAppend, theStringToAppendLength);
2161  }
2162 
2163  return theString;
2164 }
2165 
2166 
2167 
2176 inline XalanDOMString&
2178  XalanDOMString& theString,
2179  const char* theStringToAppend,
2180  XalanDOMString::size_type theStringToAppendLength = XalanDOMString::npos)
2181 {
2182  XalanDOMString tmp(theString.getMemoryManager());
2183 
2184  TranscodeFromLocalCodePage(theStringToAppend, tmp, theStringToAppendLength);
2185 
2186  theString.append(tmp);
2187 
2188  return theString;
2189 }
2190 
2191 
2192 
2200 inline XalanDOMString&
2202  XalanDOMString& theString,
2203  const XalanDOMChar theCharToAppend)
2204 {
2205  theString.append(1, theCharToAppend);
2206 
2207  return theString;
2208 }
2209 
2210 
2211 
2219 inline XalanDOMString&
2221  XalanDOMString& theString,
2222  char theCharToAppend)
2223 {
2224  // We have to transcode before appending...
2225  char theTempBuffer[] = { theCharToAppend, '\0' };
2226 
2227  return append(theString, theTempBuffer);
2228 }
2229 
2230 
2231 
2240 inline XalanDOMString&
2242  XalanDOMString& theString,
2243  XalanDOMString::size_type thePosition,
2244  const XalanDOMString& theStringToInsert)
2245 {
2246  theString.insert(thePosition, theStringToInsert);
2247 
2248  return theString;
2249 }
2250 
2251 
2252 
2261 inline XalanDOMString&
2263  XalanDOMString& theString,
2264  XalanDOMString::size_type thePosition,
2265  const XalanDOMChar* theStringToInsert)
2266 {
2267  theString.insert(thePosition, theStringToInsert);
2268 
2269  return theString;
2270 }
2271 
2272 
2273 
2281 trim(const XalanDOMString& theString, XalanDOMString& theResult);
2282 
2283 
2284 
2290 inline void
2292 {
2293  theString.clear();
2294 }
2295 
2296 
2297 
2303 inline void
2305 {
2306  theString.erase();
2307 }
2308 
2309 
2310 
2317 inline void
2319 {
2320  XalanDOMString(theManager).swap(theString);
2321 }
2322 
2323 
2324 
2327  const XalanDOMChar* theString,
2328  CharVectorType& theVector);
2329 
2330 
2331 
2334  const char* theString,
2335  CharVectorType& theVector);
2336 
2337 
2338 
2349  const char* data,
2350  XalanDOMCharVectorType& result,
2351  bool fTranscode = true);
2352 
2353 
2354 
2363 MakeXalanDOMCharVector(const XalanDOMChar* data,
2364  XalanDOMCharVectorType& result);
2365 
2366 
2367 
2375 inline XalanDOMCharVectorType&
2377  XalanDOMCharVectorType& result)
2378 {
2379  return MakeXalanDOMCharVector(c_wstr(data),result);
2380 }
2381 
2382 
2383 
2384 #if defined(XALAN_NO_STD_NAMESPACE)
2385 struct c_wstr_functor : public unary_function<XalanDOMString, const XalanDOMChar*>
2386 #else
2387 struct c_wstr_functor : public std::unary_function<XalanDOMString, const XalanDOMChar*>
2388 #endif
2389 {
2390  result_type
2391  operator() (const argument_type& theString) const
2392  {
2393  return c_wstr(theString);
2394  }
2395 };
2396 
2397 
2398 
2405 struct DOMStringHashFunction : public XALAN_STD_QUALIFIER unary_function<const XalanDOMString&, size_t>
2406 {
2407  result_type
2408  operator() (argument_type theKey) const
2409  {
2410  const XalanDOMChar* theRawBuffer = c_wstr(theKey);
2411 
2413 
2414  return hasher(theRawBuffer);
2415  }
2416 };
2417 
2418 
2419 
2420 template<>
2422 {
2424  typedef XALAN_STD_QUALIFIER equal_to<XalanDOMString> Comparator;
2425 };
2426 
2427 
2428 
2435 struct DOMStringPointerHashFunction : public XALAN_STD_QUALIFIER unary_function<const XalanDOMString*, size_t>
2436 {
2437  result_type
2438  operator() (argument_type theKey) const
2439  {
2440  assert (theKey != 0);
2441  return DOMStringHashFunction()(*theKey);
2442  }
2443 };
2444 
2445 
2446 
2447 template<>
2449 {
2452 };
2453 
2454 template<>
2456 {
2459 };
2460 
2461 
2469 #if defined(XALAN_NO_STD_NAMESPACE)
2470 struct DOMStringEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2471 #else
2472 struct DOMStringEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2473 #endif
2474 {
2475  result_type
2476  operator() (first_argument_type theLHS,
2477  second_argument_type theRHS) const
2478  {
2479  return equals(theLHS, theRHS);
2480  }
2481 };
2482 
2483 
2484 
2492 #if defined(XALAN_NO_STD_NAMESPACE)
2493 struct DOMStringNotEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2494 #else
2495 struct DOMStringNotEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2496 #endif
2497 {
2498  result_type
2499  operator() (first_argument_type theLHS,
2500  second_argument_type theRHS) const
2501  {
2502  return !equals(theLHS, theRHS);
2503  }
2504 };
2505 
2506 
2507 
2515 #if defined(XALAN_NO_STD_NAMESPACE)
2516 struct DOMStringLessThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2517 #else
2518 struct DOMStringLessThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2519 #endif
2520 {
2521  result_type
2522  operator() (first_argument_type theLHS,
2523  second_argument_type theRHS) const
2524  {
2525  return compare(theLHS, theRHS) < 0 ? true : false;
2526  }
2527 };
2528 
2529 
2537 struct DOMStringPointerEqualToFunction : public XALAN_STD_QUALIFIER binary_function<const XalanDOMString*, const XalanDOMString*, bool>
2538 {
2539  result_type
2540  operator() (first_argument_type theLHS,
2541  second_argument_type theRHS) const
2542  {
2543  assert(theLHS != 0 && theRHS != 0);
2544 
2545  return compare(*theLHS, *theRHS) == 0 ? true : false;
2546  }
2547 };
2548 
2549 
2557 #if defined(XALAN_NO_STD_NAMESPACE)
2558 struct DOMStringPointerLessThanFunction : public binary_function<const XalanDOMString*, const XalanDOMString*, bool>
2559 #else
2560 struct DOMStringPointerLessThanFunction : public std::binary_function<const XalanDOMString*, const XalanDOMString*, bool>
2561 #endif
2562 {
2563  result_type
2564  operator() (first_argument_type theLHS,
2565  second_argument_type theRHS) const
2566  {
2567  assert(theLHS != 0 && theRHS != 0);
2568 
2569  return compare(*theLHS, *theRHS) < 0 ? true : false;
2570  }
2571 };
2572 
2573 
2574 
2582 #if defined(XALAN_NO_STD_NAMESPACE)
2583 struct DOMStringLessThanIgnoreCaseASCIIFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2584 #else
2585 struct DOMStringLessThanIgnoreCaseASCIIFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2586 #endif
2587 {
2588  result_type
2589  operator() (first_argument_type theLHS,
2590  second_argument_type theRHS) const
2591  {
2592  return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false;
2593  }
2594 };
2595 
2596 
2597 
2605 #if defined(XALAN_NO_STD_NAMESPACE)
2606 struct DOMStringLessThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2607 #else
2608 struct DOMStringLessThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2609 #endif
2610 {
2611  result_type
2612  operator() (first_argument_type theLHS,
2613  second_argument_type theRHS) const
2614  {
2615  return compare(theLHS, theRHS) <= 0 ? true : false;
2616  }
2617 };
2618 
2619 
2620 
2628 #if defined(XALAN_NO_STD_NAMESPACE)
2629 struct DOMStringGreaterThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2630 #else
2631 struct DOMStringGreaterThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2632 #endif
2633 {
2634  result_type
2635  operator() (first_argument_type theLHS,
2636  second_argument_type theRHS) const
2637  {
2638  return compare(theLHS, theRHS) > 0 ? true : false;
2639  }
2640 };
2641 
2642 
2643 
2651 #if defined(XALAN_NO_STD_NAMESPACE)
2652 struct DOMStringGreaterThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2653 #else
2654 struct DOMStringGreaterThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool>
2655 #endif
2656 {
2657  result_type
2658  operator() (first_argument_type theLHS,
2659  second_argument_type theRHS) const
2660  {
2661  return compare(theLHS, theRHS) >= 0 ? true : false;
2662  }
2663 };
2664 
2665 
2666 
2672 #if defined(XALAN_NO_STD_NAMESPACE)
2673 struct less_no_case_ascii_wide_string : public binary_function<const XalanDOMChar*, const XalanDOMChar*, bool>
2674 #else
2675 struct less_no_case_ascii_wide_string : public std::binary_function<const XalanDOMChar*, const XalanDOMChar*, bool>
2676 #endif
2677 {
2686  result_type
2688  first_argument_type theLHS,
2689  second_argument_type theRHS) const
2690  {
2691  return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false;
2692  }
2693 };
2694 
2695 
2696 
2704 isXMLWhitespace(const XalanDOMString& string);
2705 
2706 
2707 
2718  const XalanDOMChar ch[],
2719  XalanDOMString::size_type start,
2721 
2722 
2723 
2730 inline bool
2731 isXMLWhitespace(const XalanDOMChar* theString)
2732 {
2733  assert(theString != 0);
2734 
2735  return isXMLWhitespace(theString, 0, length(theString));
2736 }
2737 
2738 
2739 
2740 XALAN_CPP_NAMESPACE_END
2741 
2742 
2743 
2744 #endif // DOMSTRINGHELPER_HEADER_GUARD_1357924680

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo