Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


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

Interpreting class diagrams

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

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

Apache Logo