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 
63 
64  static const size_type npos;
65 
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
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 
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 
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 
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 
503  const XalanDOMChar* theString,
504  size_type theCount);
505 
507  append(const XalanDOMChar* theString)
508  {
509  return append(theString, length(theString));
510  }
511 
514  const char* theString,
515  size_type theCount);
516 
518  append(const char* theString)
519  {
520  return append(theString, length(theString));
521  }
522 
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 
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 
572  size_type thePosition,
573  size_type theCount,
574  XalanDOMChar theChar);
575 
576  iterator
578  iterator thePosition,
579  XalanDOMChar theChar);
580 
581  void
583  iterator thePosition,
584  size_type theCount,
585  XalanDOMChar theChar);
586 
587  void
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
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
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
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  */
1391  const CharVectorType& theSourceString,
1392  XalanDOMString& theResult);
1393 
1394 
1396 
1397 
1398 
1399 }
1400 
1401 
1402 
1403 #endif // !defined(XALANDOMSTRING_HEADER_GUARD_1357924680)
#define XALAN_DOM_EXPORT
#define XALAN_DOM_EXPORT_FUNCTION(T)
#define XALAN_DEFAULT_CONSTRUCTOR_MEMMGR
#define XALAN_DEFAULT_MEMMGR
#define XALAN_USES_MEMORY_MANAGER(Type)
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
const_iterator getBackInsertIterator() const
void push_back(XalanDOMChar theChar)
XalanDOMString & assign(const char *theSource, size_type theCount)
void transcode(CharVectorType &theResult) const
Transcode the string to the local code page.
XalanDOMString(const char *theString, MemoryManager &theManager XALAN_DEFAULT_MEMMGR, size_type theCount=size_type(npos))
const XalanDOMChar * c_str() const
XalanDOMString & operator+=(XalanDOMChar theChar)
XalanDOMString * clone(MemoryManager &theManager)
size_type max_size() const
int compare(const XalanDOMChar *theString) const
XalanDOMString & assign(const XalanDOMChar *theSource, size_type theCount)
int compare(size_type thePosition1, size_type theCount1, const XalanDOMString &theString) const
const_reference at(size_type theIndex) const
static bool equals(const XalanDOMString &theLHS, const XalanDOMString &theRHS)
int compare(size_type thePosition1, size_type theCount1, const XalanDOMString &theString, size_type thePosition2, size_type theCount2) const
XalanDOMString & operator=(XalanDOMChar theRHS)
XalanDOMCharVectorType::iterator iterator
iterator erase(iterator theFirst, iterator theLast)
iterator insert(iterator thePosition, XalanDOMChar theChar)
const_iterator end() const
reverse_iterator rend()
XalanDOMString(const XalanDOMChar *theString, MemoryManager &theManager XALAN_DEFAULT_MEMMGR, size_type theCount=size_type(npos))
XalanDOMString & assign(const char *theSource)
reverse_iterator rbegin()
XalanDOMString & assign(size_type theCount, XalanDOMChar theChar)
XalanDOMString & append(const char *theString)
const_reverse_iterator rbegin() const
static bool equals(const XalanDOMString &theLHS, const XalanDOMChar *theRHS)
XalanDOMString & assign(const XalanDOMChar *theSource)
static bool equals(const XalanDOMChar *theLHS, size_type theLHSLength, const XalanDOMChar *theRHS, size_type theRHSLength)
static size_type length(const char *theString)
XalanDOMString & operator=(const char *theRHS)
XalanDOMString & insert(size_type thePosition, const XalanDOMString &theString)
iterator getIteratorForPosition(size_type thePosition)
XalanDOMString(MemoryManager &theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR)
MemoryManager & getMemoryManager()
XalanVector< char > CharVectorType
size_type capacity() const
static size_t hash(const XalanDOMChar *theString, size_type theLength)
const_reverse_iterator rend() const
void reserve(size_type theCount=0)
size_type length() const
XalanDOMString & append(const XalanDOMString &theSource)
XalanDOMString & operator=(const XalanDOMString &theRHS)
iterator erase(iterator thePosition)
XalanDOMString & insert(size_type thePosition, const XalanDOMChar *theString)
XalanDOMString & operator+=(const XalanDOMString &theSource)
XalanDOMString & assign(const XalanDOMString &theSource)
int compare(size_type thePosition1, size_type theCount1, const XalanDOMChar *theString, size_type theCount2=size_type(npos)) const
void insert(iterator thePosition, size_type theCount, XalanDOMChar theChar)
XalanDOMString & operator=(const XalanDOMChar *theRHS)
XalanDOMString(size_type theCount, XalanDOMChar theChar, MemoryManager &theManager XALAN_DEFAULT_MEMMGR)
XalanDOMString & append(const XalanDOMString &theSource, size_type thePosition, size_type theCount)
const_reference operator[](size_type theIndex) const
const XalanDOMChar & const_reference
XalanDOMString & erase(size_type theStartPosition=0, size_type theCount=size_type(npos))
XalanVector< XalanDOMChar > XalanDOMCharVectorType
void insert(iterator theInsertPosition, iterator theFirstPosition, iterator theLastPosition)
XalanDOMString & append(const char *theString, size_type theCount)
XalanDOMString & append(const XalanDOMChar *theString)
XalanDOMString & insert(size_type thePosition, const XalanDOMChar *theString, size_type theCount)
void reset(MemoryManager &theManager, const char *theString)
const XalanDOMChar * data() const
static size_type length(const XalanDOMChar *theString)
XalanDOMString & insert(size_type thePosition1, const XalanDOMString &theString, size_type thePosition2, size_type theCount)
XalanVector< wchar_t > WideCharVectorType
void swap(XalanDOMString &theOther)
const_iterator begin() const
void resize(size_type theCount)
XalanDOMString & append(size_type theCount, XalanDOMChar theChar)
static bool equals(const XalanDOMChar *theLHS, const XalanDOMChar *theRHS)
static const size_type npos
XalanDOMChar & reference
XalanDOMCharVectorType::reverse_iterator reverse_iterator
const_iterator getIteratorForPosition(size_type thePosition) const
size_type size() const
reference at(size_type theIndex)
XalanDOMCharVectorType::const_reverse_iterator const_reverse_iterator
reference operator[](size_type theIndex)
XalanDOMString & assign(iterator theFirstPosition, iterator theLastPosition)
XalanDOMString & operator+=(const XalanDOMChar *theString)
XalanDOMString & append(const XalanDOMChar *theString, size_type theCount)
int compare(const XalanDOMString &theString) const
static bool equals(const XalanDOMChar *theLHS, const XalanDOMString &theRHS)
void reset(MemoryManager &theManager, const XalanDOMChar *theString)
XalanDOMString & insert(size_type thePosition, size_type theCount, XalanDOMChar theChar)
XalanDOMString & assign(const XalanDOMString &theSource, size_type thePosition, size_type theCount)
XalanDOMCharVectorType::const_iterator const_iterator
XalanDOMString & substr(XalanDOMString &theSubstring, size_type thePosition=0, size_type theCount=size_type(npos)) const
XalanDOMString(const XalanDOMString &theSource, MemoryManager &theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR, size_type theStartPosition=0, size_type theCount=size_type(npos))
void resize(size_type theCount, XalanDOMChar theChar)
const_reverse_iterator_ const_reverse_iterator
Definition: XalanVector.hpp:78
XalanDOMString & append(XalanDOMString &theString, const XalanDOMString &theStringToAppend)
Concatenate two strings.
XalanVector< char > CharVectorType
XalanVector< XalanDOMChar > XalanDOMCharVectorType
bool operator!=(const XalanDOMString &theLHS, const XalanDOMChar *theRHS)
void erase(XalanDOMString &theString)
Remove all elements from target string.
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
void swap(XalanVector< Type > &theLHS, XalanVector< Type > &theRHS)
size_t size_type
Definition: XalanMap.hpp:46
TranscodeFromLocalCodePage(const CharVectorType &theSourceString, XalanDOMString &theResult)
Convert a vector of characters to a XalanDOMString, transcoding from the default local code.
compare(const CharVectorType &theLHS, const CharVectorType &theRHS)
Compare the contents of two strings.
XalanDOMString & assign(XalanDOMString &theString, const XalanDOMString &theStringToAssign)
Assign one string to another.
const char * c_str(const CharVectorType &theString)
Get the underlying representation of the target CharVectorType as a null-terminated string.
XalanDOMString & insert(XalanDOMString &theString, XalanDOMString::size_type thePosition, const XalanDOMString &theStringToInsert)
Insert a string into another string.
bool operator==(const XalanDOMChar *theLHS, const XalanDOMString &theRHS)
const CharVectorType TranscodeToLocalCodePage(const XalanDOMString &theSourceString)
Convert XalanDOMString to C++ standard library vector, transcoding to the default local code page.
equals(const XalanDOMChar *theLHS, const XalanDOMChar *theRHS, XalanDOMString::size_type theLength)
Compare the contents of two arrays for equality.
Equals functor for DOMStrings.
Hash functor for DOMStrings.
Less than functor for DOMStrings.
Not equals functor for DOMStrings.
Equal to functor for DOMStrings.
Hash functor for DOMStrings.
Less than functor for DOMStrings.
std::equal_to< XalanDOMString > Comparator
pointer_equal< XalanDOMString > Comparator