activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r551182 - /activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/DataInputStream.cpp
Date Wed, 27 Jun 2007 14:50:10 GMT
Author: tabish
Date: Wed Jun 27 07:50:07 2007
New Revision: 551182

URL: http://svn.apache.org/viewvc?view=rev&rev=551182
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103

Building Decaf lib

Modified:
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/DataInputStream.cpp

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/DataInputStream.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/DataInputStream.cpp?view=diff&rev=551182&r1=551181&r2=551182
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/DataInputStream.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/io/DataInputStream.cpp Wed Jun 27
07:50:07 2007
@@ -73,6 +73,7 @@
 
         return read;
     }
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
     DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
@@ -87,6 +88,7 @@
         this->readFully( ( unsigned char* )&value, 0, sizeof( char ) );
         return (char)( value != 0 );
     }
+    DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
@@ -100,6 +102,7 @@
         this->readFully( ( unsigned char* )&value, 0, sizeof( char ) );
         return (char)( value );
     }
+    DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
@@ -113,6 +116,7 @@
         this->readFully( ( unsigned char* )&value, 0, sizeof( unsigned char ) );
         return (char)( value );
     }
+    DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
@@ -124,6 +128,7 @@
         this->readFully( ( unsigned char* )&value, 0, sizeof( char ) );
         return (char)( value );
     }
+    DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
@@ -140,6 +145,7 @@
 
         return value;
     }
+    DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
@@ -158,6 +164,7 @@
 
         return value;
     }
+    DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
@@ -177,6 +184,7 @@
 
         return value;
     }
+    DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
@@ -190,6 +198,7 @@
         memcpy( &value, &lvalue, sizeof( unsigned long long ) );
         return value;
     }
+    DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
@@ -203,6 +212,7 @@
         memcpy( &value, &lvalue, sizeof( unsigned int ) );
         return value;
     }
+    DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
@@ -228,6 +238,7 @@
 
         return value;
     }
+    DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
@@ -236,23 +247,34 @@
 std::string DataInputStream::readString()
     throw ( io::IOException, io::EOFException ) {
     try {
-        std::string retVal;
-        char temp = 0;
 
-        while( true ){
-            temp = readChar();
+        size_t size = 1024;
+        std::vector<char> buffer;
+        buffer.resize( size );
+        size_t pos = 0;
 
-            // if null is found we are done.
-            if( temp == '\0' ){
+        while( true ) {
+
+            if( inputStream->read( (unsigned char*)( &buffer[pos] ), 1 ) == (size_t)-1
) {
+                throw EOFException(
+                    __FILE__, __LINE__,
+                    "DataInputStream::readString - Reached EOF" );
+            }
+
+            // if null is found we are done
+            if( buffer[pos] == '\0' ){
                 break;
             }
 
-            // Append no matter what
-            retVal += temp;
+            // Resize to hold more if we exceed current size
+            if( ++pos > size ) {
+                buffer.resize( (size *= 2) );
+            }
         }
 
-        return retVal;
+        return &buffer[0];
     }
+    DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
@@ -267,6 +289,7 @@
         readFully( (unsigned char*)buffer.c_str(), 0, len );
         return buffer;
     }
+    DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
@@ -277,6 +300,7 @@
     try {
         this->readFully( &buffer[0], 0, buffer.size() );
     }
+    DECAF_CATCH_RETHROW( EOFException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }
@@ -309,6 +333,7 @@
             n += count;
         }
     }
+    DECAF_CATCH_RETHROW( IndexOutOfBoundsException )
     DECAF_CATCH_RETHROW( NullPointerException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
@@ -328,6 +353,7 @@
 
         return total;
     }
+    DECAF_CATCH_RETHROW( UnsupportedOperationException )
     DECAF_CATCH_RETHROW( IOException )
     DECAF_CATCHALL_THROW( IOException )
 }



Mime
View raw message