00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 #if !defined(XMLSTRING_HPP)
00148 #define XMLSTRING_HPP
00149
00150 #include <util/XercesDefs.hpp>
00151
00152 class XMLLCPTranscoder;
00153
00165 class XMLString
00166 {
00167 public:
00168
00171
00182 static void binToText
00183 (
00184 const unsigned int toFormat
00185 , char* const toFill
00186 , const unsigned int maxChars
00187 , const unsigned int radix
00188 );
00189
00200 static void binToText
00201 (
00202 const unsigned int toFormat
00203 , XMLCh* const toFill
00204 , const unsigned int maxChars
00205 , const unsigned int radix
00206 );
00207
00218 static void binToText
00219 (
00220 const unsigned long toFormat
00221 , char* const toFill
00222 , const unsigned int maxChars
00223 , const unsigned int radix
00224 );
00225
00236 static void binToText
00237 (
00238 const unsigned long toFormat
00239 , XMLCh* const toFill
00240 , const unsigned int maxChars
00241 , const unsigned int radix
00242 );
00243
00254 static void binToText
00255 (
00256 const long toFormat
00257 , char* const toFill
00258 , const unsigned int maxChars
00259 , const unsigned int radix
00260 );
00261
00272 static void binToText
00273 (
00274 const long toFormat
00275 , XMLCh* const toFill
00276 , const unsigned int maxChars
00277 , const unsigned int radix
00278 );
00279
00290 static void binToText
00291 (
00292 const int toFormat
00293 , char* const toFill
00294 , const unsigned int maxChars
00295 , const unsigned int radix
00296 );
00297
00308 static void binToText
00309 (
00310 const int toFormat
00311 , XMLCh* const toFill
00312 , const unsigned int maxChars
00313 , const unsigned int radix
00314 );
00315
00326 static bool textToBin
00327 (
00328 const XMLCh* const toConvert
00329 , unsigned int& toFill
00330 );
00332
00335
00349 static void catString
00350 (
00351 char* const target
00352 , const char* const src
00353 );
00354
00367 static void catString
00368 (
00369 XMLCh* const target
00370 , const XMLCh* const src
00371 );
00373
00376
00387 static int compareIString
00388 (
00389 const char* const str1
00390 , const char* const str2
00391 );
00392
00403 static int compareIString
00404 (
00405 const XMLCh* const str1
00406 , const XMLCh* const str2
00407 );
00408
00409
00423 static int compareNString
00424 (
00425 const char* const str1
00426 , const char* const str2
00427 , const unsigned int count
00428 );
00429
00443 static int compareNString
00444 (
00445 const XMLCh* const str1
00446 , const XMLCh* const str2
00447 , const unsigned int count
00448 );
00449
00450
00464 static int compareNIString
00465 (
00466 const char* const str1
00467 , const char* const str2
00468 , const unsigned int count
00469 );
00470
00485 static int compareNIString
00486 (
00487 const XMLCh* const str1
00488 , const XMLCh* const str2
00489 , const unsigned int count
00490 );
00491
00504 static int compareString
00505 (
00506 const char* const str1
00507 , const char* const str2
00508 );
00509
00521 static int compareString
00522 (
00523 const XMLCh* const str1
00524 , const XMLCh* const str2
00525 );
00527
00530
00540 static void copyString
00541 (
00542 char* const target
00543 , const char* const src
00544 );
00545
00556 static void copyString
00557 (
00558 XMLCh* const target
00559 , const XMLCh* const src
00560 );
00561
00574 static bool copyNString
00575 (
00576 XMLCh* const target
00577 , const XMLCh* const src
00578 , const unsigned int maxChars
00579 );
00581
00584
00590 static unsigned int hash
00591 (
00592 const char* const tohash
00593 , const unsigned int hashModulus
00594 );
00595
00602 static unsigned int hash
00603 (
00604 const XMLCh* const toHash
00605 , const unsigned int hashModulus
00606 );
00607
00617 static unsigned int hashN
00618 (
00619 const XMLCh* const toHash
00620 , const unsigned int numChars
00621 , const unsigned int hashModulus
00622 );
00623
00625
00628
00636 static int indexOf(const char* const toSearch, const char ch);
00637
00646 static int indexOf(const XMLCh* const toSearch, const XMLCh ch);
00647
00656 static int lastIndexOf(const char* const toSearch, const char ch);
00657
00666 static int lastIndexOf(const XMLCh* const toSearch, const XMLCh ch);
00667
00678 static int lastIndexOf
00679 (
00680 const char* const toSearch
00681 , const char chToFind
00682 , const unsigned int fromIndex
00683 );
00684
00695 static int lastIndexOf
00696 (
00697 const XMLCh* const toSearch
00698 , const XMLCh ch
00699 , const unsigned int fromIndex
00700 );
00702
00705
00710 static void moveChars
00711 (
00712 XMLCh* const targetStr
00713 , const XMLCh* const srcStr
00714 , const unsigned int count
00715 );
00716
00718
00721
00725 static char* replicate(const char* const toRep);
00726
00731 static XMLCh* replicate(const XMLCh* const toRep);
00732
00734
00737
00743 static bool startsWith
00744 (
00745 const char* const toTest
00746 , const char* const prefix
00747 );
00748
00755 static bool startsWith
00756 (
00757 const XMLCh* const toTest
00758 , const XMLCh* const prefix
00759 );
00760
00769 static bool startsWithI
00770 (
00771 const char* const toTest
00772 , const char* const prefix
00773 );
00774
00784 static bool startsWithI
00785 (
00786 const XMLCh* const toTest
00787 , const XMLCh* const prefix
00788 );
00789
00796 static const XMLCh* findAny
00797 (
00798 const XMLCh* const toSearch
00799 , const XMLCh* const searchList
00800 );
00801
00808 static XMLCh* findAny
00809 (
00810 XMLCh* const toSearch
00811 , const XMLCh* const searchList
00812 );
00813
00818 static unsigned int stringLen(const char* const src);
00819
00824 static unsigned int stringLen(const XMLCh* const src);
00826
00829
00835 static void cut
00836 (
00837 XMLCh* const toCutFrom
00838 , const unsigned int count
00839 );
00840
00849 static char* transcode
00850 (
00851 const XMLCh* const toTranscode
00852 );
00853
00870 static bool transcode
00871 (
00872 const XMLCh* const toTranscode
00873 , char* const toFill
00874 , const unsigned int maxChars
00875 );
00876
00885 static XMLCh* transcode
00886 (
00887 const char* const toTranscode
00888 );
00889
00901 static bool transcode
00902 (
00903 const char* const toTranscode
00904 , XMLCh* const toFill
00905 , const unsigned int maxChars
00906 );
00907
00913 static void trim(char* const toTrim);
00914
00920 static void trim(XMLCh* const toTrim);
00922
00925
00933 static XMLCh* makeUName
00934 (
00935 const XMLCh* const pszURI
00936 , const XMLCh* const pszName
00937 );
00938
00954 static unsigned int replaceTokens
00955 (
00956 XMLCh* const errText
00957 , const unsigned int maxChars
00958 , const XMLCh* const text1
00959 , const XMLCh* const text2
00960 , const XMLCh* const text3
00961 , const XMLCh* const text4
00962 );
00963
00968 static void upperCase(XMLCh* const toUpperCase);
00970
00971
00972 private :
00973
00976
00977 XMLString();
00979 ~XMLString();
00981
00982
00985
00986 static void initString(XMLLCPTranscoder* const defToUse);
00987 static void termString();
00989 friend class XMLPlatformUtils;
00990 };
00991
00992
00993
00994
00995
00996
00997 inline void XMLString::moveChars( XMLCh* const targetStr
00998 , const XMLCh* const srcStr
00999 , const unsigned int count)
01000 {
01001 XMLCh* outPtr = targetStr;
01002 const XMLCh* inPtr = srcStr;
01003 for (unsigned int index = 0; index < count; index++)
01004 *outPtr++ = *inPtr++;
01005 }
01006
01007 inline unsigned int XMLString::stringLen(const XMLCh* const src)
01008 {
01009 if (src == 0 || *src == 0)
01010 {
01011 return 0;
01012 }
01013 else
01014 {
01015 const XMLCh* pszTmp = src + 1;
01016
01017 while (*pszTmp)
01018 ++pszTmp;
01019
01020 return (unsigned int)(pszTmp - src);
01021 }
01022 }
01023
01024 inline bool XMLString::startsWith( const XMLCh* const toTest
01025 , const XMLCh* const prefix)
01026 {
01027 return (compareNString(toTest, prefix, stringLen(prefix)) == 0);
01028 }
01029
01030 inline bool XMLString::startsWithI( const XMLCh* const toTest
01031 , const XMLCh* const prefix)
01032 {
01033 return (compareNIString(toTest, prefix, stringLen(prefix)) == 0);
01034 }
01035
01036 inline XMLCh* XMLString::replicate(const XMLCh* const toRep)
01037 {
01038
01039 XMLCh* ret = 0;
01040 if (toRep)
01041 {
01042 const unsigned int len = stringLen(toRep);
01043 ret = new XMLCh[len + 1];
01044 XMLCh* outPtr = ret;
01045 const XMLCh* inPtr = toRep;
01046 for (unsigned int index = 0; index <= len; index++)
01047 *outPtr++ = *inPtr++;
01048 }
01049 return ret;
01050 }
01051
01052 #endif