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

Diff for /pegasus/src/Pegasus/Common/XmlWriter.cpp between version 1.131 and 1.135

version 1.131, 2005/11/29 20:06:14 version 1.135, 2006/01/30 16:17:08
Line 1 
Line 1 
 //%2005////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
Line 8 
Line 8 
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 // EMC Corporation; VERITAS Software Corporation; The Open Group. // EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; Symantec Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 72 
Line 74 
 #include "CommonUTF.h" #include "CommonUTF.h"
 #include "Buffer.h" #include "Buffer.h"
 #include "StrLit.h" #include "StrLit.h"
   #include "LanguageParser.h"
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
Line 292 
Line 295 
  
  
 // l10n // l10n
 Buffer& operator<<(Buffer& out, const AcceptLanguages& al)  Buffer& operator<<(Buffer& out, const AcceptLanguageList& al)
 { {
     XmlWriter::append(out, al.toString ());      XmlWriter::append(out, LanguageParser::buildAcceptLanguageHeader(al));
     return out;     return out;
 } }
  
 // l10n // l10n
 Buffer& operator<<(Buffer& out, const ContentLanguages& cl)  Buffer& operator<<(Buffer& out, const ContentLanguageList& cl)
 { {
     XmlWriter::append(out, cl.toString ());      XmlWriter::append(out, LanguageParser::buildContentLanguageHeader(cl));
     return out;     return out;
 } }
  
Line 573 
Line 576 
 void XmlWriter::appendSpecial(Buffer& out, const String& str) void XmlWriter::appendSpecial(Buffer& out, const String& str)
 { {
     const Uint16* p = (const Uint16*)str.getChar16Data();     const Uint16* p = (const Uint16*)str.getChar16Data();
     size_t n = str.size();      // prevCharIsSpace is true when the last character written to the Buffer
       // is a space character (not a character reference).
     // Handle leading ASCII 7 characers in these next two loops (use unrolling).      Boolean prevCharIsSpace = false;
   
     while (n >= 8)      // If the first character is a space, use a character reference to avoid
       // space compression.
       if (*p == ' ')
     {     {
         // The following condition is equivalent to this:          out.append(STRLIT_ARGS("&#32;"));
         //     (p[0] < 128 && p[1] < 128 && p[2] < 128 && p[3] < 128 &&          p++;
         //      p[4] < 128 && p[5] < 128 && p[6] < 128 && p[7] < 128)      }
  
         if (((p[0]|p[1]|p[2]|p[3]|p[4]|p[5]|p[6]|p[7]) & 0xFF80) == 0)      Uint16 c;
       while ((c = *p++) != 0)
         {         {
             // Note: "|" is faster than "||" and achieves the same effect          if (c < 128)
             // since p[i] is either 0 or 1.          {
               if (_isSpecialChar7[c])
             if (_isSpecialChar7[p[0]] | _isSpecialChar7[p[1]] |  
                 _isSpecialChar7[p[2]] | _isSpecialChar7[p[3]] |  
                 _isSpecialChar7[p[4]] | _isSpecialChar7[p[5]] |  
                 _isSpecialChar7[p[6]] | _isSpecialChar7[p[7]])  
             {             {
                 // Rare case.                  // Write the character reference for the special character
                 _appendSpecialChar7(out, p[0]);                  out.append(
                 _appendSpecialChar7(out, p[1]);                      _specialChars[int(c)].str, _specialChars[int(c)].size);
                 _appendSpecialChar7(out, p[2]);                  prevCharIsSpace = false;
                 _appendSpecialChar7(out, p[3]);              }
                 _appendSpecialChar7(out, p[4]);              else if (prevCharIsSpace && (c == ' '))
                 _appendSpecialChar7(out, p[5]);              {
                 _appendSpecialChar7(out, p[6]);                  // Write the character reference for the space character, to
                 _appendSpecialChar7(out, p[7]);                  // avoid compression
                   out.append(STRLIT_ARGS("&#32;"));
                   prevCharIsSpace = false;
             }             }
             else             else
             {             {
                 // Common case.                  out.append(c);
                 out.append(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);                  prevCharIsSpace = (c == ' ');
             }             }
             p += 8;  
             n -= 8;  
         }         }
         else         else
             break;  
     }  
   
     while (n >= 4)  
     {     {
         // The following condition is equivalent to this:              // Handle UTF8 case
         //     (p[0] < 128 && p[1] < 128 && p[2] < 128 && p[3] < 128)  
  
         if (((p[0]|p[1]|p[2]|p[3]) & 0xFF80) == 0)              if ((((c >= FIRST_HIGH_SURROGATE) && (c <= LAST_HIGH_SURROGATE)) ||
                    ((c >= FIRST_LOW_SURROGATE) && (c <= LAST_LOW_SURROGATE))) &&
                   *p)
         {         {
             if (_isSpecialChar7[p[0]] | _isSpecialChar7[p[1]] |                  _xmlWritter_appendSurrogatePair(out, c, *p++);
                 _isSpecialChar7[p[2]] | _isSpecialChar7[p[3]])  
             {  
                 // Rare case:  
                 _appendSpecialChar7(out, p[0]);  
                 _appendSpecialChar7(out, p[1]);  
                 _appendSpecialChar7(out, p[2]);  
                 _appendSpecialChar7(out, p[3]);  
             }             }
             else             else
             {             {
                 // Common case:                  _xmlWritter_appendChar(out, c);
                 out.append(p[0], p[1], p[2], p[3]);  
             }             }
  
             p += 4;              prevCharIsSpace = false;
             n -= 4;  
         }  
         else  
             break;  
     }     }
   
     // Process remaining characters. A UTF8 character must have been  
     // encountered or this would have never been reached.  
   
     while (n--)  
     {  
         Uint16 c = *p++;  
   
         // Special processing for UTF8 case:  
   
         if (c < 128)  
         {  
             _appendSpecialChar7(out, c);  
             continue;  
         }         }
  
         // Hanlde UTF8 case (if reached).      // If the last character is a space, use a character reference to avoid
       // space compression.
         if(((c >= FIRST_HIGH_SURROGATE) && (c <= LAST_HIGH_SURROGATE)) ||      if (prevCharIsSpace)
            ((c >= FIRST_LOW_SURROGATE) && (c <= LAST_LOW_SURROGATE)))  
         {  
             Char16 highSurrogate = p[-1];  
             Char16 lowSurrogate = p[0];  
             p++;  
             n--;  
   
             _xmlWritter_appendSurrogatePair(  
                 out, Uint16(highSurrogate),Uint16(lowSurrogate));  
         }  
         else  
         {         {
             _xmlWritter_appendSpecialChar(out, c);          out.remove(out.size() - 1);
         }          out.append(STRLIT_ARGS("&#32;"));
     }     }
 } }
  
Line 1919 
Line 1881 
     const String& cimObject,     const String& cimObject,
     const String& authenticationHeader,     const String& authenticationHeader,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const AcceptLanguages & acceptLanguages,      const AcceptLanguageList& acceptLanguages,
     const ContentLanguages & contentLanguages,      const ContentLanguageList& contentLanguages,
     Uint32 contentLength)     Uint32 contentLength)
 { {
     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };
Line 1995 
Line 1957 
 void XmlWriter::appendMethodResponseHeader( void XmlWriter::appendMethodResponseHeader(
      Buffer& out,      Buffer& out,
      HttpMethod httpMethod,      HttpMethod httpMethod,
      const ContentLanguages & contentLanguages,       const ContentLanguageList& contentLanguages,
      Uint32 contentLength,      Uint32 contentLength,
      Uint64 serverResponseTime)      Uint64 serverResponseTime)
 { {
Line 2708 
Line 2670 
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const String& authenticationHeader,     const String& authenticationHeader,
     const AcceptLanguages& httpAcceptLanguages,      const AcceptLanguageList& httpAcceptLanguages,
     const ContentLanguages& httpContentLanguages)      const ContentLanguageList& httpContentLanguages)
 { {
     Buffer out;     Buffer out;
     Buffer tmp;     Buffer tmp;
Line 2749 
Line 2711 
     const CIMName& methodName,     const CIMName& methodName,
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const ContentLanguages & httpContentLanguages,      const ContentLanguageList& httpContentLanguages,
     const Buffer& body,     const Buffer& body,
                 Uint64 serverResponseTime,                 Uint64 serverResponseTime,
                 Boolean isFirst,                 Boolean isFirst,
Line 2831 
Line 2793 
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const String& authenticationHeader,     const String& authenticationHeader,
     const AcceptLanguages& httpAcceptLanguages,      const AcceptLanguageList& httpAcceptLanguages,
     const ContentLanguages& httpContentLanguages,      const ContentLanguageList& httpContentLanguages,
     const Buffer& body)     const Buffer& body)
 { {
     Buffer out;     Buffer out;
Line 2872 
Line 2834 
     const CIMName& iMethodName,     const CIMName& iMethodName,
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const ContentLanguages & httpContentLanguages,      const ContentLanguageList& httpContentLanguages,
     const Buffer& body,     const Buffer& body,
     Uint64 serverResponseTime,     Uint64 serverResponseTime,
     Boolean isFirst,     Boolean isFirst,
Line 2971 
Line 2933 
     const CIMName& cimMethod,     const CIMName& cimMethod,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const String& authenticationHeader,     const String& authenticationHeader,
     const AcceptLanguages& acceptLanguages,      const AcceptLanguageList& acceptLanguages,
     const ContentLanguages& contentLanguages,      const ContentLanguageList& contentLanguages,
     Uint32 contentLength)     Uint32 contentLength)
 { {
     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };
Line 3042 
Line 3004 
 void XmlWriter::appendEMethodResponseHeader( void XmlWriter::appendEMethodResponseHeader(
     Buffer& out,     Buffer& out,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const ContentLanguages& contentLanguages,      const ContentLanguageList& contentLanguages,
     Uint32 contentLength)     Uint32 contentLength)
 { {
     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };
Line 3210 
Line 3172 
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const String& authenticationHeader,     const String& authenticationHeader,
     const AcceptLanguages& httpAcceptLanguages,      const AcceptLanguageList& httpAcceptLanguages,
     const ContentLanguages& httpContentLanguages,      const ContentLanguageList& httpContentLanguages,
     const Buffer& body)     const Buffer& body)
 { {
     Buffer out;     Buffer out;
Line 3250 
Line 3212 
     const CIMName& eMethodName,     const CIMName& eMethodName,
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const ContentLanguages& httpContentLanguages,      const ContentLanguageList& httpContentLanguages,
     const Buffer& body)     const Buffer& body)
 { {
     Buffer out;     Buffer out;
Line 3431 
Line 3393 
             case XmlEntry::CDATA:             case XmlEntry::CDATA:
             {             {
                 _xmlWritter_indent(os, stack.size(), indentChars);                 _xmlWritter_indent(os, stack.size(), indentChars);
                 os << "<![CDATA[...]]>";                  os << "<![CDATA[" << entry.text << "]]>";
                 break;                 break;
             }             }
  


Legend:
Removed from v.1.131  
changed lines
  Added in v.1.135

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2