dbertoni 00/06/28 10:52:39
Modified: c/src/XercesPlatformSupport XercesStdTextOutputStream.cpp
XercesTextOutputStream.cpp
XercesTextOutputStream.hpp
Log:
Added better buffer size control and made sure that std::err is not buffered.
Revision Changes Path
1.6 +11 -3
xml-xalan/c/src/XercesPlatformSupport/XercesStdTextOutputStream.cpp
Index: XercesStdTextOutputStream.cpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/XercesPlatformSupport/XercesStdTextOutputStream.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XercesStdTextOutputStream.cpp 2000/03/20 14:33:39 1.5
+++ XercesStdTextOutputStream.cpp 2000/06/28 17:52:36 1.6
@@ -58,11 +58,10 @@
#include "XercesStdTextOutputStream.hpp"
-#include <strstream>
-#if defined(__GNUC__)
#include <cerrno>
-#endif
+#include <iostream>
+#include <strstream>
@@ -78,6 +77,15 @@
XercesTextOutputStream(),
m_outputStream(theOutputStream)
{
+ // This will make sure that cerr is not buffered...
+#if defined(XALAN_NO_NAMESPACES)
+ if (&m_outputStream == &cerr)
+#else
+ if (&m_outputStream == &std::cerr)
+#endif
+ {
+ setBufferSize(0);
+ }
}
1.5 +18 -7
xml-xalan/c/src/XercesPlatformSupport/XercesTextOutputStream.cpp
Index: XercesTextOutputStream.cpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/XercesPlatformSupport/XercesTextOutputStream.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XercesTextOutputStream.cpp 2000/05/03 18:42:43 1.4
+++ XercesTextOutputStream.cpp 2000/06/28 17:52:36 1.5
@@ -68,11 +68,9 @@
-const XercesTextOutputStream::BufferType::size_type
XercesTextOutputStream::s_bufferSize = 512;
-
-
-
-XercesTextOutputStream::XercesTextOutputStream()
+XercesTextOutputStream::XercesTextOutputStream(BufferType::size_type
theBufferSize) :
+ m_buffer(),
+ m_bufferSize(theBufferSize)
{
}
@@ -117,12 +115,12 @@
{
assert(theBuffer != 0);
- if (theBufferLength + m_buffer.size() > s_bufferSize)
+ if (theBufferLength + m_buffer.size() > m_bufferSize)
{
flushBuffer();
}
- if (theBufferLength > s_bufferSize)
+ if (theBufferLength > m_bufferSize)
{
doWrite(theBuffer);
}
@@ -199,6 +197,19 @@
writeData(theTranscodedString.get(),
strlen(theTranscodedString.get()));
+}
+
+
+
+void
+XercesTextOutputStream::setBufferSize(BufferType::size_type
theBufferSize)
+{
+ m_bufferSize = theBufferSize;
+
+ if (m_buffer.size() > m_bufferSize)
+ {
+ flushBuffer();
+ }
}
1.4 +13 -6
xml-xalan/c/src/XercesPlatformSupport/XercesTextOutputStream.hpp
Index: XercesTextOutputStream.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/XercesPlatformSupport/XercesTextOutputStream.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XercesTextOutputStream.hpp 2000/04/25 19:48:56 1.3
+++ XercesTextOutputStream.hpp 2000/06/28 17:52:37 1.4
@@ -113,10 +113,20 @@
const XalanDOMChar* theBuffer,
unsigned long theBufferLength);
+ enum
+ {
+ eDefaultBufferSize = 512
+ };
+
+ typedef std::vector<XalanDOMChar> BufferType;
+
+ virtual void
+ setBufferSize(BufferType::size_type theBufferSize);
+
protected:
explicit
- XercesTextOutputStream();
+ XercesTextOutputStream(BufferType::size_type theBufferSize =
eDefaultBufferSize);
virtual void
writeData(const char* theBuffer,
@@ -139,13 +149,10 @@
void
doWrite(const XalanDOMChar* theBuffer);
-
- // Data members...
- typedef std::vector<XalanDOMChar> BufferType;
- BufferType
m_buffer;
+ BufferType m_buffer;
- static const BufferType::size_type s_bufferSize;
+ BufferType::size_type m_bufferSize;
};