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

Diff for /pegasus/src/Pegasus/Common/XmlParser.cpp between version 1.45 and 1.52

version 1.45, 2008/04/29 20:40:24 version 1.52, 2008/12/02 09:00:53
Line 1 
Line 1 
 //%2006////////////////////////////////////////////////////////////////////////  //%LICENSE////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development  // Licensed to The Open Group (TOG) under one or more contributor license
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.  // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;  // this work for additional information regarding copyright ownership.
 // IBM Corp.; EMC Corporation, The Open Group.  // Each contributor licenses this file to you under the OpenPegasus Open
 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;  // Source License; you may not use this file except in compliance with the
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.  // License.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;  //
 // EMC Corporation; VERITAS Software Corporation; The Open Group.  // Permission is hereby granted, free of charge, to any person obtaining a
 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;  // copy of this software and associated documentation files (the "Software"),
 // EMC Corporation; Symantec Corporation; The Open Group.  // to deal in the Software without restriction, including without limitation
 //  // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 // Permission is hereby granted, free of charge, to any person obtaining a copy  // and/or sell copies of the Software, and to permit persons to whom the
 // of this software and associated documentation files (the "Software"), to  // Software is furnished to do so, subject to the following conditions:
 // deal in the Software without restriction, including without limitation the  //
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  // The above copyright notice and this permission notice shall be included
 // sell copies of the Software, and to permit persons to whom the Software is  // in all copies or substantial portions of the Software.
 // furnished to do so, subject to the following conditions:  //
 //  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
 // //
 //==============================================================================  //////////////////////////////////////////////////////////////////////////
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 210 
Line 208 
     const String& message)     const String& message)
 { {
     String dftMsg = _xmlMessages[Uint32(code) - 1];     String dftMsg = _xmlMessages[Uint32(code) - 1];
     String key = _xmlKeys[Uint32(code) - 1];      const char* key = _xmlKeys[Uint32(code) - 1];
     String msg = message;     String msg = message;
  
     dftMsg.append(": on line $0");     dftMsg.append(": on line $0");
Line 220 
Line 218 
         dftMsg.append("$1");         dftMsg.append("$1");
     }     }
  
     return MessageLoaderParms(key, dftMsg, line ,msg);      return MessageLoaderParms(key, dftMsg.getCString(), line ,msg);
 } }
  
 static MessageLoaderParms _formPartialMessage(Uint32 code, Uint32 line) static MessageLoaderParms _formPartialMessage(Uint32 code, Uint32 line)
 { {
     String dftMsg = _xmlMessages[Uint32(code) - 1];     String dftMsg = _xmlMessages[Uint32(code) - 1];
     String key = _xmlKeys[Uint32(code) - 1];      const char* key = _xmlKeys[Uint32(code) - 1];
  
     dftMsg.append(": on line $0");     dftMsg.append(": on line $0");
  
     return MessageLoaderParms(key, dftMsg, line);      return MessageLoaderParms(key, dftMsg.getCString(), line);
 } }
  
  
Line 375 
Line 373 
 #pragma optimize( "", on ) #pragma optimize( "", on )
 #endif #endif
  
 static inline int _getCharRef(char*& p, bool hex)  static inline int _getCharRef(char*& p)
 { {
     char* end;     char* end;
     unsigned long ch;     unsigned long ch;
       Boolean hex = false;
  
     if (hex)      if (*p == 'x')
     {     {
         ch = strtoul(p, &end, 16);          hex = true;
           ch = strtoul(++p, &end, 16);
     }     }
     else     else
     {     {
Line 404 
Line 404 
     return ch;     return ch;
 } }
  
 static void _normalize(Uint32& line, char*& p, char end_char, char*& start)  // Parse an entity reference or a character reference
   static inline int _getRef(Uint32 line, char*& p)
 { {
     // Skip over leading whitespace:      int ch;
  
     _skipWhitespace(line, p);      if (*p == '#')
     start = p;      {
           ch = _getCharRef(++p);
       }
       else
       {
           ch = _getEntityRef(p);
       }
   
       if (ch == -1)
       {
           throw XmlException(XmlException::MALFORMED_REFERENCE, line);
       }
  
       return ch;
   }
   
   static inline void _normalizeElementValue(
       Uint32& line,
       char*& p)
   {
     // Process one character at a time:     // Process one character at a time:
  
     char* q = p;     char* q = p;
  
     while (*p && (*p != end_char))      while (*p && (*p != '<'))
     {     {
         if (_isspace(*p))         if (_isspace(*p))
         {         {
             // Compress sequences of whitespace characters to a single space              // Trim whitespace from the end of the value, but do not compress
             // character. Update line number when newlines encountered.              // whitespace within the value.
   
               const char* start = p;
  
             if (*p++ == '\n')             if (*p++ == '\n')
             {             {
                 line++;                 line++;
             }             }
  
             *q++ = ' ';  
   
             _skipWhitespace(line, p);             _skipWhitespace(line, p);
         }  
         else if (*p == '&')  
         {  
             // Process entity characters and entity references:  
   
             p++;  
             int ch;  
  
             if (*p == '#')              if (*p && (*p != '<'))
             {             {
                 *p++;                  // Transfer internal whitespace to q without compressing it.
                   const char* i = start;
                 if (*p == 'x')                  while (i < p)
                 {                 {
                     p++;                      *q++ = *i++;
                     ch = _getCharRef(p, true);                  }
                 }                 }
                 else                 else
                 {                 {
                     ch = _getCharRef(p, false);                  // Do not transfer trailing whitespace to q.
                   break;
                 }                 }
             }             }
           else if (*p == '&')
           {
               // Process an entity reference or a character reference.
   
               *q++ = _getRef(line, ++p);
           }
             else             else
             {             {
                 ch = _getEntityRef(p);              *q++ = *p++;
           }
             }             }
  
             if (ch == -1)      // If q got behind p, it is safe and necessary to null-terminate q
   
       if (q != p)
             {             {
                 throw XmlException(XmlException::MALFORMED_REFERENCE, line);          *q = '\0';
       }
             }             }
  
             *q++ = ch;  static inline void _normalizeAttributeValue(
       Uint32& line,
       char*& p,
       char end_char,
       char*& start)
   {
       // Skip over leading whitespace:
   
       _skipWhitespace(line, p);
       start = p;
   
       // Process one character at a time:
   
       char* q = p;
   
       while (*p && (*p != end_char))
       {
           if (_isspace(*p))
           {
               // Compress sequences of whitespace characters to a single space
               // character. Update line number when newlines encountered.
   
               if (*p++ == '\n')
               {
                   line++;
               }
   
               *q++ = ' ';
   
               _skipWhitespace(line, p);
           }
           else if (*p == '&')
           {
               // Process an entity reference or a character reference.
   
               *q++ = _getRef(line, ++p);
         }         }
         else         else
         {         {
Line 579 
Line 637 
         {         {
             // Normalize the content:             // Normalize the content:
  
             char* start;              char* start = _current;
             _normalize(_line, _current, '<', start);              _normalizeElementValue(_line, _current);
  
             // Get the content:             // Get the content:
  
Line 749 
Line 807 
     1,1,1,1,1,1,1,1,1,1,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,     1,1,1,1,1,1,1,1,1,1,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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 }; };
  
 inline Boolean _getQName(char*& p, const char*& localName) inline Boolean _getQName(char*& p, const char*& localName)
Line 761 
Line 819 
  
     p++;     p++;
  
     while (*p && _isInnerElementChar[Uint8(*p)])      // No explicit test for NULL termination is needed.
       // On position 0 of the array false is returned.
       while (_isInnerElementChar[Uint8(*p)])
         p++;         p++;
  
     // We've validated the prefix, now validate the local name     // We've validated the prefix, now validate the local name
Line 773 
Line 833 
             return false;             return false;
  
         p++;         p++;
           // No explicit test for NULL termination is needed.
         while (*p && _isInnerElementChar[Uint8(*p)])          // On position 0 of the array false is returned.
           while (_isInnerElementChar[Uint8(*p)])
             p++;             p++;
     }     }
  
Line 932 
Line 993 
         entry.type = XmlEntry::XML_DECLARATION;         entry.type = XmlEntry::XML_DECLARATION;
         entry.text = ++p;         entry.text = ++p;
  
         Boolean openCloseElement = false;  
   
         if (_getElementName(p, entry.localName))         if (_getElementName(p, entry.localName))
             return;             return;
     }     }
Line 978 
Line 1037 
  
         return;         return;
     }     }
     else if ((((*p >= 'A') && (*p <= 'Z')) ||      else if (CharSet::isAlphaUnder(Uint8(*p)))
               ((*p >= 'a') && (*p <= 'z')) ||  
               (*p == '_')))  
     {     {
         entry.type = XmlEntry::START_TAG;         entry.type = XmlEntry::START_TAG;
         entry.text = p;         entry.text = p;
Line 1038 
Line 1095 
             char quote = *p++;             char quote = *p++;
  
             char* start;             char* start;
             _normalize(_line, p, quote, start);              _normalizeAttributeValue(_line, p, quote, start);
             attr.value = start;             attr.value = start;
  
             if (*p != quote)             if (*p != quote)
Line 1123 
Line 1180 
 } }
  
 const XmlAttribute* XmlEntry::findAttribute( const XmlAttribute* XmlEntry::findAttribute(
     int nsType,      int attrNsType,
     const char* name) const     const char* name) const
 { {
     for (Uint32 i = 0, n = attributes.size(); i < n; i++)     for (Uint32 i = 0, n = attributes.size(); i < n; i++)
     {     {
         if ((attributes[i].nsType == nsType) &&          if ((attributes[i].nsType == attrNsType) &&
             (strcmp(attributes[i].localName, name) == 0))             (strcmp(attributes[i].localName, name) == 0))
         {         {
             return &attributes[i];             return &attributes[i];


Legend:
Removed from v.1.45  
changed lines
  Added in v.1.52

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2