Skip to content
Snippets Groups Projects
Commit 333b2dc7 authored by PeiYong Zhang's avatar PeiYong Zhang
Browse files

data member changed, reset() added.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@173798 13f79535-47bb-0310-9956-ffa450edef68
parent afac806d
No related branches found
No related tags found
No related merge requests found
...@@ -57,6 +57,9 @@ ...@@ -57,6 +57,9 @@
/* /*
* $Id$ * $Id$
* $Log$ * $Log$
* Revision 1.2 2002/06/05 15:47:13 peiyongz
* data member changed, reset() added.
*
* Revision 1.1 2002/05/28 22:40:46 peiyongz * Revision 1.1 2002/05/28 22:40:46 peiyongz
* DOM3 Save Interface: DOMWriter/DOMWriterFilter * DOM3 Save Interface: DOMWriter/DOMWriterFilter
* *
...@@ -66,14 +69,11 @@ ...@@ -66,14 +69,11 @@
#include <xercesc/util/XMLString.hpp> #include <xercesc/util/XMLString.hpp>
MemBufFormatTarget::MemBufFormatTarget() MemBufFormatTarget::MemBufFormatTarget()
:fDataBuf(0)
{ {
fDataBuf = new XMLBuffer();
} }
MemBufFormatTarget::~MemBufFormatTarget() MemBufFormatTarget::~MemBufFormatTarget()
{ {
delete fDataBuf;
} }
void MemBufFormatTarget::writeChars(const XMLByte* const toWrite void MemBufFormatTarget::writeChars(const XMLByte* const toWrite
...@@ -83,21 +83,26 @@ void MemBufFormatTarget::writeChars(const XMLByte* const toWrite ...@@ -83,21 +83,26 @@ void MemBufFormatTarget::writeChars(const XMLByte* const toWrite
// //
// The toWrite may not be null terminated, // The toWrite may not be null terminated,
// so we need to do some extra work here // so we need to do some extra work here
// //
XMLByte lastChar = toWrite[count]; // preserve the last char XMLByte lastChar = toWrite[count]; // preserve the last char
XMLByte* tmpBuf = (XMLByte *)toWrite; XMLByte* tmpBuf = (XMLByte *)toWrite;
tmpBuf[count] = 0; tmpBuf[count] = 0;
XMLCh* transBuf = XMLString::transcode((char *) tmpBuf); XMLCh* transBuf = XMLString::transcode((char *) tmpBuf);
fDataBuf->append(transBuf, XMLString::stringLen(transBuf)); fDataBuf.append(transBuf, XMLString::stringLen(transBuf));
delete[] transBuf; delete[] transBuf;
tmpBuf[count] = lastChar; // restore the last char tmpBuf[count] = lastChar; // restore the last char
} }
XMLCh* MemBufFormatTarget::getString() const XMLCh* MemBufFormatTarget::getString() const
{ {
return XMLString::replicate(fDataBuf->getRawBuffer()); return XMLString::replicate(fDataBuf.getRawBuffer());
}
void MemBufFormatTarget::reset()
{
fDataBuf.reset();
} }
...@@ -57,6 +57,9 @@ ...@@ -57,6 +57,9 @@
/* /*
* $Id$ * $Id$
* $Log$ * $Log$
* Revision 1.2 2002/06/05 15:47:13 peiyongz
* data member changed, reset() added.
*
* Revision 1.1 2002/05/28 22:40:46 peiyongz * Revision 1.1 2002/05/28 22:40:46 peiyongz
* DOM3 Save Interface: DOMWriter/DOMWriterFilter * DOM3 Save Interface: DOMWriter/DOMWriterFilter
* *
...@@ -88,21 +91,33 @@ public: ...@@ -88,21 +91,33 @@ public:
// Getter // Getter
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
/** @name getString */ /** @name getString */
/**
* caller owns the returned string and is accountable
* for the memory release
*/
//@{ //@{
/**
* Returned the internal string buffer.
*
* Caller owns the returned string and is accountable
* for the memory release
*/
XMLCh* getString() const; XMLCh* getString() const;
//@}
/** @name reset */
//@{
/**
* Reset the internal string buffer.
*
*/
void reset();
//@}
private: private:
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Unimplemented methods. // Unimplemented methods.
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
MemBufFormatTarget(const MemBufFormatTarget& other); MemBufFormatTarget(const MemBufFormatTarget&);
void operator=(const MemBufFormatTarget& rhs); MemBufFormatTarget& operator=(const MemBufFormatTarget&);
XMLBuffer *fDataBuf; XMLBuffer fDataBuf;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment