You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2001/02/27 19:33:58 UTC

cvs commit: xml-xerces/c/src/framework XMLAttr.cpp XMLAttr.hpp

tng         01/02/27 10:33:58

  Modified:    c/src/framework XMLAttr.cpp XMLAttr.hpp
  Log:
  Schema: Use QName in XMLAttr.
  
  Revision  Changes    Path
  1.8       +22 -108   xml-xerces/c/src/framework/XMLAttr.cpp
  
  Index: XMLAttr.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/framework/XMLAttr.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XMLAttr.cpp	2000/07/25 22:33:28	1.7
  +++ XMLAttr.cpp	2001/02/27 18:33:55	1.8
  @@ -1,37 +1,37 @@
   /*
    * The Apache Software License, Version 1.1
  - * 
  + *
    * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
    * reserved.
  - * 
  + *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
  - * 
  + *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  - * 
  + *    notice, this list of conditions and the following disclaimer.
  + *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
    *    the documentation and/or other materials provided with the
    *    distribution.
  - * 
  + *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
    *    if and wherever such third-party acknowledgments normally appear.
  - * 
  + *
    * 4. The names "Xerces" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache\@apache.org.
  - * 
  + *
    * 5. Products derived from this software may not be called "Apache",
    *    nor may "Apache" appear in their name, without prior written
    *    permission of the Apache Software Foundation.
  - * 
  + *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  @@ -45,7 +45,7 @@
    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    * SUCH DAMAGE.
    * ====================================================================
  - * 
  + *
    * This software consists of voluntary contributions made by many
    * individuals on behalf of the Apache Software Foundation, and was
    * originally based on software copyright (c) 1999, International
  @@ -55,7 +55,7 @@
    */
   
   /**
  - * $Id: XMLAttr.cpp,v 1.7 2000/07/25 22:33:28 aruna1 Exp $
  + * $Id: XMLAttr.cpp,v 1.8 2001/02/27 18:33:55 tng Exp $
    */
   
   
  @@ -73,19 +73,13 @@
   //  XMLAttr: Constructors and Destructor
   // ---------------------------------------------------------------------------
   XMLAttr::XMLAttr() :
  -
  -    fName(0)
  -    , fNameBufSz(0)
  -    , fPrefix(0)
  -    , fPrefixBufSz(0)
  -    , fQName(0)
  -    , fQNameBufSz(0)
  -    , fType(XMLAttDef::CData)
  +      fType(XMLAttDef::CData)
       , fValue(0)
       , fValueBufSz(0)
       , fSpecified(false)
  -    , fURIId(0)
  +    , fAttName(0)
   {
  +    fAttName = new QName();
   }
   
   XMLAttr::XMLAttr(   const   unsigned int        uriId
  @@ -95,17 +89,10 @@
                       , const XMLAttDef::AttTypes type
                       , const bool                specified) :
   
  -    fName(0)
  -    , fNameBufSz(0)
  -    , fPrefix(0)
  -    , fPrefixBufSz(0)
  -    , fQName(0)
  -    , fQNameBufSz(0)
  -    , fType(type)
  +      fType(type)
       , fValue(0)
       , fValueBufSz(0)
       , fSpecified(specified)
  -    , fURIId(0)
   {
       try
       {
  @@ -113,7 +100,7 @@
           //  Just call the local setters to set up everything. Too much
           //  work is required to replicate that functionality here.
           //
  -        setName(uriId, attrName, attrPrefix);
  +        fAttName = new QName(attrPrefix, attrName, uriId);
           setValue(attrValue);
       }
   
  @@ -129,53 +116,7 @@
   // ---------------------------------------------------------------------------
   const XMLCh* XMLAttr::getQName() const
   {
  -    //
  -    //  If there is no buffer, or if there is but we've not faulted in the
  -    //  value yet, then we have to do that now.
  -    //
  -    if (!fQName || !*fQName)
  -    {
  -        //
  -        //  Calculate the worst case size buffer we will need. We use the
  -        //  current high water marks of the prefix and name buffers, so it
  -        //  might be a little wasteful of memory but we don't have to do
  -        //  string len operations on the two strings.
  -        //
  -        const unsigned int neededLen = fPrefixBufSz + fNameBufSz + 1;
  -
  -        //
  -        //  If no buffer, or the current one is too small, then allocate one
  -        //  and get rid of any old one.
  -        //
  -        if (!fQName || (neededLen > fQNameBufSz))
  -        {
  -            delete [] fQName;
  -
  -            // We have to cast off the const'ness to do this
  -            ((XMLAttr*)this)->fQNameBufSz = neededLen;
  -            ((XMLAttr*)this)->fQName = new XMLCh[neededLen + 1];
  -
  -            // Make sure its initially empty
  -            *fQName = 0;
  -        }
  -
  -        //
  -        //  If we have a prefix, then do the prefix:name version. Else, its
  -        //  just the name.
  -        //
  -        if (*fPrefix)
  -        {
  -            const XMLCh colonStr[] = { chColon, chNull };
  -            XMLString::copyString(fQName, fPrefix);
  -            XMLString::catString(fQName, colonStr);
  -            XMLString::catString(fQName, fName);
  -        }
  -         else
  -        {
  -            XMLString::copyString(fQName, fName);
  -        }
  -    }
  -    return fQName;
  +    return fAttName->getRawName();
   }
   
   
  @@ -186,38 +127,13 @@
                           , const XMLCh* const    attrName
                           , const XMLCh* const    attrPrefix)
   {
  -    unsigned int newLen;
  -
  -    newLen = XMLString::stringLen(attrName);
  -    if (!fNameBufSz || (newLen > fNameBufSz))
  -    {
  -        delete [] fName;
  -        fNameBufSz = newLen + 8;
  -        fName = new XMLCh[fNameBufSz + 1];
  -    }
  -    XMLString::moveChars(fName, attrName, newLen + 1);
  -
  -    newLen = XMLString::stringLen(attrPrefix);
  -    if (!fPrefixBufSz || (newLen > fPrefixBufSz))
  -    {
  -        delete [] fPrefix;
  -        fPrefixBufSz = newLen + 8;
  -        fPrefix = new XMLCh[fPrefixBufSz + 1];
  -    }
  -    XMLString::moveChars(fPrefix, attrPrefix, newLen + 1);
  -
  -    // And clean up any QName and leave it undone until/if asked for again
  -    if (fQName)
  -        *fQName = 0;
  -
  -    // And finally store the URI id parameter
  -    fURIId = uriId;
  +    fAttName->setName(attrPrefix, attrName, uriId);
   }
   
   
   void XMLAttr::setURIId(const unsigned int uriId)
   {
  -    fURIId = uriId;
  +    fAttName->setURI(uriId);
   }
   
   
  @@ -239,8 +155,6 @@
   // ---------------------------------------------------------------------------
   void XMLAttr::cleanUp()
   {
  -    delete [] fName;
  -    delete [] fPrefix;
  -    delete [] fQName;
  +    delete fAttName;
       delete [] fValue;
   }
  
  
  
  1.7       +24 -43    xml-xerces/c/src/framework/XMLAttr.hpp
  
  Index: XMLAttr.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/framework/XMLAttr.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLAttr.hpp	2000/04/10 22:42:53	1.6
  +++ XMLAttr.hpp	2001/02/27 18:33:55	1.7
  @@ -1,37 +1,37 @@
   /*
    * The Apache Software License, Version 1.1
  - * 
  + *
    * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
    * reserved.
  - * 
  + *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
  - * 
  + *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  - * 
  + *    notice, this list of conditions and the following disclaimer.
  + *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
    *    the documentation and/or other materials provided with the
    *    distribution.
  - * 
  + *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
    *    if and wherever such third-party acknowledgments normally appear.
  - * 
  + *
    * 4. The names "Xerces" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache\@apache.org.
  - * 
  + *
    * 5. Products derived from this software may not be called "Apache",
    *    nor may "Apache" appear in their name, without prior written
    *    permission of the Apache Software Foundation.
  - * 
  + *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  @@ -45,7 +45,7 @@
    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    * SUCH DAMAGE.
    * ====================================================================
  - * 
  + *
    * This software consists of voluntary contributions made by many
    * individuals on behalf of the Apache Software Foundation, and was
    * originally based on software copyright (c) 1999, International
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: XMLAttr.hpp,v $
  + * Revision 1.7  2001/02/27 18:33:55  tng
  + * Schema: Use QName in XMLAttr.
  + *
    * Revision 1.6  2000/04/10 22:42:53  roddey
    * Extended the buffer reuse to the QName field, to further increase
    * performance of attribute heavy applications.
  @@ -86,6 +89,7 @@
   #define XMLATTR_HPP
   
   #include <util/XMLString.hpp>
  +#include <util/QName.hpp>
   #include <framework/XMLAttDef.hpp>
   
   
  @@ -342,25 +346,9 @@
   
       // -----------------------------------------------------------------------
       //  Private instance variables
  -    //
  -    //  fName
  -    //  fNameBufSz
  -    //      The base part of the name of the attribute, and the current size
  -    //      of the buffer (minus one, where the null is.)
  -    //
  -    //  fPrefix
  -    //  fPrefixBufSz
  -    //      The prefix that was applied to this attribute's name, and the
  -    //      current size of the buffer (minus one for the null.) Prefixes
  -    //      really don't matter technically but it might be required for
  -    //      pratical reasons, to recreate the original document for instance.
       //
  -    //  fQName
  -    //  fQNameBufSz
  -    //      This is the QName form of the name, which is faulted in (from the
  -    //      prefix and name) upon request. The size field indicates the
  -    //      current size of the buffer (minus one for the null.) It will be
  -    //      zero until fauled in.
  +    //  fAttName
  +    //      The Attribute Name;
       //
       //  fSpecified
       //      True if this attribute appeared in the element; else, false if
  @@ -375,20 +363,12 @@
       //      The attribute value that was given in the attribute instance, and
       //      its current buffer size (minus one, where the null is.)
       //
  -    //  fURIId
  -    //      The id of the URI that this attribute belongs to.
       // -----------------------------------------------------------------------
  -    XMLCh*              fName;
  -    unsigned int        fNameBufSz;
  -    XMLCh*              fPrefix;
  -    unsigned int        fPrefixBufSz;
  -    XMLCh*              fQName;
  -    unsigned int        fQNameBufSz;
       bool                fSpecified;
       XMLAttDef::AttTypes fType;
       XMLCh*              fValue;
       unsigned int        fValueBufSz;
  -    unsigned int        fURIId;
  +    QName*              fAttName;
   };
   
   // ---------------------------------------------------------------------------
  @@ -405,12 +385,12 @@
   // ---------------------------------------------------------------------------
   inline const XMLCh* XMLAttr::getName() const
   {
  -    return fName;
  +    return fAttName->getLocalPart();
   }
   
   inline const XMLCh* XMLAttr::getPrefix() const
   {
  -    return fPrefix;
  +    return fAttName->getPrefix();
   }
   
   inline bool XMLAttr::getSpecified() const
  @@ -430,7 +410,7 @@
   
   inline unsigned int XMLAttr::getURIId() const
   {
  -    return fURIId;
  +    return fAttName->getURI();
   }
   
   
  @@ -444,7 +424,7 @@
                           , const XMLAttDef::AttTypes type)
   {
       // Set the name info and the value via their respective calls
  -    setName(uriId, attrName, attrPrefix);
  +    fAttName->setName(attrPrefix, attrName, uriId);
       setValue(attrValue);
   
       // And store the type