Xalan-C++ API Reference  1.12.0
XalanDOMString.hpp
Go to the documentation of this file.
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(XALANDOMSTRING_HEADER_GUARD_1357924680)
19 #define XALANDOMSTRING_HEADER_GUARD_1357924680
20 
21 
22 
24 
25 
26 
27 #include <cassert>
28 
29 
30 
34 
35 
36 
38 
39 
40 
41 namespace XALAN_CPP_NAMESPACE {
42 
43 
44 
46 {
47 public:
48 
52 
53  typedef XalanDOMChar value_type;
54  typedef XalanDOMChar& reference;
55  typedef const XalanDOMChar& const_reference;
56 
57  typedef XalanSize_t size_type;
58 
60  typedef XalanDOMCharVectorType::const_iterator const_iterator;
63 
64  static const size_type npos;
65 
66  XalanDOMString(MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR);
67 
68  explicit
70  const char* theString,
71  MemoryManager& theManager XALAN_DEFAULT_MEMMGR,
72  size_type theCount = size_type(npos));
73 
75  const XalanDOMString& theSource,
76  MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR,
77  size_type theStartPosition = 0,
78  size_type theCount = size_type(npos));
79 
80  explicit
82  const XalanDOMChar* theString,
83  MemoryManager& theManager XALAN_DEFAULT_MEMMGR,
84  size_type theCount = size_type(npos));
85 
87  size_type theCount,
88  XalanDOMChar theChar,
89  MemoryManager& theManager XALAN_DEFAULT_MEMMGR);
90 
92  clone(MemoryManager& theManager);
93 
95  {
96  }
97 
99  operator=(const XalanDOMString& theRHS)
100  {
101  return assign(theRHS);
102  }
103 
105  operator=(const XalanDOMChar* theRHS)
106  {
107  return assign(theRHS);
108  }
109 
111  operator=(const char* theRHS)
112  {
113  return assign(theRHS);
114  }
115 
117  operator=(XalanDOMChar theRHS)
118  {
119  return assign(1, theRHS);
120  }
121 
122  iterator
124  {
125  invariants();
126 
127  return m_data.begin();
128  }
129 
130  const_iterator
131  begin() const
132  {
133  invariants();
134 
135  return m_data.begin();
136  }
137 
138  iterator
139  end()
140  {
141  invariants();
142 
143  return m_data.empty() == true ? m_data.end() : m_data.end() - 1;
144  }
145 
146  const_iterator
147  end() const
148  {
149  invariants();
150 
151  return m_data.empty() == true ? m_data.end() : m_data.end() - 1;
152  }
153 
154  reverse_iterator
156  {
157  invariants();
158 
159  reverse_iterator i = m_data.rbegin();
160 
161  if (m_data.empty() == false)
162  {
163  ++i;
164  }
165 
166  return i;
167  }
168 
169  const_reverse_iterator
170  rbegin() const
171  {
172  invariants();
173 
174  const_reverse_iterator i = m_data.rbegin();
175 
176  if (m_data.empty() == false)
177  {
178  ++i;
179  }
180 
181  return i;
182  }
183 
184  reverse_iterator
186  {
187  invariants();
188 
189  return m_data.rend();
190  }
191 
192  const_reverse_iterator
193  rend() const
194  {
195  invariants();
196 
197  return m_data.rend();
198  }
199 
200  size_type
201  size() const
202  {
203  invariants();
204 
205  return m_size;
206  }
207 
208  size_type
209  length() const
210  {
211  invariants();
212 
213  return size();
214  }
215 
216  size_type
217  max_size() const
218  {
219  invariants();
220 
221  return ~size_type(0);
222  }
223 
224  void
225  resize(
226  size_type theCount,
227  XalanDOMChar theChar);
228 
229  void
230  resize(size_type theCount)
231  {
232  invariants();
233 
234  resize(theCount, XalanDOMChar(0));
235  }
236 
237  size_type
238  capacity() const
239  {
240  invariants();
241 
242  const XalanDOMCharVectorType::size_type theCapacity =
243  m_data.capacity();
244 
245  return theCapacity == 0 ? 0 : size_type(theCapacity - 1);
246  }
247 
248  void
249  reserve(size_type theCount = 0)
250  {
251  invariants();
252 
253  m_data.reserve(theCount + 1);
254  }
255 
256  void
258  {
259  invariants();
260 
261  m_data.erase(m_data.begin(), m_data.end());
262 
263  m_size = 0;
264 
265  invariants();
266  }
267 
268  iterator
269  erase(iterator thePosition)
270  {
271  invariants();
272 
273  m_data.erase(thePosition);
274 
275  --m_size;
276 
277  invariants();
278 
279  return thePosition;
280  }
281 
282  iterator
284  iterator theFirst,
285  iterator theLast)
286  {
287  invariants();
288 
289  m_data.erase(theFirst, theLast);
290 
291  m_size = m_data.size() - 1;
292 
293  invariants();
294 
295  return theFirst;
296  }
297 
299  erase(
300  size_type theStartPosition = 0,
301  size_type theCount = size_type(npos));
302 
303  bool
304  empty() const
305  {
306  invariants();
307 
308  return m_size == 0 ? true : false;
309  }
310 
311  const_reference
312  operator[](size_type theIndex) const
313  {
314  invariants();
315 
316  return m_data[theIndex];
317  }
318 
319  reference
321  {
322  invariants();
323 
324  return m_data[theIndex];
325  }
326 
327  const_reference
328  at(size_type theIndex) const
329  {
330  invariants();
331 
332  return m_data.at(theIndex);
333  }
334 
335  reference
336  at(size_type theIndex)
337  {
338  invariants();
339 
340  return m_data.at(theIndex);
341  }
342 
343  const XalanDOMChar*
344  c_str() const
345  {
346  invariants();
347 
348  return m_data.empty() == true ? &s_empty : &m_data[0];
349  }
350 
351  const XalanDOMChar*
352  data() const
353  {
354  invariants();
355 
356  return c_str();
357  }
358 
359  void
360  swap(XalanDOMString& theOther)
361  {
362  invariants();
363 
364  m_data.swap(theOther.m_data);
365 
366  std::swap(m_size, theOther.m_size);
367  }
368 
370  operator+=(const XalanDOMString& theSource)
371  {
372  return append(theSource);
373  }
374 
376  operator+=(const XalanDOMChar* theString)
377  {
378  return append(theString);
379  }
380 
382  operator+=(XalanDOMChar theChar)
383  {
384  append(1, theChar);
385 
386  return *this;
387  }
388 
390  assign(const XalanDOMChar* theSource)
391  {
392  invariants();
393 
394  erase();
395 
396  invariants();
397 
398  return append(theSource);
399  }
400 
403  const XalanDOMChar* theSource,
404  size_type theCount)
405  {
406  invariants();
407 
408  erase();
409 
410  invariants();
411 
412  return append(theSource, theCount);
413  }
414 
416  assign(const char* theSource)
417  {
418  invariants();
419 
420  erase();
421 
422  invariants();
423 
424  return append(theSource);
425  }
426 
429  const char* theSource,
430  size_type theCount)
431  {
432  invariants();
433 
434  erase();
435 
436  invariants();
437 
438  return append(theSource, theCount);
439  }
440 
442  assign(
443  const XalanDOMString& theSource,
444  size_type thePosition,
445  size_type theCount);
446 
448  assign(const XalanDOMString& theSource)
449  {
450  invariants();
451 
452  if (&theSource != this)
453  {
454  m_data = theSource.m_data;
455 
456  m_size = theSource.m_size;
457  }
458 
459  invariants();
460 
461  return *this;
462  }
463 
466  size_type theCount,
467  XalanDOMChar theChar)
468  {
469  invariants();
470 
471  erase();
472 
473  invariants();
474 
475  return append(theCount, theChar);
476  }
477 
479  assign(
480  iterator theFirstPosition,
481  iterator theLastPosition);
482 
484  append(const XalanDOMString& theSource)
485  {
486  return append(theSource.c_str(), theSource.length());
487  }
488 
491  const XalanDOMString& theSource,
492  size_type thePosition,
493  size_type theCount)
494  {
495  assert(thePosition < theSource.length() &&
496  (theCount == size_type(npos) || thePosition + theCount <= theSource.length()));
497 
498  return append(theSource.c_str() + thePosition, theCount);
499  }
500 
502  append(
503  const XalanDOMChar* theString,
504  size_type theCount);
505 
507  append(const XalanDOMChar* theString)
508  {
509  return append(theString, length(theString));
510  }
511 
513  append(
514  const char* theString,
515  size_type theCount);
516 
518  append(const char* theString)
519  {
520  return append(theString, length(theString));
521  }
522 
524  append(
525  size_type theCount,
526  XalanDOMChar theChar);
527 
528  void
529  push_back(XalanDOMChar theChar)
530  {
531  invariants();
532 
533  append(1, theChar);
534 
535  invariants();
536  }
537 
540  size_type thePosition,
541  const XalanDOMString& theString)
542  {
543  return insert(thePosition, theString.c_str(), theString.length());
544  }
545 
548  size_type thePosition1,
549  const XalanDOMString& theString,
550  size_type thePosition2,
551  size_type theCount)
552  {
553  return insert(thePosition1, theString.c_str() + thePosition2, theCount);
554  }
555 
557  insert(
558  size_type thePosition,
559  const XalanDOMChar* theString,
560  size_type theCount);
561 
564  size_type thePosition,
565  const XalanDOMChar* theString)
566  {
567  return insert(thePosition, theString, length(theString));
568  }
569 
571  insert(
572  size_type thePosition,
573  size_type theCount,
574  XalanDOMChar theChar);
575 
576  iterator
577  insert(
578  iterator thePosition,
579  XalanDOMChar theChar);
580 
581  void
582  insert(
583  iterator thePosition,
584  size_type theCount,
585  XalanDOMChar theChar);
586 
587  void
588  insert(
589  iterator theInsertPosition,
590  iterator theFirstPosition,
591  iterator theLastPosition);
592 
593 
596  XalanDOMString& theSubstring,
597  size_type thePosition = 0,
598  size_type theCount = size_type(npos)) const
599  {
600  assert((theCount == size_type(npos) && thePosition < length() ) ||
601  (thePosition + theCount <= length()));
602 
603  invariants();
604 
605  return theSubstring.assign(
606  *this,
607  thePosition,
608  theCount == npos ? length() : theCount);
609  }
610 
611  int
612  compare(const XalanDOMString& theString) const
613  {
614  invariants();
615 
616  return compare(theString.c_str());
617  }
618 
619  int
621  size_type thePosition1,
622  size_type theCount1,
623  const XalanDOMString& theString) const
624  {
625  invariants();
626 
627  return compare(thePosition1, theCount1, theString.c_str(), theString.length());
628  }
629 
630  int
632  size_type thePosition1,
633  size_type theCount1,
634  const XalanDOMString& theString,
635  size_type thePosition2,
636  size_type theCount2) const
637  {
638  invariants();
639 
640  return compare(thePosition1, theCount1, theString.c_str() + thePosition2, theCount2);
641  }
642 
643  int
644  compare(const XalanDOMChar* theString) const;
645 
646  int
647  compare(
648  size_type thePosition1,
649  size_type theCount1,
650  const XalanDOMChar* theString,
651  size_type theCount2 = size_type(npos)) const;
652 
653 
654  void
655  reset(MemoryManager& theManager, const char* theString);
656 
657  void
658  reset(MemoryManager& theManager, const XalanDOMChar* theString);
659 
661  {
662  public:
663 
665  XalanDOMException(TRANSCODING_ERR)
666  {
667  }
668 
669  virtual
671  {
672  }
673  };
674 
675 
676 
677  /**
678  * Transcode the string to the local code page. If the string
679  * cannot be properly transcoded, and the transcoder can detect
680  * the error a TranscodingError exception is thrown.
681  *
682  * @param theResult A CharVectorType instance for the transcoded string. The string is null-terminated.
683  */
684  void
685  transcode(CharVectorType& theResult) const;
686 
687  MemoryManager&
689  {
690  return m_data.getMemoryManager();
691  }
692 
693  size_t
694  hash() const
695  {
696  return hash(c_str(), length());
697  }
698 
699  static size_t
701  const XalanDOMChar* theString,
702  size_type theLength)
703  {
704  assert(theString != 0);
705 
706  return hash_non_terminated_array<XalanDOMChar>()(theString, theLength);
707  }
708 
709  static bool
710  equals(
711  const XalanDOMChar* theLHS,
712  size_type theLHSLength,
713  const XalanDOMChar* theRHS,
714  size_type theRHSLength);
715 
716  static bool
718  const XalanDOMChar* theLHS,
719  const XalanDOMChar* theRHS)
720  {
721  return equals(theLHS, length(theLHS), theRHS, length(theRHS));
722  }
723 
724  static bool
725  equals(
726  const XalanDOMString& theLHS,
727  const XalanDOMString& theRHS);
728 
729  static bool
731  const XalanDOMString& theLHS,
732  const XalanDOMChar* theRHS)
733  {
734  return equals(theLHS.c_str(), theRHS);
735  }
736 
737  static bool
739  const XalanDOMChar* theLHS,
740  const XalanDOMString& theRHS)
741  {
742  return equals(theLHS, theRHS.c_str());
743  }
744 
745  /*
746  * Helper function to determine the length of a null-
747  * terminated string.
748  *
749  * @theString The string
750  * @return the length
751  */
752  static size_type
753  length(const XalanDOMChar* theString);
754 
755  /*
756  * Helper function to determine the length of a null-
757  * terminated string.
758  *
759  * @theString The string
760  * @return the length
761  */
762  static size_type
763  length(const char* theString);
764 
765 protected:
766 
767  /*
768  * Function to assert invariant conditions for the class.
769  *
770  * @return the iterator
771  */
772  void
773  invariants() const
774  {
775 #if !defined(NDEBUG)
776  assert((m_data.empty() == true && m_size == 0) || m_size == m_data.size() - 1);
777  assert(m_data.empty() == true || m_data.back() == 0);
778 #endif
779  }
780 
781  /*
782  * Get an iterator to the position of the terminating null.
783  *
784  * @return the iterator
785  */
786  iterator
788  {
789  invariants();
790 
791  return m_data.empty() == true ? m_data.end() : m_data.end() - 1;
792  }
793 
794  const_iterator
796  {
797  invariants();
798 
799  return m_data.empty() == true ? m_data.end() : m_data.end() - 1;
800  }
801 
802  iterator
804  {
805  invariants();
806 
807  return m_data.begin() + thePosition;
808  }
809 
810  const_iterator
812  {
813  invariants();
814 
815  return m_data.begin() + thePosition;
816  }
817 
818 #if defined (XALAN_DEVELOPMENT)
819  // not defined
820  XalanDOMString();
822 #endif
823 
824 private:
825 
826 
827  XalanDOMCharVectorType m_data;
828 
829  size_type m_size;
830 
831  static const XalanDOMChar s_empty;
832 };
833 
834 
835 
836 /**
837  * Hash functor for DOMStrings
838  *
839  * @param theKey XalanDOMString to be hashed
840  * @return hash value for XalanDOMString
841  */
843 {
844  size_t
845  operator() (const XalanDOMString& theKey) const
846  {
847  return theKey.hash();
848  }
849 };
850 
851 
852 
853 /**
854  * Hash functor for DOMStrings
855  *
856  * @param theKey XalanDOMString to be hashed
857  * @return hash value for XalanDOMString
858  */
860 {
861  size_t
862  operator() (const XalanDOMString* theKey) const
863  {
864  assert (theKey != 0);
865 
866  return theKey->hash();
867  }
868 };
869 
870 
871 
872 template<>
874 {
877 };
878 
879 template<>
881 {
884 };
885 
886 
887 /**
888  * Equals functor for DOMStrings
889  *
890  * @param theLHS first string to compare
891  * @param theRHS second string to compare
892  * @return true if the contents of both strings are identical
893  */
895 {
896  bool
897  operator() (const XalanDOMString& theLHS,
898  const XalanDOMString& theRHS) const
899  {
900  return XalanDOMString::equals(theLHS, theRHS);
901  }
902 };
903 
904 
905 
906 /**
907  * Not equals functor for DOMStrings
908  *
909  * @param theLHS first string to compare
910  * @param theRHS second string to compare
911  * @return true if the contents of both strings are identical
912  */
914 {
915  bool
916  operator() (const XalanDOMString& theLHS,
917  const XalanDOMString& theRHS) const
918  {
919  return !XalanDOMString::equals(theLHS, theRHS);
920  }
921 };
922 
923 
924 
925 /**
926  * Less than functor for DOMStrings
927  *
928  * @param theLHS first string to compare
929  * @param theRHS second string to compare
930  * @return true if the theLHS is less than theRHSl
931  */
933 {
934  bool
935  operator() (const XalanDOMString& theLHS,
936  const XalanDOMString& theRHS) const
937  {
938  return theLHS.compare(theRHS) < 0 ? true : false;
939  }
940 };
941 
942 
943 /**
944  * Equal to functor for DOMStrings
945  *
946  * @param theLHS first string to compare
947  * @param theRHS second string to compare
948  * @return true if the theLHS is equal to theRHS
949  */
951 {
952  bool
953  operator() (const XalanDOMString* theLHS,
954  const XalanDOMString* theRHS) const
955  {
956  assert(theLHS != 0 && theRHS != 0);
957 
958  return XalanDOMString::equals(*theLHS, *theRHS);
959  }
960 };
961 
962 
963 /**
964  * Less than functor for DOMStrings
965  *
966  * @param theLHS first string to compare
967  * @param theRHS second string to compare
968  * @return true if the theLHS is less than theRHSl
969  */
971 {
972  bool
973  operator() (const XalanDOMString* theLHS,
974  const XalanDOMString* theRHS) const
975  {
976  assert(theLHS != 0 && theRHS != 0);
977 
978  return theLHS->compare(*theRHS) < 0 ? true : false;
979  }
980 };
981 
982 
983 
984 template<>
986 {
988  typedef std::equal_to<XalanDOMString> Comparator;
989 };
990 
991 
992 
993 inline bool
995  const XalanDOMString& theLHS,
996  const XalanDOMString& theRHS)
997 {
998  return XalanDOMString::equals(theLHS, theRHS);
999 }
1000 
1001 
1002 
1003 inline bool
1005  const XalanDOMString& theLHS,
1006  const XalanDOMChar* theRHS)
1007 {
1008  return XalanDOMString::equals(theLHS, theRHS);
1009 }
1010 
1011 
1012 
1013 inline bool
1015  const XalanDOMChar* theLHS,
1016  const XalanDOMString& theRHS)
1017 {
1018  // Note reversing of operands...
1019  return XalanDOMString::equals(theLHS, theRHS);
1020 }
1021 
1022 
1023 
1024 inline bool
1026  const XalanDOMString& theLHS,
1027  const XalanDOMString& theRHS)
1028 {
1029  return !(theLHS == theRHS);
1030 }
1031 
1032 
1033 
1034 inline bool
1036  const XalanDOMChar* theLHS,
1037  const XalanDOMString& theRHS)
1038 {
1039  return !(theLHS == theRHS);
1040 }
1041 
1042 
1043 
1044 inline bool
1046  const XalanDOMString& theLHS,
1047  const XalanDOMChar* theRHS)
1048 {
1049  return !(theRHS == theLHS);
1050 }
1051 
1052 
1053 #if 0
1054 inline XalanDOMString&
1055 add(
1056  const XalanDOMString& theLHS,
1057  const XalanDOMString& theRHS,
1058  XalanDOMString& result)
1059 {
1060  result.assign(theLHS);
1061 
1062  return result += theRHS;
1063 }
1064 
1065 
1066 
1067 inline XalanDOMString&
1068 add(
1069  const XalanDOMString& theLHS,
1070  const XalanDOMChar* theRHS,
1071  XalanDOMString& result)
1072 {
1073  result.assign(theLHS);
1074 
1075  return result += theRHS;
1076 }
1077 
1078 
1079 
1080 inline XalanDOMString&
1081 add(
1082  const XalanDOMChar* theLHS,
1083  const XalanDOMString& theRHS,
1084  XalanDOMString& result)
1085 {
1086  result.assign(theLHS);
1087 
1088  return result += theRHS;
1089 }
1090 
1091 
1092 
1093 inline const XalanDOMString&
1094 add(
1095  const char* theLHS,
1096  const XalanDOMString& theRHS,
1097  XalanDOMString& result)
1098 {
1099  result.assign(theLHS);
1100 
1101  result.append(theRHS);
1102 
1103  return result;
1104 }
1105 
1106 
1107 
1108 inline const XalanDOMString&
1109 add(
1110  const XalanDOMString& theLHS,
1111  const char* theRHS,
1112  XalanDOMString& result)
1113 {
1114  result.assign(theLHS);
1115 
1116  result.append(theRHS);
1117 
1118  return result;
1119 }
1120 #endif
1121 
1122 
1123 // Standard vector of XalanDOMChars and chars
1125 
1127 
1128 
1129 
1130 
1131 
1132 /**
1133  * Convert a XalanDOMChar string to C++ standard library
1134  * vector, transcoding to the default local code
1135  * page.
1136  *
1137  * @param sourceString The source string
1138  * @param sourceStringLength The source string length.
1139  * @param targetVector The target string
1140  * @param terminate If true, the transcoded string will be null-terminated
1141  * @return true if successful, false if not.
1142  */
1145  const XalanDOMChar* theSourceString,
1146  XalanDOMString::size_type theSourceStringLength,
1147  CharVectorType& targetVector,
1148  bool terminate = false);
1149 
1150 /**
1151  * Convert a XalanDOMChar string to C++ standard library
1152  * vector, transcoding to the default local code
1153  * page. If the source string contines code points, that can't be
1154  * represented in the local code page, the substitution character will be used
1155  *
1156  * @param sourceString The source string
1157  * @param sourceStringLength The source string length.
1158  * @param targetVector The target string
1159  * @param terminate If true, the transcoded string will be null-terminated
1160  * @param theSubstitutionChar The substitution character for code points that are not presentable
1161  * in the local page
1162  */
1165  const XalanDOMChar* theSourceString,
1166  XalanDOMString::size_type theSourceStringLength,
1167  CharVectorType& targetVector,
1168  bool terminate,
1169  char theSubstitutionChar);
1170 
1171 /**
1172  * Convert a string to a XalanDOMString, transcoding from
1173  * the default local code page.
1174  *
1175  * @param theSourceString The source string
1176  * @param theSourceStringLength The source string length.
1177  * @return The new string.
1178  */
1179 #if !defined(XALAN_DEVELOPMENT)
1180 inline const XalanDOMString
1182  const char* theSourceString,
1183  XalanDOMString::size_type theSourceStringLength = XalanDOMString::npos)
1184 {
1185  return XalanDOMString(theSourceString,XalanMemMgrs::getDefaultXercesMemMgr(), theSourceStringLength);
1186 }
1187 #endif
1188 
1189 
1190 /**
1191  * Convert a XalanDOMChar string to C++ standard library
1192  * vector, transcoding to the default local code
1193  * page. The string _must_ be null-terminated.
1194  *
1195  * @param theSourceString The source string
1196  * @param targetVector The target string
1197  * @param terminate If true, the transcoded string will be null-terminated
1198  * @return true if successful, false if not.
1199  */
1202  const XalanDOMChar* theSourceString,
1203  CharVectorType& targetVector,
1204  bool terminate = false);
1205 
1206 /**
1207  * Convert a XalanDOMChar string to C++ standard library
1208  * vector, transcoding to the default local code
1209  * page. The string _must_ be null-terminated.
1210  *
1211  * @param theSourceString The source string
1212  * @param targetVector The target string
1213  * @param terminate If true, the transcoded string will be null-terminated
1214  */
1217  const XalanDOMChar* theSourceString,
1218  CharVectorType& targetVector,
1219  bool terminate,
1220  char theSubstitutionChar);
1221 
1222 /**
1223  * Convert XalanDOMString to C++ standard library
1224  * vector, transcoding to the default local code
1225  * page. Null-terminate the sttring...
1226  *
1227  * @param theSourceString source string
1228  * @return The transcoded string.
1229  */
1230 #if !defined(XALAN_DEVELOPMENT)
1231 inline const CharVectorType
1232 TranscodeToLocalCodePage(const XalanDOMChar* theSourceString)
1233 {
1234  CharVectorType theResult;
1235 
1236  TranscodeToLocalCodePage(theSourceString, theResult, true, '?');
1237 
1238  return theResult;
1239 }
1240 #endif
1241 
1242 
1243 /**
1244  * Convert XalanDOMString to C++ standard library
1245  * vector, transcoding to the default local code
1246  * page.
1247  *
1248  * @param theSourceString The source string
1249  * @param theTargetVector The target string
1250  * @return true if successful, false if not.
1251  */
1252 inline bool
1254  const XalanDOMString& theSourceString,
1255  CharVectorType& theTargetVector,
1256  bool terminate = false)
1257 {
1258  return TranscodeToLocalCodePage(
1259  theSourceString.c_str(),
1260  theTargetVector,
1261  terminate);
1262 }
1263 
1264 /**
1265  * Convert XalanDOMString to C++ standard library
1266  * vector, transcoding to the default local code
1267  * page.
1268  *
1269  * @param theSourceString The source string
1270  * @param targetVector The target string
1271  * @param terminate If true, the transcoded string will be null-terminated
1272  * @param theSubstitutionChar The substitution character for code points that are not presentable
1273  * in the local page
1274  */
1277  const XalanDOMString& theSourceString,
1278  CharVectorType& theTargetVector,
1279  bool terminate,
1280  char theSubstitutionChar);
1281 
1282 
1283 
1284 /**
1285  * Convert XalanDOMString to C++ standard library
1286  * vector, transcoding to the default local code
1287  * page.
1288  *
1289  * @param thetheSourceString source string
1290  * @return The transcoded string.
1291  */
1292 #if !defined(XALAN_DEVELOPMENT)
1293 inline const CharVectorType
1295 {
1296  CharVectorType theResult;
1297 
1298  TranscodeToLocalCodePage(theSourceString.c_str(), theResult, true, '?');
1299 
1300  return theResult;
1301 }
1302 #endif
1303 
1304 
1305 /**
1306  * Convert a string to a XalanDOMString, transcoding from
1307  * the default local code page.
1308  *
1309  * @param theSourceString The source string
1310  * @param theResult The result.
1311  * @param theSourceStringLength The source string length.
1312  * @return The new string.
1313  */
1314 inline const XalanDOMString&
1316  const char* theSourceString,
1317  XalanDOMString& theResult,
1318  XalanDOMString::size_type theSourceStringLength = XalanDOMString::npos)
1319 {
1320  theResult.assign(theSourceString, theSourceStringLength);
1321 
1322  return theResult;
1323 }
1324 
1325 
1326 
1327 /**
1328  * Convert a string to a C++ standard library
1329  * vector, transcoding from the default local code
1330  * page.
1331  *
1332  * @param theSourceString The source string
1333  * @param theSourceStringLength The source string length.
1334  * @param targetVector The target string
1335  * @param terminate If true, the transcoded string will be null-terminated
1336  * @return true if successful, false if not.
1337  */
1340  const char* theSourceString,
1341  XalanDOMString::size_type theSourceStringLength,
1342  XalanDOMCharVectorType& theTargetVector,
1343  bool terminate = false);
1344 
1345 /**
1346  * Convert a string to a C++ standard library
1347  * vector, transcoding from the default local code
1348  * page. The string _must_ be null-terminated.
1349  *
1350  * @param sourceString The source string
1351  * @param targetVector The target string
1352  * @param terminate If true, the transcoded string will be null-terminated
1353  * @return true if successful, false if not.
1354  */
1357  const char* theSourceString,
1358  XalanDOMCharVectorType& theTargetVector,
1359  bool terminate = false);
1360 
1361 /**
1362  * Convert a string to a C++ standard library
1363  * vector, transcoding from the default local code
1364  * page.
1365  *
1366  * @param theSourceString The source string
1367  * @param theSourceStringLength The source string length.
1368  * @param theSourceStringIsNullTerminated true if the source string is null-terminated, otherwise false.
1369  * @param targetVector The target string
1370  * @param terminate If true, the transcoded string will be null-terminated
1371  * @return true if successful, false if not.
1372  */
1375  const char* theSourceString,
1376  XalanDOMString::size_type theSourceStringLength,
1377  bool theSourceStringIsNullTerminated,
1378  XalanDOMCharVectorType& theTargetVector,
1379  bool terminate = false);
1380 
1381 /**
1382  * Convert a vector of characters to a XalanDOMString,
1383  * transcoding from the default local code
1384  *
1385  * @param theSourceString The source vector.
1386  * @param theResult The result.
1387  * @return The transcoded string.
1388  */
1389 XALAN_DOM_EXPORT_FUNCTION(const XalanDOMString&)
1391  const CharVectorType& theSourceString,
1392  XalanDOMString& theResult);
1393 
1394 
1395 XALAN_USES_MEMORY_MANAGER(XalanDOMString)
1396 
1397 
1398 
1399 }
1400 
1401 
1402 
1403 #endif // !defined(XALANDOMSTRING_HEADER_GUARD_1357924680)
xalanc::XalanMapKeyTraits< const XalanDOMString * >::Hasher
DOMStringPointerHashFunction Hasher
Definition: XalanDOMString.hpp:882
xalanc::XalanDOMString::insert
XalanDOMString & insert(size_type thePosition1, const XalanDOMString &theString, size_type thePosition2, size_type theCount)
Definition: XalanDOMString.hpp:547
xalanc::XalanDOMString::getBackInsertIterator
const_iterator getBackInsertIterator() const
Definition: XalanDOMString.hpp:795
xalanc::XalanDOMString::rbegin
reverse_iterator rbegin()
Definition: XalanDOMString.hpp:155
xalanc::XalanDOMString::operator=
XalanDOMString & operator=(const XalanDOMChar *theRHS)
Definition: XalanDOMString.hpp:105
xalanc::DOMStringEqualsFunction
Equals functor for DOMStrings.
Definition: XalanDOMString.hpp:894
xalanc::XalanDOMString::erase
iterator erase(iterator theFirst, iterator theLast)
Definition: XalanDOMString.hpp:283
xalanc::XalanDOMString::getMemoryManager
MemoryManager & getMemoryManager()
Definition: XalanDOMString.hpp:688
xalanc::XalanDOMString::assign
XalanDOMString & assign(const XalanDOMChar *theSource)
Definition: XalanDOMString.hpp:390
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::XalanDOMString::operator=
XalanDOMString & operator=(const XalanDOMString &theRHS)
Definition: XalanDOMString.hpp:99
xalanc::XalanMapKeyTraits< XalanDOMString * >::Comparator
pointer_equal< XalanDOMString > Comparator
Definition: XalanDOMString.hpp:876
xalanc::XalanDOMString::getIteratorForPosition
const_iterator getIteratorForPosition(size_type thePosition) const
Definition: XalanDOMString.hpp:811
xalanc::XalanDOMString::at
reference at(size_type theIndex)
Definition: XalanDOMString.hpp:336
xalanc::DOMStringPointerHashFunction
Hash functor for DOMStrings.
Definition: XalanDOMString.hpp:859
xalanc::XalanDOMString::hash
static size_t hash(const XalanDOMChar *theString, size_type theLength)
Definition: XalanDOMString.hpp:700
xalanc::XalanDOMString::append
XalanDOMString & append(const XalanDOMString &theSource, size_type thePosition, size_type theCount)
Definition: XalanDOMString.hpp:490
xalanc::hash_non_terminated_array
Definition: STLHelper.hpp:282
xalanc::XalanDOMString::getIteratorForPosition
iterator getIteratorForPosition(size_type thePosition)
Definition: XalanDOMString.hpp:803
xalanc::XalanDOMString::equals
static bool equals(const XalanDOMChar *theLHS, const XalanDOMString &theRHS)
Definition: XalanDOMString.hpp:738
xalanc::XalanDOMString::substr
XalanDOMString & substr(XalanDOMString &theSubstring, size_type thePosition=0, size_type theCount=size_type(npos)) const
Definition: XalanDOMString.hpp:595
xalanc::XalanDOMString::const_reverse_iterator
XalanDOMCharVectorType::const_reverse_iterator const_reverse_iterator
Definition: XalanDOMString.hpp:62
xalanc::XalanVector< XalanDOMChar >
XALAN_USES_MEMORY_MANAGER
#define XALAN_USES_MEMORY_MANAGER(Type)
Definition: XalanMemoryManagement.hpp:589
xalanc::TranscodeFromLocalCodePage
TranscodeFromLocalCodePage(const CharVectorType &theSourceString, XalanDOMString &theResult)
Convert a vector of characters to a XalanDOMString, transcoding from the default local code.
xalanc::swap
void swap(XalanVector< Type > &theLHS, XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1107
xalanc::XalanDOMString::assign
XalanDOMString & assign(const XalanDOMString &theSource)
Definition: XalanDOMString.hpp:448
xalanc::XalanDOMString::operator=
XalanDOMString & operator=(XalanDOMChar theRHS)
Definition: XalanDOMString.hpp:117
xalanc::size_type
size_t size_type
Definition: XalanMap.hpp:46
xalanc::XalanDOMString::TranscodingError::TranscodingError
TranscodingError()
Definition: XalanDOMString.hpp:664
xalanc::XalanDOMString::compare
int compare(const XalanDOMString &theString) const
Definition: XalanDOMString.hpp:612
xalanc::XalanDOMString::size
size_type size() const
Definition: XalanDOMString.hpp:201
xalanc::XalanDOMString::empty
bool empty() const
Definition: XalanDOMString.hpp:304
XALAN_DEFAULT_MEMMGR
#define XALAN_DEFAULT_MEMMGR
Definition: XalanMemoryManagement.hpp:516
xalanc::XalanDOMString::rbegin
const_reverse_iterator rbegin() const
Definition: XalanDOMString.hpp:170
xalanc::XalanDOMString::append
XalanDOMString & append(const XalanDOMString &theSource)
Definition: XalanDOMString.hpp:484
xalanc::XalanDOMString::compare
int compare(size_type thePosition1, size_type theCount1, const XalanDOMString &theString, size_type thePosition2, size_type theCount2) const
Definition: XalanDOMString.hpp:631
xalanc::assign
XalanDOMString & assign(XalanDOMString &theString, const XalanDOMString &theStringToAssign)
Assign one string to another.
Definition: DOMStringHelper.hpp:2243
xalanc::DOMStringPointerLessThanFunction
Less than functor for DOMStrings.
Definition: XalanDOMString.hpp:970
xalanc::XalanDOMString::assign
XalanDOMString & assign(const char *theSource)
Definition: XalanDOMString.hpp:416
XalanVector.hpp
xalanc::equals
equals(const XalanDOMChar *theLHS, const XalanDOMChar *theRHS, XalanDOMString::size_type theLength)
Compare the contents of two arrays for equality.
XALAN_DOM_EXPORT_FUNCTION
#define XALAN_DOM_EXPORT_FUNCTION(T)
Definition: XalanDOMDefinitions.hpp:39
xalanc::TranscodeToLocalCodePage
const CharVectorType TranscodeToLocalCodePage(const XalanDOMString &theSourceString)
Convert XalanDOMString to C++ standard library vector, transcoding to the default local code page.
Definition: XalanDOMString.hpp:1294
xalanc::XalanDOMString::operator+=
XalanDOMString & operator+=(const XalanDOMString &theSource)
Definition: XalanDOMString.hpp:370
xalanc::XalanDOMString::XalanDOMCharVectorType
XalanVector< XalanDOMChar > XalanDOMCharVectorType
Definition: XalanDOMString.hpp:49
xalanc::XalanDOMString::invariants
void invariants() const
Definition: XalanDOMString.hpp:773
xalanc::XalanMapKeyTraits< XalanDOMString >::Hasher
DOMStringHashFunction Hasher
Definition: XalanDOMString.hpp:987
STLHelper.hpp
xalanc::XalanDOMString::operator+=
XalanDOMString & operator+=(XalanDOMChar theChar)
Definition: XalanDOMString.hpp:382
xalanc::XalanDOMString::npos
static const size_type npos
Definition: XalanDOMString.hpp:64
xalanc::operator!=
bool operator!=(const XalanDOMString &theLHS, const XalanDOMChar *theRHS)
Definition: XalanDOMString.hpp:1045
xalanc::XalanDOMCharVectorType
XalanVector< XalanDOMChar > XalanDOMCharVectorType
Definition: XalanDOMString.hpp:1124
xalanc::XalanDOMString::~XalanDOMString
~XalanDOMString()
Definition: XalanDOMString.hpp:94
xalanc::XalanVector< XalanDOMChar >::const_reverse_iterator
const_reverse_iterator_ const_reverse_iterator
Definition: XalanVector.hpp:78
xalanc::XalanMapKeyTraits< const XalanDOMString * >::Comparator
pointer_equal< XalanDOMString > Comparator
Definition: XalanDOMString.hpp:883
xalanc::XalanDOMException
Definition: XalanDOMException.hpp:39
xalanc::XalanDOMString::max_size
size_type max_size() const
Definition: XalanDOMString.hpp:217
xalanc::XalanDOMString::length
size_type length() const
Definition: XalanDOMString.hpp:209
xalanc::append
XalanDOMString & append(XalanDOMString &theString, const XalanDOMString &theStringToAppend)
Concatenate two strings.
Definition: DOMStringHelper.hpp:2294
xalanc::compare
compare(const CharVectorType &theLHS, const CharVectorType &theRHS)
Compare the contents of two strings.
xalanc::c_str
const char * c_str(const CharVectorType &theString)
Get the underlying representation of the target CharVectorType as a null-terminated string.
Definition: DOMStringHelper.hpp:114
xalanc::XalanDOMString::compare
int compare(size_type thePosition1, size_type theCount1, const XalanDOMString &theString) const
Definition: XalanDOMString.hpp:620
XalanMemoryManagement.hpp
xalanc::XalanDOMString::equals
static bool equals(const XalanDOMChar *theLHS, const XalanDOMChar *theRHS)
Definition: XalanDOMString.hpp:717
xalanc::XalanVector< XalanDOMChar >::iterator
value_type * iterator
Definition: XalanVector.hpp:71
xalanc::XalanDOMString::end
const_iterator end() const
Definition: XalanDOMString.hpp:147
xalanc::DOMStringPointerEqualToFunction
Equal to functor for DOMStrings.
Definition: XalanDOMString.hpp:950
xalanc::XalanMapKeyTraits< XalanDOMString >::Comparator
std::equal_to< XalanDOMString > Comparator
Definition: XalanDOMString.hpp:988
xalanc::length
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
Definition: DOMStringHelper.hpp:235
xalanc::XalanDOMString::swap
void swap(XalanDOMString &theOther)
Definition: XalanDOMString.hpp:360
xalanc::erase
void erase(XalanDOMString &theString)
Remove all elements from target string.
Definition: DOMStringHelper.hpp:2490
xalanc::XalanDOMString::operator[]
const_reference operator[](size_type theIndex) const
Definition: XalanDOMString.hpp:312
xalanc::XalanDOMString::at
const_reference at(size_type theIndex) const
Definition: XalanDOMString.hpp:328
xalanc::XalanDOMString::resize
void resize(size_type theCount)
Definition: XalanDOMString.hpp:230
xalanc::XalanDOMString::equals
static bool equals(const XalanDOMString &theLHS, const XalanDOMChar *theRHS)
Definition: XalanDOMString.hpp:730
xalanc::pointer_equal
Definition: STLHelper.hpp:480
xalanc::XalanDOMString::assign
XalanDOMString & assign(const XalanDOMChar *theSource, size_type theCount)
Definition: XalanDOMString.hpp:402
xalanc::DOMStringNotEqualsFunction
Not equals functor for DOMStrings.
Definition: XalanDOMString.hpp:913
xalanc::XalanMapKeyTraits< XalanDOMString * >::Hasher
DOMStringPointerHashFunction Hasher
Definition: XalanDOMString.hpp:875
xalanc::XalanDOMString::operator+=
XalanDOMString & operator+=(const XalanDOMChar *theString)
Definition: XalanDOMString.hpp:376
xalanc::XalanDOMString::assign
XalanDOMString & assign(const char *theSource, size_type theCount)
Definition: XalanDOMString.hpp:428
xalanc::XalanDOMString::capacity
size_type capacity() const
Definition: XalanDOMString.hpp:238
xalanc::XalanDOMString::reference
XalanDOMChar & reference
Definition: XalanDOMString.hpp:54
xalanc::XalanDOMString::assign
XalanDOMString & assign(size_type theCount, XalanDOMChar theChar)
Definition: XalanDOMString.hpp:465
xalanc::XalanDOMString::clear
void clear()
Definition: XalanDOMString.hpp:257
xalanc::XalanDOMString::CharVectorType
XalanVector< char > CharVectorType
Definition: XalanDOMString.hpp:50
xalanc::XalanDOMString::end
iterator end()
Definition: XalanDOMString.hpp:139
xalanc::XalanDOMString::getBackInsertIterator
iterator getBackInsertIterator()
Definition: XalanDOMString.hpp:787
xalanc::XalanDOMString::reverse_iterator
XalanDOMCharVectorType::reverse_iterator reverse_iterator
Definition: XalanDOMString.hpp:61
xalanc::XalanDOMString::c_str
const XalanDOMChar * c_str() const
Definition: XalanDOMString.hpp:344
xalanc::XalanDOMString::insert
XalanDOMString & insert(size_type thePosition, const XalanDOMChar *theString)
Definition: XalanDOMString.hpp:563
xalanc::XalanDOMString::const_iterator
XalanDOMCharVectorType::const_iterator const_iterator
Definition: XalanDOMString.hpp:60
xalanc::XalanDOMString::erase
iterator erase(iterator thePosition)
Definition: XalanDOMString.hpp:269
xalanc::XalanDOMString::append
XalanDOMString & append(const XalanDOMChar *theString)
Definition: XalanDOMString.hpp:507
xalanc::XalanDOMString::TranscodingError
Definition: XalanDOMString.hpp:660
xalanc::XalanMapKeyTraits
Definition: XalanMap.hpp:68
xalanc::XalanDOMString::data
const XalanDOMChar * data() const
Definition: XalanDOMString.hpp:352
xalanc::operator==
bool operator==(const XalanDOMChar *theLHS, const XalanDOMString &theRHS)
Definition: XalanDOMString.hpp:1014
xalanc::XalanDOMString::operator=
XalanDOMString & operator=(const char *theRHS)
Definition: XalanDOMString.hpp:111
xalanc::insert
XalanDOMString & insert(XalanDOMString &theString, XalanDOMString::size_type thePosition, const XalanDOMString &theStringToInsert)
Insert a string into another string.
Definition: DOMStringHelper.hpp:2418
xalanc::CharVectorType
XalanVector< char > CharVectorType
Definition: XalanDOMString.hpp:1126
xalanc::XalanDOMString::const_reference
const typedef XalanDOMChar & const_reference
Definition: XalanDOMString.hpp:55
xalanc::XalanDOMString::rend
reverse_iterator rend()
Definition: XalanDOMString.hpp:185
xalanc::XalanDOMString::size_type
XalanSize_t size_type
Definition: XalanDOMString.hpp:57
xalanc::XalanDOMString::iterator
XalanDOMCharVectorType::iterator iterator
Definition: XalanDOMString.hpp:59
xalanc::XalanDOMString::rend
const_reverse_iterator rend() const
Definition: XalanDOMString.hpp:193
xalanc::XalanDOMString::TranscodingError::~TranscodingError
virtual ~TranscodingError()
Definition: XalanDOMString.hpp:670
XalanDOMDefinitions.hpp
XALAN_DOM_EXPORT
#define XALAN_DOM_EXPORT
Definition: XalanDOMDefinitions.hpp:37
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::XalanDOMString::reserve
void reserve(size_type theCount=0)
Definition: XalanDOMString.hpp:249
xalanc::XalanVector< XalanDOMChar >::reverse_iterator
reverse_iterator_ reverse_iterator
Definition: XalanVector.hpp:77
xalanc::XalanDOMString::WideCharVectorType
XalanVector< wchar_t > WideCharVectorType
Definition: XalanDOMString.hpp:51
xalanc::XalanDOMString::begin
iterator begin()
Definition: XalanDOMString.hpp:123
XalanDOMException.hpp
xalanc::XalanDOMString::value_type
XalanDOMChar value_type
Definition: XalanDOMString.hpp:53
xalanc::XalanDOMString::operator[]
reference operator[](size_type theIndex)
Definition: XalanDOMString.hpp:320
xalanc::DOMStringLessThanFunction
Less than functor for DOMStrings.
Definition: XalanDOMString.hpp:932
xalanc::XalanVector< XalanDOMChar >::size_type
size_t size_type
Definition: XalanVector.hpp:68
XALAN_DEFAULT_CONSTRUCTOR_MEMMGR
#define XALAN_DEFAULT_CONSTRUCTOR_MEMMGR
Definition: XalanMemoryManagement.hpp:515
xalanc::XalanDOMString::begin
const_iterator begin() const
Definition: XalanDOMString.hpp:131
xalanc::DOMStringHashFunction
Hash functor for DOMStrings.
Definition: XalanDOMString.hpp:842
xalanc::XalanDOMString::append
XalanDOMString & append(const char *theString)
Definition: XalanDOMString.hpp:518
xalanc::XalanDOMString::push_back
void push_back(XalanDOMChar theChar)
Definition: XalanDOMString.hpp:529
xalanc::XalanDOMString::hash
size_t hash() const
Definition: XalanDOMString.hpp:694
xalanc::XalanDOMString::insert
XalanDOMString & insert(size_type thePosition, const XalanDOMString &theString)
Definition: XalanDOMString.hpp:539