You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2006/07/06 00:27:47 UTC

svn commit: r419365 [4/25] - in /incubator/activemq/trunk: activemq-core/src/main/java/org/apache/activemq/thread/ activemq-core/src/test/java/org/apache/activemq/openwire/v1/ activemq-cpp/src/main/activemq/concurrent/ activemq-cpp/src/main/activemq/co...

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp?rev=419365&r1=419364&r2=419365&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp Wed Jul  5 15:27:34 2006
@@ -1,340 +1,340 @@
-/*
- * Copyright 2006 The Apache Software Foundation or its licensors, as
- * applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "StompCommandReader.h"
-
-#include <activemq/connector/stomp/commands/CommandConstants.h>
-#include <activemq/concurrent/Thread.h>
-
-using namespace std;
-using namespace activemq;
-using namespace activemq::concurrent;
-using namespace activemq::connector;
-using namespace activemq::connector::stomp;
-using namespace activemq::transport;
-using namespace activemq::io;
-using namespace activemq::exceptions;
-
-////////////////////////////////////////////////////////////////////////////////
-StompCommandReader::StompCommandReader(void)
-{
-    inputStream = NULL;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-StompCommandReader::StompCommandReader(InputStream* is)
-{
-    inputStream = is;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-Command* StompCommandReader::readCommand(void) 
-    throw (CommandIOException)
-{
-    try
-    {
-        // Create a new Frame for reading to.
-        StompFrame* frame = new StompFrame();
-       
-        // Read the command into the frame.
-        readStompCommand( *frame );
-       
-        // Read the headers.
-        readStompHeaders( *frame );
-       
-        // Read the body.
-        readStompBody( *frame );
-       
-        // Return the Command, caller must delete it.
-        return marshaler.marshal( frame );
-    }
-    AMQ_CATCH_RETHROW( CommandIOException )
-    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, CommandIOException )
-    AMQ_CATCHALL_THROW( CommandIOException )
-}
-
-////////////////////////////////////////////////////////////////////////////////
-void StompCommandReader::readStompCommand( StompFrame& frame ) 
-   throw ( StompConnectorException )
-{  
-	while( true ) 
-	{
-	    // Clean up the mess.
-	    buffer.clear();
-
-	    // Read the command;
-	    readStompHeaderLine();
-
-        // Ignore all white space before the command.
-        int offset=-1;
-        for( size_t ix = 0; ix < buffer.size()-1; ++ix )
-        {
-        	// Find the first non space character
-        	char b = buffer[ix];
-            switch ( b ) 
-            {
-            	case '\n':
-            	case '\t':
-            	case '\r':
-            		break;
-            	  
-	            default:
-		            offset = ix;
-		            break; 
-            } 
-            
-	        if( offset != -1 )
-	        {
-	        	break;
-	        }            
-        }
-	
-	    if( offset >= 0 )
-	    {
-		    // Set the command in the frame - copy the memory.
-		    frame.setCommand( reinterpret_cast<char*>(&buffer[offset]) );
-			break;
-	    }
-	
-	}
-    // Clean up the mess.
-    buffer.clear();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-void StompCommandReader::readStompHeaders( StompFrame& frame ) 
-   throw (StompConnectorException)
-{
-    // Read the command;
-    bool endOfHeaders = false;
-
-    while( !endOfHeaders )
-    {
-        // Clean up the mess.
-        buffer.clear();
-
-        // Read in the next header line.
-        int numChars = readStompHeaderLine();
-
-        if( numChars == 0 )
-        {
-            // should never get here
-            throw StompConnectorException(
-                __FILE__, __LINE__,
-                "StompCommandReader::readStompHeaders: no characters read" );
-        }
-      
-        // Check for an empty line to demark the end of the header section.
-        // if its not the end then we have a header to process, so parse it.
-        if( numChars == 1 && buffer[0] == '\0' )
-        {
-            endOfHeaders = true;
-        }
-        else
-        {
-            // Search through this line to separate the key/value pair.
-            for( size_t ix = 0; ix < buffer.size(); ++ix )
-            {
-                // If found the key/value separator...
-                if( buffer[ix] == ':' )
-                {
-                    // Null-terminate the key.
-                    buffer[ix] = '\0'; 
-
-                    const char* key = reinterpret_cast<char*>(&buffer[0]);
-                    const char* value = reinterpret_cast<char*>(&buffer[ix+1]);
-               
-                    // Assign the header key/value pair.
-                    frame.getProperties().setProperty(key, value);
-               
-                    // Break out of the for loop.
-                    break;
-                }
-            }
-        }
-    }
-
-    // Clean up the mess.
-    buffer.clear();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-int StompCommandReader::readStompHeaderLine(void) 
-    throw (StompConnectorException)
-{
-    int count = 0;
-  
-    while( true )
-    {
-        // Read the next char from the stream.
-        buffer.push_back( inputStream->read() );
-      
-        // Increment the position pointer.
-        count++;
-      
-        // If we reached the line terminator, return the total number
-        // of characters read.
-        if( buffer[count-1] == '\n' )
-        {
-            // Overwrite the line feed with a null character. 
-            buffer[count-1] = '\0';
-         
-            return count;
-        }
-    }
-   
-    // If we get here something bad must have happened.
-    throw StompConnectorException(
-        __FILE__, __LINE__,
-        "StompCommandReader::readStompHeaderLine: "
-        "Unrecoverable, error condition");
-}
-
-////////////////////////////////////////////////////////////////////////////////
-void StompCommandReader::readStompBody( StompFrame& frame ) 
-   throw ( StompConnectorException )
-{
-    unsigned long content_length = 0;
-   
-    if(frame.getProperties().hasProperty(
-        commands::CommandConstants::toString(
-            commands::CommandConstants::HEADER_CONTENTLENGTH)))
-    {
-        char* stopped_string = NULL;
-      
-        string length = 
-            frame.getProperties().getProperty(
-                commands::CommandConstants::toString(
-                    commands::CommandConstants::HEADER_CONTENTLENGTH));
-            
-        content_length = strtoul(
-            length.c_str(), 
-            &stopped_string, 
-            10);
-     }
-
-     if(content_length != 0)
-     {
-        // For this case its assumed that content length indicates how 
-        // much to read.  We reserve space in the buffer for it to 
-        // minimize the number of reallocs that might occur.  We are
-        // assuming that content length doesn't count the trailing null
-        // that indicates the end of frame.  The reserve won't do anything
-        // if the buffer already has that much capacity.  The resize call
-        // basically sets the end iterator to the correct location since
-        // this is a char vector and we already reserve enough space.
-        // Resize doesn't realloc the vector smaller if content_length
-        // is less than capacity of the buffer, it just move the end
-        // iterator.  Reserve adds the benefit that the mem is set to 
-        // zero.  Over time as larger messages come in thsi will cause
-        // us to adapt to that size so that future messages that are
-        // around that size won't alloc any new memory.
-
-        buffer.reserve( content_length );
-        buffer.resize( content_length );
-
-        // Read the Content Length now
-        read( &buffer[0], content_length );
-
-        // Content Length read, now pop the end terminator off (\0\n).
-        if(inputStream->read() != '\0' )
-        {
-            throw StompConnectorException(
-                __FILE__, __LINE__,
-                "StompCommandReader::readStompBody: "
-                "Read Content Length, and no trailing null");
-        }
-    }
-    else
-    {
-        // Content length was either zero, or not set, so we read until the
-        // first null is encounted.
-      
-        while( true )
-        {
-            char byte = inputStream->read();
-         
-            buffer.push_back(byte);
-        
-            content_length++;
-
-            if(byte != '\0')
-            {            
-                continue;
-            }
-
-            break;  // Read null and newline we are done.
-        }
-    }
-
-    if( content_length != 0 )
-    {
-        char* cpyBody = new char[content_length];
-        memcpy(cpyBody, &buffer[0], content_length);
-
-        // Set the body contents in the frame - copy the memory
-        frame.setBody( cpyBody, content_length );
-    }
-
-    // Clean up the mess.
-    buffer.clear();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-int StompCommandReader::read(unsigned char* buffer, int count) 
-   throw(io::IOException)
-{
-    if( inputStream == NULL )
-    {
-        throw IOException( 
-            __FILE__, __LINE__, 
-            "StompCommandReader::read(char*,int) - input stream is NULL" );
-    }
-   
-    int head = 0;
-   
-    // We call the read(buffer, size) version asking for one
-    // byte, if this returns zero, then there wasn't anything 
-    // on the stream to read, so we try again after a short 
-    // pause in hopes that some more data will show up.
-    while( true )
-    {
-        head += inputStream->read(&buffer[head], count - head);
-      
-        if(head == count)
-        {
-            return count;
-        }
-      
-        // Got here, so we wait a bit and try again.
-        Thread::sleep( 10 );
-    }
-}
- 
-////////////////////////////////////////////////////////////////////////////////
-unsigned char StompCommandReader::readByte(void) throw(io::IOException)
-{
-    if( inputStream == NULL )
-    {
-        throw IOException( 
-            __FILE__, __LINE__, 
-            "StompCommandReader::read(char*,int) - input stream is NULL" );
-    }
-   
-    unsigned char c = 0;
-    inputStream->read(&c, 1);
-    return c;
-}
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "StompCommandReader.h"
+
+#include <activemq/connector/stomp/commands/CommandConstants.h>
+#include <activemq/concurrent/Thread.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::concurrent;
+using namespace activemq::connector;
+using namespace activemq::connector::stomp;
+using namespace activemq::transport;
+using namespace activemq::io;
+using namespace activemq::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+StompCommandReader::StompCommandReader(void)
+{
+    inputStream = NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+StompCommandReader::StompCommandReader(InputStream* is)
+{
+    inputStream = is;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Command* StompCommandReader::readCommand(void) 
+    throw (CommandIOException)
+{
+    try
+    {
+        // Create a new Frame for reading to.
+        StompFrame* frame = new StompFrame();
+       
+        // Read the command into the frame.
+        readStompCommand( *frame );
+       
+        // Read the headers.
+        readStompHeaders( *frame );
+       
+        // Read the body.
+        readStompBody( *frame );
+       
+        // Return the Command, caller must delete it.
+        return marshaler.marshal( frame );
+    }
+    AMQ_CATCH_RETHROW( CommandIOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, CommandIOException )
+    AMQ_CATCHALL_THROW( CommandIOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StompCommandReader::readStompCommand( StompFrame& frame ) 
+   throw ( StompConnectorException )
+{  
+	while( true ) 
+	{
+	    // Clean up the mess.
+	    buffer.clear();
+
+	    // Read the command;
+	    readStompHeaderLine();
+
+        // Ignore all white space before the command.
+        int offset=-1;
+        for( size_t ix = 0; ix < buffer.size()-1; ++ix )
+        {
+        	// Find the first non space character
+        	char b = buffer[ix];
+            switch ( b ) 
+            {
+            	case '\n':
+            	case '\t':
+            	case '\r':
+            		break;
+            	  
+	            default:
+		            offset = ix;
+		            break; 
+            } 
+            
+	        if( offset != -1 )
+	        {
+	        	break;
+	        }            
+        }
+	
+	    if( offset >= 0 )
+	    {
+		    // Set the command in the frame - copy the memory.
+		    frame.setCommand( reinterpret_cast<char*>(&buffer[offset]) );
+			break;
+	    }
+	
+	}
+    // Clean up the mess.
+    buffer.clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StompCommandReader::readStompHeaders( StompFrame& frame ) 
+   throw (StompConnectorException)
+{
+    // Read the command;
+    bool endOfHeaders = false;
+
+    while( !endOfHeaders )
+    {
+        // Clean up the mess.
+        buffer.clear();
+
+        // Read in the next header line.
+        int numChars = readStompHeaderLine();
+
+        if( numChars == 0 )
+        {
+            // should never get here
+            throw StompConnectorException(
+                __FILE__, __LINE__,
+                "StompCommandReader::readStompHeaders: no characters read" );
+        }
+      
+        // Check for an empty line to demark the end of the header section.
+        // if its not the end then we have a header to process, so parse it.
+        if( numChars == 1 && buffer[0] == '\0' )
+        {
+            endOfHeaders = true;
+        }
+        else
+        {
+            // Search through this line to separate the key/value pair.
+            for( size_t ix = 0; ix < buffer.size(); ++ix )
+            {
+                // If found the key/value separator...
+                if( buffer[ix] == ':' )
+                {
+                    // Null-terminate the key.
+                    buffer[ix] = '\0'; 
+
+                    const char* key = reinterpret_cast<char*>(&buffer[0]);
+                    const char* value = reinterpret_cast<char*>(&buffer[ix+1]);
+               
+                    // Assign the header key/value pair.
+                    frame.getProperties().setProperty(key, value);
+               
+                    // Break out of the for loop.
+                    break;
+                }
+            }
+        }
+    }
+
+    // Clean up the mess.
+    buffer.clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int StompCommandReader::readStompHeaderLine(void) 
+    throw (StompConnectorException)
+{
+    int count = 0;
+  
+    while( true )
+    {
+        // Read the next char from the stream.
+        buffer.push_back( inputStream->read() );
+      
+        // Increment the position pointer.
+        count++;
+      
+        // If we reached the line terminator, return the total number
+        // of characters read.
+        if( buffer[count-1] == '\n' )
+        {
+            // Overwrite the line feed with a null character. 
+            buffer[count-1] = '\0';
+         
+            return count;
+        }
+    }
+   
+    // If we get here something bad must have happened.
+    throw StompConnectorException(
+        __FILE__, __LINE__,
+        "StompCommandReader::readStompHeaderLine: "
+        "Unrecoverable, error condition");
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StompCommandReader::readStompBody( StompFrame& frame ) 
+   throw ( StompConnectorException )
+{
+    unsigned long content_length = 0;
+   
+    if(frame.getProperties().hasProperty(
+        commands::CommandConstants::toString(
+            commands::CommandConstants::HEADER_CONTENTLENGTH)))
+    {
+        char* stopped_string = NULL;
+      
+        string length = 
+            frame.getProperties().getProperty(
+                commands::CommandConstants::toString(
+                    commands::CommandConstants::HEADER_CONTENTLENGTH));
+            
+        content_length = strtoul(
+            length.c_str(), 
+            &stopped_string, 
+            10);
+     }
+
+     if(content_length != 0)
+     {
+        // For this case its assumed that content length indicates how 
+        // much to read.  We reserve space in the buffer for it to 
+        // minimize the number of reallocs that might occur.  We are
+        // assuming that content length doesn't count the trailing null
+        // that indicates the end of frame.  The reserve won't do anything
+        // if the buffer already has that much capacity.  The resize call
+        // basically sets the end iterator to the correct location since
+        // this is a char vector and we already reserve enough space.
+        // Resize doesn't realloc the vector smaller if content_length
+        // is less than capacity of the buffer, it just move the end
+        // iterator.  Reserve adds the benefit that the mem is set to 
+        // zero.  Over time as larger messages come in thsi will cause
+        // us to adapt to that size so that future messages that are
+        // around that size won't alloc any new memory.
+
+        buffer.reserve( content_length );
+        buffer.resize( content_length );
+
+        // Read the Content Length now
+        read( &buffer[0], content_length );
+
+        // Content Length read, now pop the end terminator off (\0\n).
+        if(inputStream->read() != '\0' )
+        {
+            throw StompConnectorException(
+                __FILE__, __LINE__,
+                "StompCommandReader::readStompBody: "
+                "Read Content Length, and no trailing null");
+        }
+    }
+    else
+    {
+        // Content length was either zero, or not set, so we read until the
+        // first null is encounted.
+      
+        while( true )
+        {
+            char byte = inputStream->read();
+         
+            buffer.push_back(byte);
+        
+            content_length++;
+
+            if(byte != '\0')
+            {            
+                continue;
+            }
+
+            break;  // Read null and newline we are done.
+        }
+    }
+
+    if( content_length != 0 )
+    {
+        char* cpyBody = new char[content_length];
+        memcpy(cpyBody, &buffer[0], content_length);
+
+        // Set the body contents in the frame - copy the memory
+        frame.setBody( cpyBody, content_length );
+    }
+
+    // Clean up the mess.
+    buffer.clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int StompCommandReader::read(unsigned char* buffer, int count) 
+   throw(io::IOException)
+{
+    if( inputStream == NULL )
+    {
+        throw IOException( 
+            __FILE__, __LINE__, 
+            "StompCommandReader::read(char*,int) - input stream is NULL" );
+    }
+   
+    int head = 0;
+   
+    // We call the read(buffer, size) version asking for one
+    // byte, if this returns zero, then there wasn't anything 
+    // on the stream to read, so we try again after a short 
+    // pause in hopes that some more data will show up.
+    while( true )
+    {
+        head += inputStream->read(&buffer[head], count - head);
+      
+        if(head == count)
+        {
+            return count;
+        }
+      
+        // Got here, so we wait a bit and try again.
+        Thread::sleep( 10 );
+    }
+}
+ 
+////////////////////////////////////////////////////////////////////////////////
+unsigned char StompCommandReader::readByte(void) throw(io::IOException)
+{
+    if( inputStream == NULL )
+    {
+        throw IOException( 
+            __FILE__, __LINE__, 
+            "StompCommandReader::read(char*,int) - input stream is NULL" );
+    }
+   
+    unsigned char c = 0;
+    inputStream->read(&c, 1);
+    return c;
+}

Propchange: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.h?rev=419365&r1=419364&r2=419365&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.h Wed Jul  5 15:27:34 2006
@@ -1,146 +1,146 @@
-/*
- * Copyright 2006 The Apache Software Foundation or its licensors, as
- * applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef _ACTIVEMQ_CONNECTOR_STOMP_STOMPCOMMANDREADER_H_
-#define _ACTIVEMQ_CONNECTOR_STOMP_STOMPCOMMANDREADER_H_
-
-#include <activemq/transport/CommandReader.h>
-#include <activemq/io/InputStream.h>
-#include <activemq/transport/CommandIOException.h>
-#include <activemq/transport/Command.h>
-#include <activemq/connector/stomp/StompFrame.h>
-#include <activemq/connector/stomp/StompConnectorException.h>
-#include <activemq/connector/stomp/marshal/Marshaler.h>
-
-namespace activemq{
-namespace connector{
-namespace stomp{
-
-    class StompCommandReader : public transport::CommandReader
-    {
-    private:
-   
-        /**
-         * The target input stream.
-         */
-        io::InputStream* inputStream;
-      
-        /**
-         * Vector Object used to buffer data
-         */
-        std::vector<unsigned char> buffer;
-        
-        /**
-         * Marshaler of Stomp Commands
-         */
-        marshal::Marshaler marshaler;
-
-    public:
-
-        /**
-         * Deafult Constructor
-         */
-    	StompCommandReader( void );
-
-        /**
-         * Constructor.
-         * @param is the target input stream.
-         */
-        StompCommandReader( io::InputStream* is );
-
-        /**
-         * Destructor
-         */
-    	virtual ~StompCommandReader(void) {}
-
-        /**
-         * Reads a command from the given input stream.
-         * @return The next command available on the stream.
-         * @throws CommandIOException if a problem occurs during the read.
-         */
-        virtual transport::Command* readCommand( void ) 
-            throw ( transport::CommandIOException );
-
-        /**
-         * Sets the target input stream.
-         * @param Target Input Stream
-         */
-        virtual void setInputStream(io::InputStream* is){
-            inputStream = is;
-        }
-      
-        /**
-         * Gets the target input stream.
-         * @return Target Input Stream
-         */
-        virtual io::InputStream* getInputStream( void ){
-            return inputStream;
-        }
-
-        /**
-         * Attempts to read an array of bytes from the stream.
-         * @param buffer The target byte buffer.
-         * @param count The number of bytes to read.
-         * @return The number of bytes read.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual int read(unsigned char* buffer, int count) 
-            throw( io::IOException );
-       
-        /**
-         * Attempts to read a byte from the input stream
-         * @return The byte.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual unsigned char readByte(void) throw( io::IOException );
-
-    private:
-    
-        /**
-         * Read the Stomp Command from the Frame
-         * @param reference to a Stomp Frame
-         * @throws StompConnectorException
-         */
-        void readStompCommand( StompFrame& frame ) 
-            throw ( StompConnectorException );
-
-        /** 
-         * Read all the Stomp Headers for the incoming Frame
-         * @param Frame to place data into
-         * @throws StompConnectorException
-         */
-        void readStompHeaders( StompFrame& frame ) 
-            throw ( StompConnectorException );
-
-        /**
-         * Reads a Stomp Header line and stores it in the buffer object
-         * @return number of bytes read, zero if there was a problem.
-         * @throws StompConnectorException
-         */
-        int readStompHeaderLine( void ) throw ( StompConnectorException );
-
-        /**
-         * Reads the Stomp Body from the Wire and store it in the frame.
-         * @param Stomp Frame to place data in
-         */
-        void readStompBody( StompFrame& frame ) 
-            throw ( StompConnectorException );
-    
-    };
-
-}}}
-
-#endif /*_ACTIVEMQ_CONNECTOR_STOMP_STOMPCOMMANDREADER_H_*/
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _ACTIVEMQ_CONNECTOR_STOMP_STOMPCOMMANDREADER_H_
+#define _ACTIVEMQ_CONNECTOR_STOMP_STOMPCOMMANDREADER_H_
+
+#include <activemq/transport/CommandReader.h>
+#include <activemq/io/InputStream.h>
+#include <activemq/transport/CommandIOException.h>
+#include <activemq/transport/Command.h>
+#include <activemq/connector/stomp/StompFrame.h>
+#include <activemq/connector/stomp/StompConnectorException.h>
+#include <activemq/connector/stomp/marshal/Marshaler.h>
+
+namespace activemq{
+namespace connector{
+namespace stomp{
+
+    class StompCommandReader : public transport::CommandReader
+    {
+    private:
+   
+        /**
+         * The target input stream.
+         */
+        io::InputStream* inputStream;
+      
+        /**
+         * Vector Object used to buffer data
+         */
+        std::vector<unsigned char> buffer;
+        
+        /**
+         * Marshaler of Stomp Commands
+         */
+        marshal::Marshaler marshaler;
+
+    public:
+
+        /**
+         * Deafult Constructor
+         */
+    	StompCommandReader( void );
+
+        /**
+         * Constructor.
+         * @param is the target input stream.
+         */
+        StompCommandReader( io::InputStream* is );
+
+        /**
+         * Destructor
+         */
+    	virtual ~StompCommandReader(void) {}
+
+        /**
+         * Reads a command from the given input stream.
+         * @return The next command available on the stream.
+         * @throws CommandIOException if a problem occurs during the read.
+         */
+        virtual transport::Command* readCommand( void ) 
+            throw ( transport::CommandIOException );
+
+        /**
+         * Sets the target input stream.
+         * @param Target Input Stream
+         */
+        virtual void setInputStream(io::InputStream* is){
+            inputStream = is;
+        }
+      
+        /**
+         * Gets the target input stream.
+         * @return Target Input Stream
+         */
+        virtual io::InputStream* getInputStream( void ){
+            return inputStream;
+        }
+
+        /**
+         * Attempts to read an array of bytes from the stream.
+         * @param buffer The target byte buffer.
+         * @param count The number of bytes to read.
+         * @return The number of bytes read.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual int read(unsigned char* buffer, int count) 
+            throw( io::IOException );
+       
+        /**
+         * Attempts to read a byte from the input stream
+         * @return The byte.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual unsigned char readByte(void) throw( io::IOException );
+
+    private:
+    
+        /**
+         * Read the Stomp Command from the Frame
+         * @param reference to a Stomp Frame
+         * @throws StompConnectorException
+         */
+        void readStompCommand( StompFrame& frame ) 
+            throw ( StompConnectorException );
+
+        /** 
+         * Read all the Stomp Headers for the incoming Frame
+         * @param Frame to place data into
+         * @throws StompConnectorException
+         */
+        void readStompHeaders( StompFrame& frame ) 
+            throw ( StompConnectorException );
+
+        /**
+         * Reads a Stomp Header line and stores it in the buffer object
+         * @return number of bytes read, zero if there was a problem.
+         * @throws StompConnectorException
+         */
+        int readStompHeaderLine( void ) throw ( StompConnectorException );
+
+        /**
+         * Reads the Stomp Body from the Wire and store it in the frame.
+         * @param Stomp Frame to place data in
+         */
+        void readStompBody( StompFrame& frame ) 
+            throw ( StompConnectorException );
+    
+    };
+
+}}}
+
+#endif /*_ACTIVEMQ_CONNECTOR_STOMP_STOMPCOMMANDREADER_H_*/

Propchange: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandReader.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.cpp?rev=419365&r1=419364&r2=419365&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.cpp Wed Jul  5 15:27:34 2006
@@ -1,137 +1,137 @@
-/*
- * Copyright 2006 The Apache Software Foundation or its licensors, as
- * applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "StompCommandWriter.h"
-
-#include <activemq/connector/stomp/StompFrame.h>
-#include <activemq/connector/stomp/commands/CommandConstants.h>
-
-using namespace std;
-using namespace activemq;
-using namespace activemq::connector;
-using namespace activemq::connector::stomp;
-using namespace activemq::connector::stomp::commands;
-using namespace activemq::transport;
-using namespace activemq::io;
-using namespace activemq::exceptions;
-
-////////////////////////////////////////////////////////////////////////////////
-StompCommandWriter::StompCommandWriter(void)
-{
-    outputStream = NULL;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-StompCommandWriter::StompCommandWriter(OutputStream* os)
-{
-    outputStream = os;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-void StompCommandWriter::writeCommand( const Command* command ) 
-    throw ( transport::CommandIOException )
-{
-    try
-    {
-        if( outputStream == NULL )
-        {
-            throw CommandIOException( 
-                __FILE__, __LINE__, 
-                "StompCommandWriter::writeCommand - "
-                "output stream is NULL" );
-        }
-
-        const StompFrame& frame = marshaler.marshal( command );
-
-        // Write the command.
-        const string& cmdString = frame.getCommand();
-        write( cmdString.c_str(), cmdString.length() );
-        writeByte( '\n' );
-
-        // Write all the headers.
-        vector< pair<string,string> > headers = frame.getProperties().toArray();   
-        for( unsigned int ix=0; ix < headers.size(); ++ix )
-        {
-            string& name = headers[ix].first;
-            string& value = headers[ix].second;
-
-            write( name.c_str(), name.length() );
-            writeByte( ':' );
-            write( value.c_str(), value.length() );
-            writeByte( '\n' );       
-        }
-
-        // Finish the header section with a form feed.
-        writeByte( '\n' );
-
-        // Write the body.
-        const char* body = frame.getBody();
-        if( body != NULL ) 
-        {
-            write( body, frame.getBodyLength() );
-        }
-
-        if( ( frame.getBodyLength() == 0 ) ||
-            ( frame.getProperties().getProperty( 
-                  CommandConstants::toString( 
-                      CommandConstants::HEADER_CONTENTLENGTH ), "" ) != "" ) )
-        {
-            writeByte( '\0' );
-        }
-
-        writeByte( '\n' );
-
-        // Flush the stream.
-        outputStream->flush();
-    }
-    AMQ_CATCH_RETHROW( CommandIOException )
-    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, CommandIOException )
-    AMQ_CATCHALL_THROW( CommandIOException )
-}
-
-////////////////////////////////////////////////////////////////////////////////
-void StompCommandWriter::write(const unsigned char* buffer, int count) 
-    throw(IOException)
-{
-    if( outputStream == NULL )
-    {
-        throw IOException( 
-            __FILE__, __LINE__, 
-            "StompCommandWriter::write(char*,int) - input stream is NULL" );
-    }
-
-    outputStream->write( buffer, count );
-}
- 
-////////////////////////////////////////////////////////////////////////////////
-void StompCommandWriter::writeByte(unsigned char v) throw(IOException)
-{
-    if( outputStream == NULL )
-    {
-        throw IOException( 
-            __FILE__, __LINE__, 
-            "StompCommandWriter::write(char) - input stream is NULL" );
-    }
-   
-    outputStream->write( v );
-}
-
-////////////////////////////////////////////////////////////////////////////////
-void StompCommandWriter::write(const char* buffer, int count) 
-   throw(io::IOException)
-{
-    write(reinterpret_cast<const unsigned char*>(buffer), count);
-}
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "StompCommandWriter.h"
+
+#include <activemq/connector/stomp/StompFrame.h>
+#include <activemq/connector/stomp/commands/CommandConstants.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::connector;
+using namespace activemq::connector::stomp;
+using namespace activemq::connector::stomp::commands;
+using namespace activemq::transport;
+using namespace activemq::io;
+using namespace activemq::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+StompCommandWriter::StompCommandWriter(void)
+{
+    outputStream = NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+StompCommandWriter::StompCommandWriter(OutputStream* os)
+{
+    outputStream = os;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StompCommandWriter::writeCommand( const Command* command ) 
+    throw ( transport::CommandIOException )
+{
+    try
+    {
+        if( outputStream == NULL )
+        {
+            throw CommandIOException( 
+                __FILE__, __LINE__, 
+                "StompCommandWriter::writeCommand - "
+                "output stream is NULL" );
+        }
+
+        const StompFrame& frame = marshaler.marshal( command );
+
+        // Write the command.
+        const string& cmdString = frame.getCommand();
+        write( cmdString.c_str(), cmdString.length() );
+        writeByte( '\n' );
+
+        // Write all the headers.
+        vector< pair<string,string> > headers = frame.getProperties().toArray();   
+        for( unsigned int ix=0; ix < headers.size(); ++ix )
+        {
+            string& name = headers[ix].first;
+            string& value = headers[ix].second;
+
+            write( name.c_str(), name.length() );
+            writeByte( ':' );
+            write( value.c_str(), value.length() );
+            writeByte( '\n' );       
+        }
+
+        // Finish the header section with a form feed.
+        writeByte( '\n' );
+
+        // Write the body.
+        const char* body = frame.getBody();
+        if( body != NULL ) 
+        {
+            write( body, frame.getBodyLength() );
+        }
+
+        if( ( frame.getBodyLength() == 0 ) ||
+            ( frame.getProperties().getProperty( 
+                  CommandConstants::toString( 
+                      CommandConstants::HEADER_CONTENTLENGTH ), "" ) != "" ) )
+        {
+            writeByte( '\0' );
+        }
+
+        writeByte( '\n' );
+
+        // Flush the stream.
+        outputStream->flush();
+    }
+    AMQ_CATCH_RETHROW( CommandIOException )
+    AMQ_CATCH_EXCEPTION_CONVERT( ActiveMQException, CommandIOException )
+    AMQ_CATCHALL_THROW( CommandIOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StompCommandWriter::write(const unsigned char* buffer, int count) 
+    throw(IOException)
+{
+    if( outputStream == NULL )
+    {
+        throw IOException( 
+            __FILE__, __LINE__, 
+            "StompCommandWriter::write(char*,int) - input stream is NULL" );
+    }
+
+    outputStream->write( buffer, count );
+}
+ 
+////////////////////////////////////////////////////////////////////////////////
+void StompCommandWriter::writeByte(unsigned char v) throw(IOException)
+{
+    if( outputStream == NULL )
+    {
+        throw IOException( 
+            __FILE__, __LINE__, 
+            "StompCommandWriter::write(char) - input stream is NULL" );
+    }
+   
+    outputStream->write( v );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StompCommandWriter::write(const char* buffer, int count) 
+   throw(io::IOException)
+{
+    write(reinterpret_cast<const unsigned char*>(buffer), count);
+}

Propchange: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.h?rev=419365&r1=419364&r2=419365&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.h Wed Jul  5 15:27:34 2006
@@ -1,118 +1,118 @@
-/*
- * Copyright 2006 The Apache Software Foundation or its licensors, as
- * applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef _ACTIVEMQ_CONNECTOR_STOMP_STOMPCOMMANDWRITER_H_
-#define _ACTIVEMQ_CONNECTOR_STOMP_STOMPCOMMANDWRITER_H_
-
-#include <activemq/transport/CommandWriter.h>
-#include <activemq/io/InputStream.h>
-#include <activemq/transport/CommandIOException.h>
-#include <activemq/connector/stomp/StompConnectorException.h>
-#include <activemq/transport/Command.h>
-#include <activemq/io/OutputStream.h>
-#include <activemq/connector/stomp/marshal/Marshaler.h>
-
-namespace activemq{
-namespace connector{
-namespace stomp{
-
-    class StompCommandWriter : public transport::CommandWriter
-    {
-    private:
-    
-        /**
-         * Target output stream.
-         */
-        io::OutputStream* outputStream;
-
-        /**
-         * Marshaler of Stomp Commands
-         */
-        marshal::Marshaler marshaler;
-
-    public:
-    
-        /**
-         * Default Constructor
-         */
-    	StompCommandWriter(void);
-
-        /**
-         * Constructor.
-         * @param os the target output stream.
-         */
-        StompCommandWriter( io::OutputStream* os );
-
-        /**
-         * Destructor
-         */
-    	virtual ~StompCommandWriter(void) {}
-
-        /**
-         * Sets the target output stream.
-         */
-        virtual void setOutputStream(io::OutputStream* os){
-            outputStream = os;
-        }
-      
-        /**
-         * Gets the target output stream.
-         */
-        virtual io::OutputStream* getOutputStream(void){
-            return outputStream;
-        }
-
-        /**
-         * Writes a command to the given output stream.
-         * @param command the command to write.
-         * @param os the target stream for the write.
-         * @throws CommandIOException if a problem occurs during the write.
-         */
-        virtual void writeCommand( const transport::Command* command ) 
-            throw ( transport::CommandIOException );
-
-        /**
-         * Writes a byte array to the output stream.
-         * @param buffer a byte array
-         * @param count the number of bytes in the array to write.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual void write(const unsigned char* buffer, int count) 
-            throw( io::IOException );
-       
-        /**
-         * Writes a byte to the output stream.
-         * @param v The value to be written.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual void writeByte(unsigned char v) throw( io::IOException );
-
-    private:
-   
-        /**
-         * Writes a char array to the output stream.
-         * @param buffer a char array
-         * @param count the number of bytes in the array to write.
-         * @throws IOException thrown if an error occurs.
-         */
-        virtual void write(const char* buffer, int count) 
-            throw( io::IOException );
-
-    };
-
-}}}
-
-#endif /*_ACTIVEMQ_CONNECTOR_STOMP_STOMPCOMMANDWRITER_H_*/
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _ACTIVEMQ_CONNECTOR_STOMP_STOMPCOMMANDWRITER_H_
+#define _ACTIVEMQ_CONNECTOR_STOMP_STOMPCOMMANDWRITER_H_
+
+#include <activemq/transport/CommandWriter.h>
+#include <activemq/io/InputStream.h>
+#include <activemq/transport/CommandIOException.h>
+#include <activemq/connector/stomp/StompConnectorException.h>
+#include <activemq/transport/Command.h>
+#include <activemq/io/OutputStream.h>
+#include <activemq/connector/stomp/marshal/Marshaler.h>
+
+namespace activemq{
+namespace connector{
+namespace stomp{
+
+    class StompCommandWriter : public transport::CommandWriter
+    {
+    private:
+    
+        /**
+         * Target output stream.
+         */
+        io::OutputStream* outputStream;
+
+        /**
+         * Marshaler of Stomp Commands
+         */
+        marshal::Marshaler marshaler;
+
+    public:
+    
+        /**
+         * Default Constructor
+         */
+    	StompCommandWriter(void);
+
+        /**
+         * Constructor.
+         * @param os the target output stream.
+         */
+        StompCommandWriter( io::OutputStream* os );
+
+        /**
+         * Destructor
+         */
+    	virtual ~StompCommandWriter(void) {}
+
+        /**
+         * Sets the target output stream.
+         */
+        virtual void setOutputStream(io::OutputStream* os){
+            outputStream = os;
+        }
+      
+        /**
+         * Gets the target output stream.
+         */
+        virtual io::OutputStream* getOutputStream(void){
+            return outputStream;
+        }
+
+        /**
+         * Writes a command to the given output stream.
+         * @param command the command to write.
+         * @param os the target stream for the write.
+         * @throws CommandIOException if a problem occurs during the write.
+         */
+        virtual void writeCommand( const transport::Command* command ) 
+            throw ( transport::CommandIOException );
+
+        /**
+         * Writes a byte array to the output stream.
+         * @param buffer a byte array
+         * @param count the number of bytes in the array to write.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write(const unsigned char* buffer, int count) 
+            throw( io::IOException );
+       
+        /**
+         * Writes a byte to the output stream.
+         * @param v The value to be written.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void writeByte(unsigned char v) throw( io::IOException );
+
+    private:
+   
+        /**
+         * Writes a char array to the output stream.
+         * @param buffer a char array
+         * @param count the number of bytes in the array to write.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write(const char* buffer, int count) 
+            throw( io::IOException );
+
+    };
+
+}}}
+
+#endif /*_ACTIVEMQ_CONNECTOR_STOMP_STOMPCOMMANDWRITER_H_*/

Propchange: incubator/activemq/trunk/activemq-cpp/src/main/activemq/connector/stomp/StompCommandWriter.h
------------------------------------------------------------------------------
    svn:eol-style = native