activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r476684 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal: BaseDataStreamMarshaller.cpp BaseDataStreamMarshaller.h
Date Sun, 19 Nov 2006 01:51:24 GMT
Author: tabish
Date: Sat Nov 18 17:51:23 2006
New Revision: 476684

URL: http://svn.apache.org/viewvc?view=rev&rev=476684
Log:
Code Submit for planned Openwire Support

Modified:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.h

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp?view=diff&rev=476684&r1=476683&r2=476684
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp
Sat Nov 18 17:51:23 2006
@@ -683,6 +683,81 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+std::vector<unsigned char> BaseDataStreamMarshaller::tightUnmarshalByteArray( 
+    io::DataInputStream* dataIn, 
+    utils::BooleanStream* bs ) 
+        throw ( io::IOException ) {
+
+    try{
+        
+        std::vector<unsigned char> data;
+                
+        if( bs->readBoolean() ) {
+            int size = dataIn->readInt();
+            data.resize( size );
+            dataIn->readFully( data );
+        }
+        
+        return data;
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::vector<unsigned char> BaseDataStreamMarshaller::looseUnmarshalByteArray( 
+    io::DataInputStream* dataIn ) 
+        throw ( io::IOException ) {  
+
+    try{
+        int size = dataIn->readInt();
+        std::vector<unsigned char> data;
+        data.resize( size );
+        dataIn->readFully( data );
+        return data;
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::vector<unsigned char> BaseDataStreamMarshaller::tightUnmarshalConstByteArray(

+    io::DataInputStream* dataIn, 
+    utils::BooleanStream* bs, 
+    int size ) 
+        throw ( io::IOException ) {
+         
+    try{
+        std::vector<unsigned char> data;
+        data.resize( size );
+        dataIn->readFully( data );
+        return data;
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::vector<unsigned char> BaseDataStreamMarshaller::looseUnmarshalConstByteArray(

+    io::DataInputStream* dataIn, 
+    int size ) 
+        throw ( io::IOException ) { 
+
+    try{
+        std::vector<unsigned char> data;
+        data.resize( size );
+        dataIn->readFully( data );
+        return data;
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
 std::string BaseDataStreamMarshaller::toString( commands::MessageId* id )
 {
     if( id == NULL ) return "";

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.h?view=diff&rev=476684&r1=476683&r2=476684
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.h
(original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.h
Sat Nov 18 17:51:23 2006
@@ -400,8 +400,7 @@
          */
         virtual std::vector<unsigned char> tightUnmarshalByteArray( 
             io::DataInputStream* dataIn, 
-            utils::BooleanStream* bs ) throw ( io::IOException )
-                { return std::vector<unsigned char>(); }
+            utils::BooleanStream* bs ) throw ( io::IOException );
 
         /**
          * Loose Unmarshal an array of char
@@ -410,8 +409,7 @@
          * @throws IOException if an error occurs.
          */
         virtual std::vector<unsigned char> looseUnmarshalByteArray( 
-            io::DataInputStream* dataIn ) throw ( io::IOException )  
-            { return std::vector<unsigned char>(); }
+            io::DataInputStream* dataIn ) throw ( io::IOException );
 
         /**
          * Tight Unmarshal a fixed size array from that data input stream
@@ -425,9 +423,7 @@
         virtual std::vector<unsigned char> tightUnmarshalConstByteArray( 
             io::DataInputStream* dataIn, 
             utils::BooleanStream* bs, 
-            int size ) throw ( io::IOException ) { 
-                return std::vector<unsigned char>(); 
-        }
+            int size ) throw ( io::IOException );
 
         /**
          * Tight Unmarshal a fixed size array from that data input stream
@@ -440,8 +436,7 @@
          */
         virtual std::vector<unsigned char> looseUnmarshalConstByteArray( 
             io::DataInputStream* dataIn, 
-            int size ) throw ( io::IOException ) 
-        { return std::vector<unsigned char>(); }
+            int size ) throw ( io::IOException );
         
         /**
          * Tight Unarshall the Error object
@@ -459,26 +454,26 @@
         /**
          * Tight Marshall the Error object
          * @param wireFormat - The OpenwireFormat properties 
-         * @param error - Error to Marshal
+         * @param data - Error to Marshal
          * @param bs - boolean stream to marshal to.
          * @returns size of the marshalled data
          * @throws IOException if an error occurs.
          */
         virtual int tightMarshalBrokerError1( OpenWireFormat* wireFormat, 
-                                              commands::DataStructure* error, 
+                                              commands::DataStructure* data, 
                                               utils::BooleanStream* bs ) 
                                                     throw ( io::IOException );
                                               
         /**
          * Tight Marshall the Error object
          * @param wireFormat - The OpenwireFormat properties 
-         * @param error - Error to Marshal
+         * @param data - Error to Marshal
          * @param dataOut - stream to write marshalled data to
          * @param bs - boolean stream to marshal to.
          * @throws IOException if an error occurs.
          */
         virtual void tightMarshalBrokerError2( OpenWireFormat* wireFormat, 
-                                               commands::DataStructure* error, 
+                                               commands::DataStructure* data, 
                                                io::DataOutputStream* dataOut, 
                                                utils::BooleanStream* bs )
                                                     throw ( io::IOException );
@@ -497,34 +492,117 @@
         /**
          * Tight Marshall the Error object
          * @param wireFormat - The OpenwireFormat properties 
-         * @param error - Error to Marshal
+         * @param data - Error to Marshal
          * @param dataOut - stream to write marshalled data to
          * @throws IOException if an error occurs.
          */
         virtual void looseMarshalBrokerError( OpenWireFormat* wireFormat, 
-                                              commands::DataStructure* error, 
+                                              commands::DataStructure* data, 
                                               io::DataOutputStream* dataOut ) 
                                                   throw ( io::IOException );
         
+        /**
+         * Tightly Marshal an array of DataStructure objects to the provided
+         * boolean stream, and return the size that the tight marshalling is
+         * going to take.
+         * @param wireFormat - The OpenwireFormat properties
+         * @param objects - array of DataStructure object pointers.
+         * @param bs - boolean stream to marshal to.
+         * @returns size of the marshalled data
+         * @throws IOException if an error occurs.
+         */ 
         template<typename T>
         int tightMarshalObjectArray1( OpenWireFormat* wireFormat, 
-                                      std::vector<T*>, 
+                                      std::vector<T*> objects, 
                                       utils::BooleanStream* bs )
                                         throw ( io::IOException )
-        { return 0; }
+        {
+            try{ 
+                if( !objects.empty() )
+                {
+                    int rc = 0;
+                    bs->writeBoolean( true );
+                    rc += 2;
+                    for( int i = 0; i < objects.size(); ++i ) {
+                        rc += tightMarshalNestedObject1( 
+                                wireFormat, objects[i], bs );
+                    }
+                    return rc;
+                    
+                } else {
+                    bs->writeBoolean( false );
+                    return 0;
+                }
+            }
+            AMQ_CATCH_RETHROW( io::IOException )
+            AMQ_CATCH_EXCEPTION_CONVERT( exceptions::ActiveMQException, io::IOException )
+            AMQ_CATCHALL_THROW( io::IOException )
+        }
         
+        /**
+         * Tightly Marshal an array of DataStructure objects to the provided
+         * boolean stream and data output stream
+         * @param wireFormat - The OpenwireFormat properties
+         * @param objects - array of DataStructure object pointers.
+         * @param dataOut - stream to write marshalled data to
+         * @param bs - boolean stream to marshal to.
+         * @returns size of the marshalled data
+         * @throws IOException if an error occurs.
+         */ 
         template<typename T>
         void tightMarshalObjectArray2( OpenWireFormat* wireFormat, 
-                                       std::vector<T*>, 
+                                       std::vector<T*> objects, 
                                        io::DataOutputStream* dataOut, 
                                        utils::BooleanStream* bs ) 
-                                        throw ( io::IOException ) {}
+                                        throw ( io::IOException ) {
+                                            
+            try {
+
+                if( bs->readBoolean() ) {
+                    
+                    dataOut->writeShort( (short)objects.size() );
+                    for( int i = 0; i < objects.size(); ++i ) {
+                        tightMarshalNestedObject2(
+                            wireFormat, objects[i], dataOut, bs );
+                    }
+                }
+            }
+            AMQ_CATCH_RETHROW( io::IOException )
+            AMQ_CATCH_EXCEPTION_CONVERT( exceptions::ActiveMQException, io::IOException )
+            AMQ_CATCHALL_THROW( io::IOException )
+        }
 
+        /**
+         * Loosely Marshal an array of DataStructure objects to the provided
+         * boolean stream and data output stream
+         * @param wireFormat - The OpenwireFormat properties
+         * @param objects - array of DataStructure object pointers.
+         * @param dataOut - stream to write marshalled data to
+         * @returns size of the marshalled data
+         * @throws IOException if an error occurs.
+         */ 
         template<typename T>
         void looseMarshalObjectArray( OpenWireFormat* wireFormat, 
-                                      std::vector<T*>, 
+                                      std::vector<T*> objects, 
                                       io::DataOutputStream* dataOut ) 
-                                        throw ( io::IOException ) {}
+                                        throw ( io::IOException ) {
+
+            try {
+
+                dataOut->writeBoolean( !objects.empty() );
+                if( !objects.empty() ) {
+                    
+                    dataOut->writeShort( (short)objects.size() );
+                    for( int i = 0; i < objects.size(); ++i ) {
+                        looseMarshalNestedObject(
+                            wireFormat, objects[i], dataOut );
+                    }
+                }
+            }
+            AMQ_CATCH_RETHROW( io::IOException )
+            AMQ_CATCH_EXCEPTION_CONVERT( exceptions::ActiveMQException, io::IOException )
+            AMQ_CATCHALL_THROW( io::IOException )
+        }
                          
     protected:
 



Mime
View raw message