cargilld 2005/02/21 10:19:46 Modified: c/src/xercesc/dom/impl DOMNodeVector.cpp DOMNodeVector.hpp c/src/xercesc/internal IGXMLScanner.cpp IGXMLScanner2.cpp SGXMLScanner.cpp XMLReader.cpp c/src/xercesc/util KVStringPair.cpp KVStringPair.hpp c/src/xercesc/validators/schema TraverseSchema.cpp Log: Performance fixes from Christian Will. Revision Changes Path 1.7 +1 -19 xml-xerces/c/src/xercesc/dom/impl/DOMNodeVector.cpp Index: DOMNodeVector.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMNodeVector.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DOMNodeVector.cpp 8 Sep 2004 13:55:52 -0000 1.6 +++ DOMNodeVector.cpp 21 Feb 2005 18:19:45 -0000 1.7 @@ -88,19 +88,6 @@ } } - -DOMNode *DOMNodeVector::elementAt(XMLSize_t index) { - if (index >= nextFreeSlot) - return 0; - return data[index]; -} - -DOMNode *DOMNodeVector::lastElement() { - if (nextFreeSlot == 0) - return 0; - return data[nextFreeSlot-1]; -} - void DOMNodeVector::insertElementAt(DOMNode *elem, XMLSize_t index) { XMLSize_t i; @@ -135,10 +122,5 @@ } -XMLSize_t DOMNodeVector::size() { - return nextFreeSlot; -} - - XERCES_CPP_NAMESPACE_END 1.6 +17 -1 xml-xerces/c/src/xercesc/dom/impl/DOMNodeVector.hpp Index: DOMNodeVector.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMNodeVector.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- DOMNodeVector.hpp 8 Sep 2004 13:55:52 -0000 1.5 +++ DOMNodeVector.hpp 21 Feb 2005 18:19:45 -0000 1.6 @@ -65,6 +65,22 @@ void reset(); }; +inline DOMNode *DOMNodeVector::elementAt(XMLSize_t index) { + if (index >= nextFreeSlot) + return 0; + return data[index]; +} + +inline DOMNode *DOMNodeVector::lastElement() { + if (nextFreeSlot == 0) + return 0; + return data[nextFreeSlot-1]; +} + +inline XMLSize_t DOMNodeVector::size() { + return nextFreeSlot; +} + XERCES_CPP_NAMESPACE_END #endif 1.87 +17 -7 xml-xerces/c/src/xercesc/internal/IGXMLScanner.cpp Index: IGXMLScanner.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner.cpp,v retrieving revision 1.86 retrieving revision 1.87 diff -u -r1.86 -r1.87 --- IGXMLScanner.cpp 19 Feb 2005 23:44:17 -0000 1.86 +++ IGXMLScanner.cpp 21 Feb 2005 18:19:45 -0000 1.87 @@ -632,6 +632,8 @@ return attCount; } + const XMLCh* curAttNameBuf = fAttNameBuf.getRawBuffer(); + // And next must be an equal sign if (!scanEq()) { @@ -674,7 +676,7 @@ // Next should be the quoted attribute value. We just do a simple // and stupid scan of this value. The only thing we do here // is to expand entity references. - if (!basicAttrValueScan(fAttNameBuf.getRawBuffer(), fAttValueBuf)) + if (!basicAttrValueScan(curAttNameBuf, fAttValueBuf)) { static const XMLCh tmpList[] = { @@ -711,10 +713,10 @@ // Make sure that the name is basically well formed for namespace // enabled rules. It either has no colons, or it has one which // is neither the first or last char. - const int colonFirst = XMLString::indexOf(fAttNameBuf.getRawBuffer(), chColon); + const int colonFirst = XMLString::indexOf(curAttNameBuf, chColon); if (colonFirst != -1) { - const int colonLast = XMLString::lastIndexOf(fAttNameBuf.getRawBuffer(), chColon); + const int colonLast = XMLString::lastIndexOf(chColon, curAttNameBuf, fAttNameBuf.getLen()); if (colonFirst != colonLast) { @@ -737,16 +739,24 @@ { curPair = new (fMemoryManager) KVStringPair ( - fAttNameBuf.getRawBuffer() + curAttNameBuf + , fAttNameBuf.getLen() , fAttValueBuf.getRawBuffer() + , fAttValueBuf.getLen() , fMemoryManager ); toFill.addElement(curPair); } else { - curPair = toFill.elementAt(attCount); - curPair->set(fAttNameBuf.getRawBuffer(), fAttValueBuf.getRawBuffer()); + curPair = toFill.elementAt(attCount); + curPair->set + ( + curAttNameBuf, + fAttNameBuf.getLen(), + fAttValueBuf.getRawBuffer(), + fAttValueBuf.getLen() + ); } // And bump the count of attributes we've gotten 1.81 +59 -40 xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp Index: IGXMLScanner2.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -u -r1.80 -r1.81 --- IGXMLScanner2.cpp 7 Jan 2005 08:33:15 -0000 1.80 +++ IGXMLScanner2.cpp 21 Feb 2005 18:19:45 -0000 1.81 @@ -900,48 +900,67 @@ // Loop through the chars of the source value and normalize it according // to the type. States curState = InContent; - bool escaped; bool firstNonWS = false; XMLCh nextCh; const XMLCh* srcPtr = value; - while (*srcPtr) - { - // Get the next character from the source. We have to watch for - // escaped characters (which are indicated by a 0xFFFF value followed - // by the char that was escaped.) - nextCh = *srcPtr; - escaped = (nextCh == 0xFFFF); - if (escaped) - nextCh = *++srcPtr; - - // If its not escaped, then make sure its not a < character, which is - // not allowed in attribute values. - if (!escaped && (*srcPtr == chOpenAngle)) - { - emitError(XMLErrs::BracketInAttrValue, attName); - retVal = false; - } - if (type == XMLAttDef::CData || type > XMLAttDef::Notation) - { - if (!escaped) + if (type == XMLAttDef::CData || type > XMLAttDef::Notation) { + while (*srcPtr) { + // Get the next character from the source. We have to watch for + // escaped characters (which are indicated by a 0xFFFF value followed + // by the char that was escaped.) + nextCh = *srcPtr; + + // Do we have an escaped character ? + if (nextCh == 0xFFFF) { - if ((nextCh == 0x09) || (nextCh == 0x0A) || (nextCh == 0x0D)) - { - // Check Validity Constraint for Standalone document declaration - // XML 1.0, Section 2.9 - if (fStandalone && fValidate && isAttExternal) - { - // Can't have a standalone document declaration of "yes" if attribute - // values are subject to normalisation - fValidator->emitError(XMLValid::NoAttNormForStandalone, attName); - } - nextCh = chSpace; + nextCh = *++srcPtr; + } + else if ( (nextCh <= 0x0D) && (nextCh == 0x09 || nextCh == 0x0A || nextCh == 0x0D) ) { + // Check Validity Constraint for Standalone document declaration + // XML 1.0, Section 2.9 + if (fStandalone && fValidate && isAttExternal) + { + // Can't have a standalone document declaration of "yes" if attribute + // values are subject to normalisation + fValidator->emitError(XMLValid::NoAttNormForStandalone, attName); } + nextCh = chSpace; + } + else if (nextCh == chOpenAngle) { + // If its not escaped, then make sure its not a < character, which is + // not allowed in attribute values. + emitError(XMLErrs::BracketInAttrValue, attName); + retVal = false; } + + // Add this char to the target buffer + toFill.append(nextCh); + + // And move up to the next character in the source + srcPtr++; } - else + } + else { + while (*srcPtr) { + // Get the next character from the source. We have to watch for + // escaped characters (which are indicated by a 0xFFFF value followed + // by the char that was escaped.) + nextCh = *srcPtr; + + // Do we have an escaped character ? + if (nextCh == 0xFFFF) + { + nextCh = *++srcPtr; + } + else if (nextCh == chOpenAngle) { + // If its not escaped, then make sure its not a < character, which is + // not allowed in attribute values. + emitError(XMLErrs::BracketInAttrValue, attName); + retVal = false; + } + if (curState == InWhitespace) { if (!fReaderMgr.getCurrentReader()->isWhitespace(nextCh)) @@ -979,15 +998,15 @@ } firstNonWS = true; } - } - // Add this char to the target buffer - toFill.append(nextCh); + // Add this char to the target buffer + toFill.append(nextCh); - // And move up to the next character in the source - srcPtr++; + // And move up to the next character in the source + srcPtr++; + } } - + return retVal; } 1.109 +76 -57 xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp Index: SGXMLScanner.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp,v retrieving revision 1.108 retrieving revision 1.109 diff -u -r1.108 -r1.109 --- SGXMLScanner.cpp 19 Feb 2005 23:44:17 -0000 1.108 +++ SGXMLScanner.cpp 21 Feb 2005 18:19:45 -0000 1.109 @@ -563,6 +563,8 @@ return attCount; } + const XMLCh* curAttNameBuf = fAttNameBuf.getRawBuffer(); + // And next must be an equal sign if (!scanEq()) { @@ -605,7 +607,7 @@ // Next should be the quoted attribute value. We just do a simple // and stupid scan of this value. The only thing we do here // is to expand entity references. - if (!basicAttrValueScan(fAttNameBuf.getRawBuffer(), fAttValueBuf)) + if (!basicAttrValueScan(curAttNameBuf, fAttValueBuf)) { static const XMLCh tmpList[] = { @@ -642,10 +644,10 @@ // Make sure that the name is basically well formed for namespace // enabled rules. It either has no colons, or it has one which // is neither the first or last char. - const int colonFirst = XMLString::indexOf(fAttNameBuf.getRawBuffer(), chColon); + const int colonFirst = XMLString::indexOf(curAttNameBuf, chColon); if (colonFirst != -1) { - const int colonLast = XMLString::lastIndexOf(fAttNameBuf.getRawBuffer(), chColon); + const int colonLast = XMLString::lastIndexOf(chColon, curAttNameBuf, fAttNameBuf.getLen()); if (colonFirst != colonLast) { @@ -668,8 +670,10 @@ { curPair = new (fMemoryManager) KVStringPair ( - fAttNameBuf.getRawBuffer() + curAttNameBuf + , fAttNameBuf.getLen() , fAttValueBuf.getRawBuffer() + , fAttValueBuf.getLen() , fMemoryManager ); toFill.addElement(curPair); @@ -677,7 +681,13 @@ else { curPair = toFill.elementAt(attCount); - curPair->set(fAttNameBuf.getRawBuffer(), fAttValueBuf.getRawBuffer()); + curPair->set + ( + curAttNameBuf + , fAttNameBuf.getLen() + , fAttValueBuf.getRawBuffer() + , fAttValueBuf.getLen() + ); } // And bump the count of attributes we've gotten @@ -2745,7 +2755,7 @@ // are legal if escaped only. And some escape chars are not subject to // normalization rules. bool SGXMLScanner::normalizeAttValue( const XMLAttDef* const attDef - , const XMLCh* const attrName + , const XMLCh* const attName , const XMLCh* const value , XMLBuffer& toFill) { @@ -2772,54 +2782,68 @@ // Loop through the chars of the source value and normalize it according // to the type. - States curState = InContent; - bool escaped; + States curState = InContent; bool firstNonWS = false; XMLCh nextCh; const XMLCh* srcPtr = value; - while (*srcPtr) - { - // Get the next character from the source. We have to watch for - // escaped characters (which are indicated by a 0xFFFF value followed - // by the char that was escaped.) - nextCh = *srcPtr; - escaped = (nextCh == 0xFFFF); - if (escaped) - nextCh = *++srcPtr; - // If its not escaped, then make sure its not a < character, which is - // not allowed in attribute values. - if (!escaped && (*srcPtr == chOpenAngle)) - { - emitError(XMLErrs::BracketInAttrValue, attrName); - retVal = false; - } - - if (type == XMLAttDef::CData || type > XMLAttDef::Notation) - { - if (!escaped) + if (type == XMLAttDef::CData || type > XMLAttDef::Notation) { + while (*srcPtr) { + // Get the next character from the source. We have to watch for + // escaped characters (which are indicated by a 0xFFFF value followed + // by the char that was escaped.) + nextCh = *srcPtr; + + // Do we have an escaped character ? + if (nextCh == 0xFFFF) { - if ((nextCh == 0x09) || (nextCh == 0x0A) || (nextCh == 0x0D)) - { - // Check Validity Constraint for Standalone document declaration - // XML 1.0, Section 2.9 - if (fStandalone && fValidate && isAttExternal) - { - // Can't have a standalone document declaration of "yes" if attribute - // values are subject to normalisation - fValidator->emitError(XMLValid::NoAttNormForStandalone, attrName); - if (getPSVIHandler()) - { - // REVISIT: - // PSVIAttribute->setValidity(PSVIItem::VALIDITY_INVALID); - } - } - nextCh = chSpace; + nextCh = *++srcPtr; + } + else if ( (nextCh <= 0x0D) && (nextCh == 0x09 || nextCh == 0x0A || nextCh == 0x0D) ) { + // Check Validity Constraint for Standalone document declaration + // XML 1.0, Section 2.9 + if (fStandalone && fValidate && isAttExternal) + { + // Can't have a standalone document declaration of "yes" if attribute + // values are subject to normalisation + fValidator->emitError(XMLValid::NoAttNormForStandalone, attName); } + nextCh = chSpace; } + else if (nextCh == chOpenAngle) { + // If its not escaped, then make sure its not a < character, which is + // not allowed in attribute values. + emitError(XMLErrs::BracketInAttrValue, attName); + retVal = false; + } + + // Add this char to the target buffer + toFill.append(nextCh); + + // And move up to the next character in the source + srcPtr++; } - else + } + else { + while (*srcPtr) { + // Get the next character from the source. We have to watch for + // escaped characters (which are indicated by a 0xFFFF value followed + // by the char that was escaped.) + nextCh = *srcPtr; + + // Do we have an escaped character ? + if (nextCh == 0xFFFF) + { + nextCh = *++srcPtr; + } + else if (nextCh == chOpenAngle) { + // If its not escaped, then make sure its not a < character, which is + // not allowed in attribute values. + emitError(XMLErrs::BracketInAttrValue, attName); + retVal = false; + } + if (curState == InWhitespace) { if (!fReaderMgr.getCurrentReader()->isWhitespace(nextCh)) @@ -2850,25 +2874,20 @@ { // Can't have a standalone document declaration of "yes" if attribute // values are subject to normalisation - fValidator->emitError(XMLValid::NoAttNormForStandalone, attrName); - if (getPSVIHandler()) - { - // REVISIT: - // PSVIAttribute->setValidity(PSVIItem::VALIDITY_INVALID); - } + fValidator->emitError(XMLValid::NoAttNormForStandalone, attName); } } continue; } firstNonWS = true; } - } - // Add this char to the target buffer - toFill.append(nextCh); + // Add this char to the target buffer + toFill.append(nextCh); - // And move up to the next character in the source - srcPtr++; + // And move up to the next character in the source + srcPtr++; + } } return retVal; 1.27 +53 -34 xml-xerces/c/src/xercesc/internal/XMLReader.cpp Index: XMLReader.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLReader.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- XMLReader.cpp 20 Dec 2004 15:50:42 -0000 1.26 +++ XMLReader.cpp 21 Feb 2005 18:19:45 -0000 1.27 @@ -591,6 +591,8 @@ return false; } + unsigned int fCharIndex_start = fCharIndex; + // Lets check the first char for being a first name char. If not, then // what's the point in living mannnn? Just give up now. We only do this // if its a name and not a name token that they want. @@ -603,56 +605,73 @@ if ((fCharBuf[fCharIndex+1] < 0xDC00) || (fCharBuf[fCharIndex+1] > 0xDFFF)) return false; - // Looks ok, so lets eat it and put it in our buffer - toFill.append(fCharBuf[fCharIndex++]); - fCurCol++; - toFill.append(fCharBuf[fCharIndex++]); - fCurCol++; + // Looks ok, so lets eat it + fCharIndex += 2; } else { if (!isFirstNameChar(fCharBuf[fCharIndex])) return false; - // Looks ok, so lets eat it and put it in our buffer. Update column also! - toFill.append(fCharBuf[fCharIndex++]); - fCurCol++; + // Looks ok, so lets eat it + fCharIndex ++; } } // And now we loop until we run out of data in this reader or we hit // a non-name char. - do { - - while (fCharIndex < fCharsAvail) + while (true) + { + if (fXMLVersion == XMLV1_1) { - // Check the current char and take it if its a name char. Else - // break out. - if (fXMLVersion == XMLV1_1 && ((fCharBuf[fCharIndex] >= 0xD800) && (fCharBuf[fCharIndex] <= 0xDB7F))) { - // make sure one more char is in the buffer, the transcoder - // should put only a complete surrogate pair into the buffer - assert(fCharIndex+1 < fCharsAvail); - if ((fCharBuf[fCharIndex+1] < 0xDC00) || (fCharBuf[fCharIndex+1] > 0xDFFF)) - return !toFill.isEmpty(); - - toFill.append(fCharBuf[fCharIndex++]); - fCurCol++; - toFill.append(fCharBuf[fCharIndex++]); - fCurCol++; - } - else { - if (!isNameChar(fCharBuf[fCharIndex])) + while (fCharIndex < fCharsAvail) + { + // Check the current char and take it if its a name char. Else + // break out. + if ( (fCharBuf[fCharIndex] >= 0xD800) && (fCharBuf[fCharIndex] <= 0xDB7F) ) { - return !toFill.isEmpty(); - } + // make sure one more char is in the buffer, the transcoder + // should put only a complete surrogate pair into the buffer + assert(fCharIndex+1 < fCharsAvail); + if ( (fCharBuf[fCharIndex+1] < 0xDC00) || + (fCharBuf[fCharIndex+1] > 0xDFFF) ) + break; + fCharIndex += 2; - toFill.append(fCharBuf[fCharIndex++]); - fCurCol++; + } + else + { + if (!isNameChar(fCharBuf[fCharIndex])) + break; + fCharIndex++; + } + } + } + else // XMLV1_0 + { + while (fCharIndex < fCharsAvail) + { + if (!isNameChar(fCharBuf[fCharIndex])) + break; + fCharIndex++; } } - // If we don't get no more, then break out. - } while (refreshCharBuffer()); + // we have to copy the accepted character(s), and update column + if (fCharIndex != fCharIndex_start) + { + fCurCol += fCharIndex - fCharIndex_start; + toFill.append(&fCharBuf[fCharIndex_start], fCharIndex - fCharIndex_start); + } + + // something is wrong if there is still something in the buffer + // or if we don't get no more, then break out. + if ((fCharIndex < fCharsAvail) || + !refreshCharBuffer()) + break; + + fCharIndex_start = fCharIndex; + } return !toFill.isEmpty(); } 1.9 +32 -39 xml-xerces/c/src/xercesc/util/KVStringPair.cpp Index: KVStringPair.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/KVStringPair.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- KVStringPair.cpp 7 Jan 2005 15:12:10 -0000 1.8 +++ KVStringPair.cpp 21 Feb 2005 18:19:45 -0000 1.9 @@ -16,6 +16,9 @@ /* * $Log$ + * Revision 1.9 2005/02/21 18:19:45 cargilld + * Performance fixes from Christian Will. + * * Revision 1.8 2005/01/07 15:12:10 amassari * Removed warnings * @@ -121,6 +124,35 @@ set(key, value); } +KVStringPair::KVStringPair(const XMLCh* const key, + const XMLCh* const value, + const unsigned int valueLength, + MemoryManager* const manager) +:fKeyAllocSize(0) +,fValueAllocSize(0) +,fKey(0) +,fValue(0) +,fMemoryManager(manager) +{ + setKey(key); + setValue(value, valueLength); +} + +KVStringPair::KVStringPair(const XMLCh* const key, + const unsigned int keyLength, + const XMLCh* const value, + const unsigned int valueLength, + MemoryManager* const manager) +:fKeyAllocSize(0) +,fValueAllocSize(0) +,fKey(0) +,fValue(0) +,fMemoryManager(manager) +{ + setKey(key, keyLength); + setValue(value, valueLength); +} + KVStringPair::KVStringPair(const KVStringPair& toCopy) :XSerializable(toCopy) ,XMemory(toCopy) @@ -139,45 +171,6 @@ fMemoryManager->deallocate(fValue); //delete [] fValue; } - -// --------------------------------------------------------------------------- -// KVStringPair: Setters -// --------------------------------------------------------------------------- -void KVStringPair::setKey(const XMLCh* const newKey) -{ - const unsigned int len = XMLString::stringLen(newKey); - - if (len >= fKeyAllocSize) - { - fMemoryManager->deallocate(fKey); //delete [] fKey; - fKeyAllocSize = len + 1; - fKey = (XMLCh*) fMemoryManager->allocate(fKeyAllocSize * sizeof(XMLCh)); //new XMLCh[fKeyAllocSize]; - } - - XMLString::copyString(fKey, newKey); -} - -void KVStringPair::setValue(const XMLCh* const newValue) -{ - const unsigned int len = XMLString::stringLen(newValue); - - if (len >= fValueAllocSize) - { - fMemoryManager->deallocate(fValue); //delete [] fValue; - fValueAllocSize = len + 1; - fValue = (XMLCh*) fMemoryManager->allocate(fValueAllocSize * sizeof(XMLCh)); //new XMLCh[fValueAllocSize]; - } - - XMLString::copyString(fValue, newValue); -} - -void KVStringPair::set( const XMLCh* const newKey - , const XMLCh* const newValue) -{ - setKey(newKey); - setValue(newValue); -} - /*** * Support for Serialization/De-serialization ***/ 1.10 +93 -3 xml-xerces/c/src/xercesc/util/KVStringPair.hpp Index: KVStringPair.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/KVStringPair.hpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- KVStringPair.hpp 28 Oct 2004 20:14:41 -0000 1.9 +++ KVStringPair.hpp 21 Feb 2005 18:19:45 -0000 1.10 @@ -16,6 +16,9 @@ /* * $Log$ + * Revision 1.10 2005/02/21 18:19:45 cargilld + * Performance fixes from Christian Will. + * * Revision 1.9 2004/10/28 20:14:41 peiyongz * Data member reshuffle * @@ -122,6 +125,21 @@ , const XMLCh* const value , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); + KVStringPair + ( + const XMLCh* const key + , const XMLCh* const value + , const unsigned int valueLength + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); + KVStringPair + ( + const XMLCh* const key + , const unsigned int keyLength + , const XMLCh* const value + , const unsigned int valueLength + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); KVStringPair(const KVStringPair& toCopy); ~KVStringPair(); @@ -142,12 +160,28 @@ // ----------------------------------------------------------------------- void setKey(const XMLCh* const newKey); void setValue(const XMLCh* const newValue); + void setKey + ( + const XMLCh* const newKey + , const unsigned int newKeyLength + ); + void setValue + ( + const XMLCh* const newValue + , const unsigned int newValueLength + ); void set ( - const XMLCh* const newKey - , const XMLCh* const newValue + const XMLCh* const newKey + , const XMLCh* const newValue + ); + void set + ( + const XMLCh* const newKey + , const unsigned int newKeyLength + , const XMLCh* const newValue + , const unsigned int newValueLength ); - /*** * Support for Serialization/De-serialization @@ -204,6 +238,62 @@ return fValue; } +// --------------------------------------------------------------------------- +// KVStringPair: Setters +// --------------------------------------------------------------------------- +inline void KVStringPair::setKey(const XMLCh* const newKey) +{ + setKey(newKey, XMLString::stringLen(newKey)); +} + +inline void KVStringPair::setValue(const XMLCh* const newValue) +{ + setValue(newValue, XMLString::stringLen(newValue)); +} + +inline void KVStringPair::setKey( const XMLCh* const newKey + , const unsigned int newKeyLength) +{ + if (newKeyLength >= fKeyAllocSize) + { + fMemoryManager->deallocate(fKey); //delete [] fKey; + fKeyAllocSize = newKeyLength + 1; + fKey = (XMLCh*) fMemoryManager->allocate(fKeyAllocSize * sizeof(XMLCh)); //new XMLCh[fKeyAllocSize]; + } + + memcpy(fKey, newKey, (newKeyLength+1) * sizeof(XMLCh)); // len+1 because of the 0 at the end +} + +inline void KVStringPair::setValue( const XMLCh* const newValue + , const unsigned int newValueLength) +{ + if (newValueLength >= fValueAllocSize) + { + fMemoryManager->deallocate(fValue); //delete [] fValue; + fValueAllocSize = newValueLength + 1; + fValue = (XMLCh*) fMemoryManager->allocate(fValueAllocSize * sizeof(XMLCh)); //new XMLCh[fValueAllocSize]; + } + + memcpy(fValue, newValue, (newValueLength+1) * sizeof(XMLCh)); // len+1 because of the 0 at the end +} + +inline void KVStringPair::set( const XMLCh* const newKey + , const XMLCh* const newValue) +{ + setKey(newKey, XMLString::stringLen(newKey)); + setValue(newValue, XMLString::stringLen(newValue)); +} + +inline void KVStringPair::set( const XMLCh* const newKey + , const unsigned int newKeyLength + , const XMLCh* const newValue + , const unsigned int newValueLength) +{ + setKey(newKey, newKeyLength); + setValue(newValue, newValueLength); +} + + XERCES_CPP_NAMESPACE_END #endif 1.130 +3 -2 xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp Index: TraverseSchema.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp,v retrieving revision 1.129 retrieving revision 1.130 diff -u -r1.129 -r1.130 --- TraverseSchema.cpp 14 Dec 2004 02:06:40 -0000 1.129 +++ TraverseSchema.cpp 21 Feb 2005 18:19:45 -0000 1.130 @@ -3210,7 +3210,7 @@ if (!pattern.isEmpty()) { - KVStringPair* kv = new (fGrammarPoolMemoryManager) KVStringPair(SchemaSymbols::fgELT_PATTERN, pattern.getRawBuffer(), fGrammarPoolMemoryManager); + KVStringPair* kv = new (fGrammarPoolMemoryManager) KVStringPair(SchemaSymbols::fgELT_PATTERN, pattern.getRawBuffer(), pattern.getLen(), fGrammarPoolMemoryManager); if (!janPatternAnnot.isDataNull()) fSchemaGrammar->putAnnotation(kv, janPatternAnnot.release()); facets->put((void*) SchemaSymbols::fgELT_PATTERN, kv); @@ -3705,6 +3705,7 @@ ( SchemaSymbols::fgELT_PATTERN , pattern.getRawBuffer() + , pattern.getLen() , fGrammarPoolMemoryManager ) );
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]