(file) Return to XmlGenerator.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/XmlGenerator.cpp between version 1.6.4.6 and 1.11

version 1.6.4.6, 2009/10/27 18:38:08 version 1.11, 2013/01/09 11:55:36
Line 194 
Line 194 
 }; };
  
 // If _isSpecialChar7[ch] is true, then ch is a special character, which must // If _isSpecialChar7[ch] is true, then ch is a special character, which must
 // have a special encoding in XML. But only use 7-bit ASCII characters to  // have a special encoding in XML.
 // index this array.  // Remaining 128 values are automatically initialised to 0 by compiler.
 static const int _isSpecialChar7[] =  static const int _isSpecialChar7[256] =
 { {
     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,
     0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,     0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,
Line 205 
Line 205 
 }; };
  
 // If _isSpecialChar7[ch] is true, then ch is a special character, which must // If _isSpecialChar7[ch] is true, then ch is a special character, which must
 // have a special encoding in XML. But only use 7-biat ASCII characters to  // have a special encoding in XML.
 // index this array.  
 static const int _isNormalChar7[] = static const int _isNormalChar7[] =
 { {
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,
     1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,     1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,
     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
   // remaining 128 values are used on multi-byte UTF-8 and should not be escaped
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
 }; };
  
  
Line 331 
Line 335 
         _appendChar(out, c);         _appendChar(out, c);
 } }
  
   
   // The code is to checks for the case where the character
   // type is char or unsigned char, depending on the platform
   // and compiler.The check avoids comparing to >= 0 for unsigned char
   // which triggers a GCC warning "comparison is always true"
   
   template <class T>
   bool isSpecialChar( T c)
   {
       return (((c < 0x20) && (c >= 0)) || (c == 0x7f));
   }
   
   template <>
   bool isSpecialChar(Sint8 c)
   {
       return (((c < 0x20) && (c >= 0)) || (c == 0x7f));
   }
   
   template <>
   bool isSpecialChar( Uint8 c)
   {
       return ((c < 0x20) || (c == 0x7f));
   }
   
 void XmlGenerator::_appendSpecialChar(PEGASUS_STD(ostream)& os, char c) void XmlGenerator::_appendSpecialChar(PEGASUS_STD(ostream)& os, char c)
 { {
     if ( ((c < 0x20) && (c >= 0)) || (c == 0x7f) )      if (isSpecialChar(c))
     {     {
         char scratchBuffer[22];         char scratchBuffer[22];
         Uint32 outputLength;         Uint32 outputLength;
Line 626 
Line 654 
     const Uint8* p= (const Uint8*) str;     const Uint8* p= (const Uint8*) str;
  
     while (size >= 4 &&     while (size >= 4 &&
              (_isNormalChar7[p[0]] |               (_isNormalChar7[p[0]] &
               _isNormalChar7[p[1]] |                _isNormalChar7[p[1]] &
               _isNormalChar7[p[2]] |                _isNormalChar7[p[2]] &
               _isNormalChar7[p[3]]))               _isNormalChar7[p[3]]))
     {     {
         size -= 4;         size -= 4;
Line 639 
Line 667 
  
     while (size>=8)     while (size>=8)
     {     {
         register int c;          register Uint8 c;
         c = str[0];         c = str[0];
         if (_isSpecialChar7[c])         if (_isSpecialChar7[c])
         {         {
Line 734 
Line 762 
  
     while (size>=4)     while (size>=4)
     {     {
         register int c;          register Uint8 c;
         c = str[0];         c = str[0];
         if (_isSpecialChar7[c])         if (_isSpecialChar7[c])
         {         {
Line 785 
Line 813 
  
     while (size--)     while (size--)
     {     {
         register int c;          register Uint8 c;
         c=*str;         c=*str;
         if (_isSpecialChar7[c])         if (_isSpecialChar7[c])
         {         {
Line 825 
Line 853 
 void XmlGenerator::_encodeURIChar(String& outString, Sint8 char8) void XmlGenerator::_encodeURIChar(String& outString, Sint8 char8)
 { {
     Uint8 c = (Uint8)char8;     Uint8 c = (Uint8)char8;
   
 #ifndef PEGASUS_DO_NOT_IMPLEMENT_URI_ENCODING  
     if (c > 127 || _is_uri[int(c)])     if (c > 127 || _is_uri[int(c)])
     {     {
         char hexencoding[4];         char hexencoding[4];
         int n = sprintf(hexencoding, "%%%X%X", c/16, c%16);         int n = sprintf(hexencoding, "%%%X%X", c/16, c%16);
 #ifdef PEGASUS_USE_STRING_EXTENSIONS  
         outString.append(hexencoding, n);         outString.append(hexencoding, n);
 #else /* PEGASUS_USE_STRING_EXTENSIONS */  
         outString.append(hexencoding);  
 #endif /* PEGASUS_USE_STRING_EXTENSIONS */  
     }     }
     else     else
 #endif  
     {     {
         outString.append((Uint16)c);         outString.append((Uint16)c);
     }     }
 } }
  
 String XmlGenerator::encodeURICharacters(const Buffer& uriString)  
 {  
     String encodedString;  
   
     for (Uint32 i=0; i<uriString.size(); i++)  
     {  
         _encodeURIChar(encodedString, uriString[i]);  
     }  
   
     return encodedString;  
 }  
   
 String XmlGenerator::encodeURICharacters(const String& uriString) String XmlGenerator::encodeURICharacters(const String& uriString)
 { {
     String encodedString;     String encodedString;


Legend:
Removed from v.1.6.4.6  
changed lines
  Added in v.1.11

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2