Author: tabish
Date: Sat Nov 3 15:34:12 2007
New Revision: 591702
URL: http://svn.apache.org/viewvc?rev=591702&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103
http://issues.apache.org/activemq/browse/AMQCPP-136
Modified:
activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.cpp
Modified:
activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.cpp?rev=591702&r1=591701&r2=591702&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.cpp
(original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/io/DataOutputStream.cpp
Sat Nov 3 15:34:12 2007
@@ -24,20 +24,25 @@
////////////////////////////////////////////////////////////////////////////////
DataOutputStream::DataOutputStream( OutputStream* outputStream, bool own )
- : FilterOutputStream( outputStream, own )
-{
+ : FilterOutputStream( outputStream, own ) {
// Init the written count
written = 0;
}
////////////////////////////////////////////////////////////////////////////////
-DataOutputStream::~DataOutputStream()
-{
+DataOutputStream::~DataOutputStream() {
}
////////////////////////////////////////////////////////////////////////////////
void DataOutputStream::write( const unsigned char c ) throw ( IOException ) {
try {
+
+ if( outputStream == NULL ) {
+ throw IOException(
+ __FILE__, __LINE__,
+ "DataOutputStream::write - Base stream is Null");
+ }
+
outputStream->write( c );
written++;
}
@@ -56,6 +61,12 @@
return;
}
+ if( outputStream == NULL ) {
+ throw IOException(
+ __FILE__, __LINE__,
+ "DataOutputStream::write - Base stream is Null");
+ }
+
outputStream->write( &buffer[0], buffer.size() );
written += buffer.size();
}
@@ -68,6 +79,17 @@
throw ( IOException ) {
try {
+
+ if( len == 0 ) {
+ return;
+ }
+
+ if( outputStream == NULL ) {
+ throw IOException(
+ __FILE__, __LINE__,
+ "DataOutputStream::write - Base stream is Null");
+ }
+
outputStream->write( buffer, len );
written += len;
}
@@ -82,6 +104,17 @@
{
try {
+
+ if( len == 0 ) {
+ return;
+ }
+
+ if( outputStream == NULL ) {
+ throw IOException(
+ __FILE__, __LINE__,
+ "DataOutputStream::write - Base stream is Null");
+ }
+
outputStream->write( buffer+offset, len );
written += len;
}
@@ -95,6 +128,12 @@
unsigned char ivalue = 0;
value == true ? ivalue = 1 : ivalue = 0;
+ if( outputStream == NULL ) {
+ throw IOException(
+ __FILE__, __LINE__,
+ "DataOutputStream::write - Base stream is Null");
+ }
+
outputStream->write( ivalue );
written++;
}
@@ -105,6 +144,13 @@
////////////////////////////////////////////////////////////////////////////////
void DataOutputStream::writeByte( unsigned char value ) throw ( IOException ) {
try {
+
+ if( outputStream == NULL ) {
+ throw IOException(
+ __FILE__, __LINE__,
+ "DataOutputStream::write - Base stream is Null");
+ }
+
outputStream->write( value );
written++;
}
@@ -115,6 +161,13 @@
////////////////////////////////////////////////////////////////////////////////
void DataOutputStream::writeChar( char value ) throw ( IOException ) {
try {
+
+ if( outputStream == NULL ) {
+ throw IOException(
+ __FILE__, __LINE__,
+ "DataOutputStream::write - Base stream is Null");
+ }
+
outputStream->write( value );
written++;
}
@@ -125,6 +178,13 @@
////////////////////////////////////////////////////////////////////////////////
void DataOutputStream::writeShort( short value ) throw ( IOException ) {
try {
+
+ if( outputStream == NULL ) {
+ throw IOException(
+ __FILE__, __LINE__,
+ "DataOutputStream::write - Base stream is Null");
+ }
+
unsigned char buffer[sizeof(value)];
buffer[0] = (value & 0xFF00) >> 8;
@@ -142,6 +202,13 @@
throw ( IOException )
{
try {
+
+ if( outputStream == NULL ) {
+ throw IOException(
+ __FILE__, __LINE__,
+ "DataOutputStream::write - Base stream is Null");
+ }
+
unsigned char buffer[sizeof(value)];
buffer[0] = (value & 0xFF00) >> 8;
@@ -157,6 +224,13 @@
////////////////////////////////////////////////////////////////////////////////
void DataOutputStream::writeInt( int value ) throw ( IOException ) {
try {
+
+ if( outputStream == NULL ) {
+ throw IOException(
+ __FILE__, __LINE__,
+ "DataOutputStream::write - Base stream is Null");
+ }
+
unsigned char buffer[sizeof(value)];
buffer[0] = (value & 0xFF000000) >> 24;
@@ -174,6 +248,13 @@
////////////////////////////////////////////////////////////////////////////////
void DataOutputStream::writeLong( long long value ) throw ( IOException ) {
try {
+
+ if( outputStream == NULL ) {
+ throw IOException(
+ __FILE__, __LINE__,
+ "DataOutputStream::write - Base stream is Null");
+ }
+
unsigned char buffer[sizeof(value)];
buffer[0] = (unsigned char)((value & 0xFF00000000000000ULL) >> 56);
@@ -217,6 +298,11 @@
////////////////////////////////////////////////////////////////////////////////
void DataOutputStream::writeBytes( const std::string& value ) throw (
IOException ) {
try {
+
+ if( value.length() == 0 ) {
+ return;
+ }
+
// do not add one so that we don't write the NULL
this->write( (const unsigned char*)value.c_str(), value.length() );
}
@@ -227,6 +313,11 @@
////////////////////////////////////////////////////////////////////////////////
void DataOutputStream::writeChars( const std::string& value ) throw (
IOException ) {
try {
+
+ if( value.length() == 0 ) {
+ return;
+ }
+
// add one so that we write the NULL
this->write( (const unsigned char*)value.c_str(), value.length() + 1 );
}
@@ -237,6 +328,11 @@
////////////////////////////////////////////////////////////////////////////////
void DataOutputStream::writeUTF( const std::string& value ) throw (
IOException ) {
try {
+
+ if( value.length() == 0 ) {
+ return;
+ }
+
this->writeUnsignedShort( (unsigned short)value.length() );
this->write( (const unsigned char*)value.c_str(), value.length() );
}