peiyongz 2004/03/18 17:18:08 Modified: c/src/xercesc/validators/datatype AbstractNumericFacetValidator.cpp AbstractNumericFacetValidator.hpp Log: Let base dv to store/load (Max,Min)(Inc,Exc)sives Revision Changes Path 1.19 +76 -21 xml-xerces/c/src/xercesc/validators/datatype/AbstractNumericFacetValidator.cpp Index: AbstractNumericFacetValidator.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/AbstractNumericFacetValidator.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- AbstractNumericFacetValidator.cpp 29 Jan 2004 11:51:22 -0000 1.18 +++ AbstractNumericFacetValidator.cpp 19 Mar 2004 01:18:08 -0000 1.19 @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.19 2004/03/19 01:18:08 peiyongz + * Let base dv to store/load (Max,Min)(Inc,Exc)sives + * * Revision 1.18 2004/01/29 11:51:22 cargilld * Code cleanup changes to get rid of various compiler diagnostic messages. * @@ -974,18 +977,14 @@ ***/ DatatypeValidator::serialize(serEng); - serEng<<fMaxInclusiveInherited; - serEng<<fMaxExclusiveInherited; - serEng<<fMinInclusiveInherited; - serEng<<fMinExclusiveInherited; - serEng<<fEnumerationInherited; - // need not write type info for the XMLNumber since - // the derivative class has done that - serEng<<fMaxInclusive; - serEng<<fMaxExclusive; - serEng<<fMinInclusive; - serEng<<fMinExclusive; + // the derivative class has done that + storeClusive(serEng, fMaxInclusiveInherited, fMaxInclusive); + storeClusive(serEng, fMaxExclusiveInherited, fMaxExclusive); + storeClusive(serEng, fMinInclusiveInherited, fMinInclusive); + storeClusive(serEng, fMinExclusiveInherited, fMinExclusive); + + serEng<<fEnumerationInherited; /*** * Serialize RefArrayVectorOf<XMLCh> @@ -1005,16 +1004,12 @@ DatatypeValidator::serialize(serEng); - serEng>>fMaxInclusiveInherited; - serEng>>fMaxExclusiveInherited; - serEng>>fMinInclusiveInherited; - serEng>>fMinExclusiveInherited; - serEng>>fEnumerationInherited; + loadClusive(serEng, fMaxInclusiveInherited, fMaxInclusive, numType, 1); + loadClusive(serEng, fMaxExclusiveInherited, fMaxExclusive, numType, 2); + loadClusive(serEng, fMinInclusiveInherited, fMinInclusive, numType, 3); + loadClusive(serEng, fMinExclusiveInherited, fMinExclusive, numType, 4); - fMaxInclusive=XMLNumber::loadNumber(numType, serEng); - fMaxExclusive=XMLNumber::loadNumber(numType, serEng); - fMinInclusive=XMLNumber::loadNumber(numType, serEng); - fMinExclusive=XMLNumber::loadNumber(numType, serEng); + serEng>>fEnumerationInherited; /*** * Deserialize RefArrayVectorOf<XMLCh> @@ -1022,6 +1017,66 @@ ***/ XTemplateSerializer::loadObject(&fStrEnumeration, 8, true, serEng); XTemplateSerializer::loadObject(&fEnumeration, 8, true, numType, serEng); + + } + +} + +// +// A user defined dv may inherit any of the Max/Min/Inc/Exc from a +// built dv, which will create its own Max/Min/Inc/Exc during the +// loading. Therefore if the user defined store and load this +// facet, and does not own it, that will cause leakage. +// +// To avoid checking if the facet belongs to a builtIn dv or not, we +// do this way, for any inherited *clusive, we will not store it, and later +// on during loading, we get it from the base dv. +// +void AbstractNumericFacetValidator::storeClusive(XSerializeEngine& serEng + , bool inherited + , XMLNumber* data) +{ + serEng<<inherited; + + //store only if own it + if (!inherited) + serEng<<data; + +} + +// it is guranteed that the base dv is loaded before this dv +// +void AbstractNumericFacetValidator::loadClusive(XSerializeEngine& serEng + , bool& inherited + , XMLNumber*& data + , XMLNumber::NumberType numType + , int flag) +{ + serEng>>inherited; + + if (!inherited) + data = XMLNumber::loadNumber(numType, serEng); + else + { + AbstractNumericFacetValidator* basedv = (AbstractNumericFacetValidator*) getBaseValidator(); + + switch(flag) + { + case 1: + data = basedv->getMaxInclusive(); + break; + case 2: + data = basedv->getMaxExclusive(); + break; + case 3: + data = basedv->getMinInclusive(); + break; + case 4: + data = basedv->getMinExclusive(); + break; + default: + break; + } } 1.12 +14 -1 xml-xerces/c/src/xercesc/validators/datatype/AbstractNumericFacetValidator.hpp Index: AbstractNumericFacetValidator.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/AbstractNumericFacetValidator.hpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- AbstractNumericFacetValidator.hpp 29 Jan 2004 11:51:22 -0000 1.11 +++ AbstractNumericFacetValidator.hpp 19 Mar 2004 01:18:08 -0000 1.12 @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.12 2004/03/19 01:18:08 peiyongz + * Let base dv to store/load (Max,Min)(Inc,Exc)sives + * * Revision 1.11 2004/01/29 11:51:22 cargilld * Code cleanup changes to get rid of various compiler diagnostic messages. * @@ -228,6 +231,16 @@ void inspectFacetBase(MemoryManager* const manager); void inheritFacet(); + + void storeClusive(XSerializeEngine& + , bool + , XMLNumber*); + + void loadClusive(XSerializeEngine& + , bool& + , XMLNumber*& + , XMLNumber::NumberType + , int ); // ----------------------------------------------------------------------- // Unimplemented constructors and operators
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]