DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17589>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17589

Refactoring ...

           Summary: Refactoring ...
           Product: Xerces-C++
           Version: Nightly build (please specify the date)
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Utilities
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


(CVS'ed on March 1, 2003) 
 
What follows is the output of running cvs diff -B -b in xml-xerces/c/src/xercesc (and 
removing messages about generated files). 
 
Salut, 
Jacques 
 
----- 
 
Index: framework/XMLFormatter.cpp 
=================================================================== 
RCS file: /home/cvspublic/xml-xerces/c/src/xercesc/framework/XMLFormatter.cpp,v 
retrieving revision 1.7 
diff -B -b -r1.7 XMLFormatter.cpp 
143,164c143,155 
< XMLFormatter::XMLFormatter( const   char* const             outEncoding 
<                             ,       XMLFormatTarget* const  target 
<                             , const EscapeFlags             escapeFlags 
<                             , const UnRepFlags              unrepFlags) : 
<  
<     fEscapeFlags(escapeFlags) 
<     , fOutEncoding(0) 
<     , fTarget(target) 
<     , fUnRepFlags(unrepFlags) 
<     , fXCoder(0) 
<  
<     , fAposRef(0) 
<     , fAmpRef(0) 
<     , fGTRef(0) 
<     , fLTRef(0) 
<     , fQuoteRef(0) 
<  
<     , fAposLen(0) 
<     , fAmpLen(0) 
<     , fGTLen(0) 
<     , fLTLen(0) 
<     , fQuoteLen(0) 
--- 
> XMLFormatter::XMLFormatter(const char      * const outEncoding, 
>                            XMLFormatTarget * const target, 
>                            const EscapeFlags       escapeFlags, 
>                            const UnRepFlags        unrepFlags)  
>    : fEscapeFlags(escapeFlags),  
>      fOutEncoding(0),  
>      fTarget(target),  
>      fUnRepFlags(unrepFlags),  
>      fXCoder(0), 
>  
>      fAmpRef(0), fAposRef(0), fGTRef(0), fLTRef(0), fQuoteRef(0), 
>  
>      fAmpLen(0), fAposLen(0), fGTLen(0), fLTLen(0), fQuoteLen(0) 
168,188c159 
<  
<     // Try to create a transcoder for this encoding 
<     XMLTransService::Codes resCode; 
<     fXCoder = XMLPlatformUtils::fgTransService->makeNewTranscoderFor 
<     ( 
<         fOutEncoding 
<         , resCode 
<         , kTmpBufSize 
<     ); 
<  
<     if (!fXCoder) 
<     { 
<         delete [] fOutEncoding; 
<         fOutEncoding = 0; 
<         ThrowXML1 
<         ( 
<             TranscodingException 
<             , XMLExcepts::Trans_CantCreateCvtrFor 
<             , outEncoding 
<         ); 
<     } 
--- 
>     initialize(target, escapeFlags, unrepFlags); 
190a162,172 
> XMLFormatter::XMLFormatter(const XMLCh *     const outEncoding, 
>                            XMLFormatTarget * const target, 
>                            const EscapeFlags       escapeFlags, 
>                            const UnRepFlags        unrepFlags)  
>    : fEscapeFlags(escapeFlags),  
>      fOutEncoding(0),  
>      fTarget(target),  
>      fUnRepFlags(unrepFlags),  
>      fXCoder(0), 
>  
>      fAmpRef(0), fAposRef(0), fGTRef(0), fLTRef(0), fQuoteRef(0), 
192,206c174 
< XMLFormatter::XMLFormatter( const   XMLCh* const            outEncoding 
<                             ,       XMLFormatTarget* const  target 
<                             , const EscapeFlags             escapeFlags 
<                             , const UnRepFlags              unrepFlags) : 
<     fEscapeFlags(escapeFlags) 
<     , fOutEncoding(0) 
<     , fTarget(target) 
<     , fUnRepFlags(unrepFlags) 
<     , fXCoder(0) 
<  
<     , fAposRef(0) 
<     , fAmpRef(0) 
<     , fGTRef(0) 
<     , fLTRef(0) 
<     , fQuoteRef(0) 
--- 
>      fAmpLen(0), fAposLen(0), fGTLen(0), fLTLen(0), fQuoteLen(0) 
209a178,179 
>     initialize(target, escapeFlags, unrepFlags); 
> } 
210a181,185 
> void 
> XMLFormatter::initialize(XMLFormatTarget * const target, 
>                          const EscapeFlags       escapeFlags, 
>                          const UnRepFlags        unrepFlags) 
> { 
213,218c188,191 
<     fXCoder = XMLPlatformUtils::fgTransService->makeNewTranscoderFor 
<     ( 
<         fOutEncoding 
<         , resCode 
<         , kTmpBufSize 
<     ); 
--- 
>     fXCoder  
>        = XMLPlatformUtils::fgTransService->makeNewTranscoderFor(fOutEncoding, 
>                                                                 resCode, 
>                                                                 kTmpBufSize); 
220,222c193 
<     if (!fXCoder) 
<     { 
<         delete [] fOutEncoding; 
--- 
>     if (!fXCoder) { 
224,229c195,197 
<         ThrowXML1 
<         ( 
<             TranscodingException 
<             , XMLExcepts::Trans_CantCreateCvtrFor 
<             , outEncoding 
<         ); 
--- 
>         ThrowXML1(TranscodingException,  
>                   XMLExcepts::Trans_CantCreateCvtrFor, 
>                   fOutEncoding); 
233c201 
< XMLFormatter::~XMLFormatter() 
--- 
> XMLFormatter::~XMLFormatter(void) 
250a219,222 
>  
> #define getRef(x, c) \ 
>    getCharRef(c, f ## x ## Ref, g ## x ## Ref); 
>  
252,255c224,227 
< XMLFormatter::formatBuf(const   XMLCh* const    toFormat 
<                         , const unsigned int    count 
<                         , const EscapeFlags     escapeFlags 
<                         , const UnRepFlags      unrepFlags) 
--- 
> XMLFormatter::formatBuf(const XMLCh* const toFormat,  
>                         const unsigned int count, 
>                         const EscapeFlags  escapeFlags, 
>                         const UnRepFlags   unrepFlags) 
261,262c233,234 
<     const EscapeFlags actualEsc = (escapeFlags == DefaultEscape) 
<                                 ? fEscapeFlags : escapeFlags; 
--- 
>     const EscapeFlags actualEsc  
>        = (escapeFlags == DefaultEscape) ? fEscapeFlags : escapeFlags; 
265,266c237,238 
<     const UnRepFlags  actualUnRep = (unrepFlags == DefaultUnRep) 
<                                     ? fUnRepFlags : unrepFlags; 
--- 
>     const UnRepFlags actualUnRep  
>        = (unrepFlags == DefaultUnRep) ? fUnRepFlags : unrepFlags; 
299,300c271,272 
<         //  Just do a whole buffer at a time into the temp buffer, cap it 
<         //  off, and send it to the target. 
--- 
>         //  Just do a whole buffer at a time into the temp buffer, cap 
>         //  it off, and send it to the target. 
303,336c275 
<         { 
<             const unsigned int srcCount = endPtr - srcPtr; 
<             const unsigned srcChars = srcCount > kTmpBufSize ? 
<                                       kTmpBufSize : srcCount; 
<  
<             const unsigned int outBytes = fXCoder->transcodeTo 
<             ( 
<                 srcPtr 
<                 , srcChars 
<                 , fTmpBuf 
<                 , kTmpBufSize 
<                 , charsEaten 
<                 , unRepOpts 
<             ); 
<  
<             #if defined(XML_DEBUG) 
<             if ((outBytes > kTmpBufSize) 
<             ||  (charsEaten > srcCount)) 
<             { 
<                 // <TBD> The transcoder is freakin out maaaannn 
<             } 
<             #endif 
<  
<             // If we get any bytes out, then write them 
<             if (outBytes) 
<             { 
<                 fTmpBuf[outBytes] = 0; fTmpBuf[outBytes + 1] = 0; 
<                 fTmpBuf[outBytes + 2] = 0; fTmpBuf[outBytes + 3] = 0; 
<                 fTarget->writeChars(fTmpBuf, outBytes, this); 
<             } 
<  
<             // And bump up our pointer 
<             srcPtr += charsEaten; 
<         } 
--- 
>            srcPtr += handleUnEscapedChars(srcPtr, endPtr - srcPtr, unRepOpts); 
341,343c280,282 
<         //  Escap chars that require it according tot he scale flags we were 
<         //  given. For the others, try to accumulate them and format them in 
<         //  as big as bulk as we can. 
--- 
>         //  Escape chars that require it according tot he scale flags 
>         //  we were given. For the others, try to accumulate them and 
>         //  format them in as big as bulk as we can. 
361,377c300,301 
<             { 
<                 unsigned int srcCount = tmpPtr - srcPtr; 
<  
<                 while (srcCount) { 
<  
<                     const unsigned srcChars = srcCount > kTmpBufSize ? 
<                                               kTmpBufSize : srcCount; 
<  
<                     const unsigned int outBytes = fXCoder->transcodeTo 
<                     ( 
<                         srcPtr 
<                         , srcChars 
<                         , fTmpBuf 
<                         , kTmpBufSize 
<                         , charsEaten 
<                         , unRepOpts 
<                     ); 
--- 
>                srcPtr += handleUnEscapedChars(srcPtr, tmpPtr - srcPtr,  
>                                               unRepOpts); 
379,399d302 
<                     #if defined(XML_DEBUG) 
<                     if ((outBytes > kTmpBufSize) 
<                     ||  (charsEaten > srcCount)) 
<                     { 
<                         // <TBD> The transcoder is freakin out maaaannn 
<                     } 
<                     #endif 
<  
<                     // If we get any bytes out, then write them 
<                     if (outBytes) 
<                     { 
<                         fTmpBuf[outBytes] = 0; fTmpBuf[outBytes + 1] = 0; 
<                         fTmpBuf[outBytes + 2] = 0; fTmpBuf[outBytes + 3] = 0; 
<                         fTarget->writeChars(fTmpBuf, outBytes, this); 
<                     } 
<  
<                     // And bump up our pointer 
<                     srcPtr += charsEaten; 
<                     srcCount -= charsEaten; 
<                 } 
<             } 
408,409c311 
<                 switch(*srcPtr) 
<                 { 
--- 
>                 switch (*srcPtr) { 
411c313 
<                         theChars = getAmpRef(count); 
--- 
>                    theChars = getRef(Amp, count); 
416c318 
<                         theChars = getAposRef(count); 
--- 
>                    theChars = getRef(Apos, count); 
421c323 
<                         theChars = getQuoteRef(count); 
--- 
>                    theChars = getRef(Quote, count); 
426c328 
<                         theChars = getGTRef(count); 
--- 
>                    theChars = getRef(GT, count); 
431c333 
<                         theChars = getLTRef(count); 
--- 
>                    theChars = getRef(LT, count); 
444a347,378 
>  
> unsigned int 
> XMLFormatter::handleUnEscapedChars(const XMLCh *                  srcPtr, 
>                                    const unsigned int             oCount, 
>                                    const XMLTranscoder::UnRepOpts unRepOpts) 
> { 
>    unsigned int charsEaten; 
>    unsigned int count = oCount; 
>  
>    while (count) { 
>       const unsigned srcChars  
>          = count > kTmpBufSize ? kTmpBufSize : count; 
>  
>       const unsigned int outBytes  
>          = fXCoder->transcodeTo(srcPtr, srcChars,  
>                                 fTmpBuf, kTmpBufSize, 
>                                 charsEaten, unRepOpts); 
>  
>       if (outBytes) { 
>          fTmpBuf[outBytes]     = 0; fTmpBuf[outBytes + 1] = 0; 
>          fTmpBuf[outBytes + 2] = 0; fTmpBuf[outBytes + 3] = 0; 
>          fTarget->writeChars(fTmpBuf, outBytes, this); 
>       } 
>  
>       srcPtr += charsEaten; 
>       count  -= charsEaten; 
>    } 
>     
>    return oCount - count; // This should be zero. 
> } 
>  
>  
477,531c411,413 
< const XMLByte* XMLFormatter::getAposRef(unsigned int & count) 
< { 
<     if (fAposRef) 
<     { 
<         count = fAposLen; 
<         return fAposRef; 
<     } 
<  
<     unsigned int charsEaten; 
<     const unsigned int outBytes = fXCoder->transcodeTo 
<     ( 
<         gAposRef 
<         , XMLString::stringLen(gAposRef) 
<         , fTmpBuf 
<         , kTmpBufSize 
<         , charsEaten 
<         , XMLTranscoder::UnRep_Throw 
<     ); 
<     fTmpBuf[outBytes] = 0; fTmpBuf[outBytes + 1] = 0; 
<     fTmpBuf[outBytes + 2] = 0; fTmpBuf[outBytes + 3] = 0; 
<  
<     ((XMLFormatter*)this)->fAposRef = new XMLByte[outBytes + 4]; 
<     memcpy(fAposRef, fTmpBuf, outBytes + 4); 
<     count = fAposLen = outBytes; 
<     return fAposRef; 
< } 
<  
< const XMLByte* XMLFormatter::getAmpRef(unsigned int & count) 
< { 
<     if (fAmpRef) 
<     { 
<         count = fAmpLen; 
<         return fAmpRef; 
<     } 
<  
<     unsigned int charsEaten; 
<     const unsigned int outBytes = fXCoder->transcodeTo 
<     ( 
<         gAmpRef 
<         , XMLString::stringLen(gAmpRef) 
<         , fTmpBuf 
<         , kTmpBufSize 
<         , charsEaten 
<         , XMLTranscoder::UnRep_Throw 
<     ); 
<     fTmpBuf[outBytes] = 0; fTmpBuf[outBytes + 1] = 0; 
<     fTmpBuf[outBytes + 2] = 0; fTmpBuf[outBytes + 3] = 0; 
<  
<     ((XMLFormatter*)this)->fAmpRef = new XMLByte[outBytes + 4]; 
<     memcpy(fAmpRef, fTmpBuf, outBytes + 4); 
<     count = fAmpLen = outBytes; 
<     return fAmpRef; 
< } 
<  
< const XMLByte* XMLFormatter::getGTRef(unsigned int & count) 
--- 
> const XMLByte* XMLFormatter::getCharRef(unsigned int & count, 
>                                         XMLByte *      ref, 
>                                         const XMLCh *  stdRef) 
533,538c415 
<     if (fGTRef) 
<     { 
<         count = fGTLen; 
<         return fGTRef; 
<     } 
<  
--- 
>    if (!ref) { 
540,564c417,420 
<     const unsigned int outBytes = fXCoder->transcodeTo 
<     ( 
<         gGTRef 
<         , XMLString::stringLen(gGTRef) 
<         , fTmpBuf 
<         , kTmpBufSize 
<         , charsEaten 
<         , XMLTranscoder::UnRep_Throw 
<     ); 
<     fTmpBuf[outBytes] = 0; fTmpBuf[outBytes + 1] = 0; 
<     fTmpBuf[outBytes + 2] = 0; fTmpBuf[outBytes + 3] = 0; 
<  
<     ((XMLFormatter*)this)->fGTRef = new XMLByte[outBytes + 4]; 
<     memcpy(fGTRef, fTmpBuf, outBytes + 4); 
<     count = fGTLen = outBytes; 
<     return fGTRef; 
< } 
<  
< const XMLByte* XMLFormatter::getLTRef(unsigned int & count) 
< { 
<     if (fLTRef) 
<     { 
<         count = fLTLen; 
<         return fLTRef; 
<     } 
--- 
>       const unsigned int outBytes  
>          = fXCoder->transcodeTo(stdRef, XMLString::stringLen(stdRef), 
>                                 fTmpBuf, kTmpBufSize, charsEaten, 
>                                 XMLTranscoder::UnRep_Throw); 
566,575d421 
<     unsigned int charsEaten; 
<     const unsigned int outBytes = fXCoder->transcodeTo 
<     ( 
<         gLTRef 
<         , XMLString::stringLen(gLTRef) 
<         , fTmpBuf 
<         , kTmpBufSize 
<         , charsEaten 
<         , XMLTranscoder::UnRep_Throw 
<     ); 
579,590c425,427 
<     ((XMLFormatter*)this)->fLTRef = new XMLByte[outBytes + 4]; 
<     memcpy(fLTRef, fTmpBuf, outBytes + 4); 
<     count = fLTLen = outBytes; 
<     return fLTRef; 
< } 
<  
< const XMLByte* XMLFormatter::getQuoteRef(unsigned int & count) 
< { 
<     if (fQuoteRef) 
<     { 
<         count = fQuoteLen; 
<         return fQuoteRef; 
--- 
>       ref = new XMLByte[outBytes + 4]; 
>       memcpy(ref, fTmpBuf, outBytes + 4); 
>       count = outBytes; 
593,609c430 
<     unsigned int charsEaten; 
<     const unsigned int outBytes = fXCoder->transcodeTo 
<     ( 
<         gQuoteRef 
<         , XMLString::stringLen(gQuoteRef) 
<         , fTmpBuf 
<         , kTmpBufSize 
<         , charsEaten 
<         , XMLTranscoder::UnRep_Throw 
<     ); 
<     fTmpBuf[outBytes] = 0; fTmpBuf[outBytes + 1] = 0; 
<     fTmpBuf[outBytes + 2] = 0; fTmpBuf[outBytes + 3] = 0; 
<  
<     ((XMLFormatter*)this)->fQuoteRef = new XMLByte[outBytes + 4]; 
<     memcpy(fQuoteRef, fTmpBuf, outBytes + 4); 
<     count = fQuoteLen = outBytes; 
<     return fQuoteRef; 
--- 
>    return ref; 
661c481 
<             // 
--- 
>  
Index: framework/XMLFormatter.hpp 
=================================================================== 
RCS file: /home/cvspublic/xml-xerces/c/src/xercesc/framework/XMLFormatter.hpp,v 
retrieving revision 1.7 
diff -B -b -r1.7 XMLFormatter.hpp 
401,405c401,411 
<     const XMLByte* getAposRef(unsigned int & count); 
<     const XMLByte* getAmpRef(unsigned int & count); 
<     const XMLByte* getGTRef(unsigned int & count); 
<     const XMLByte* getLTRef(unsigned int & count); 
<     const XMLByte* getQuoteRef(unsigned int & count); 
--- 
>     const XMLByte* getCharRef(unsigned int & count, 
>                               XMLByte *      ref, 
>                               const XMLCh *  stdRef); 
>  
>     void initialize(XMLFormatTarget* const target, 
>                     const EscapeFlags      escapeFlags, 
>                     const UnRepFlags       unrepFlags); 
>  
>    unsigned int handleUnEscapedChars(const XMLCh *                  srcPtr, 
>                                      unsigned int                   count, 
>                                      const XMLTranscoder::UnRepOpts unRepOpts);

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to