activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r452154 - in /incubator/activemq/activemq-cpp/trunk/activemq-cpp: ./ .settings/ src/main/activemq/io/ src/main/activemq/wireformat/ src/test/activemq/connector/openwire/utils/
Date Mon, 02 Oct 2006 18:12:58 GMT
Author: tabish
Date: Mon Oct  2 11:12:57 2006
New Revision: 452154

URL: http://svn.apache.org/viewvc?view=rev&rev=452154
Log: (empty)

Added:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/.cdtproject
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/.project   (with props)
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/.settings/
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/.settings/org.eclipse.cdt.core.prefs
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.cpp   (with props)
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.h   (with props)
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.cpp   (with props)
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.h   (with props)
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/WireFormat.h   (with props)
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/WireFormatFactory.h   (with props)
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/utils/
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/utils/BooleanStreamTest.cpp   (with props)
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/utils/BooleanStreamTest.h   (with props)
Modified:
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/makefile
    incubator/activemq/activemq-cpp/trunk/activemq-cpp/makefile.cfg

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/.cdtproject
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/.cdtproject?view=auto&rev=452154
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/.cdtproject (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/.cdtproject Mon Oct  2 11:12:57 2006
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse-cdt version="2.0"?>
+
+<cdtproject id="org.eclipse.cdt.make.core.make">
+<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.SOM" point="org.eclipse.cdt.core.BinaryParser">
+<attribute key="addr2line" value="addr2line"/>
+<attribute key="c++filt" value="c++filt"/>
+</extension>
+<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.XCOFF32" point="org.eclipse.cdt.core.BinaryParser">
+<attribute key="addr2line" value="addr2line"/>
+<attribute key="c++filt" value="c++filt"/>
+</extension>
+<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser">
+<attribute key="addr2line" value="addr2line"/>
+<attribute key="c++filt" value="c++filt"/>
+</extension>
+<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser">
+<attribute key="addr2line" value="addr2line"/>
+<attribute key="cygpath" value="cygpath"/>
+<attribute key="c++filt" value="c++filt"/>
+<attribute key="nm" value="nm"/>
+</extension>
+<extension id="org.eclipse.cdt.core.domsourceindexer" point="org.eclipse.cdt.core.CIndexer"/>
+<data>
+<item id="scannerConfiguration">
+<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="false"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="false" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+<parser enabled="false"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="false" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="false"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="false" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="false"/>
+</scannerInfoProvider>
+</profile>
+</item>
+<item id="org.eclipse.cdt.core.pathentry">
+<pathentry kind="src" path=""/>
+<pathentry kind="out" path=""/>
+<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
+</item>
+</data>
+</cdtproject>

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/.project
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/.project?view=auto&rev=452154
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/.project (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/.project Mon Oct  2 11:12:57 2006
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>activemq-trunk-cpp</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.cdt.make.core.makeBuilder</name>
+			<triggers>clean,full,incremental,</triggers>
+			<arguments>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.build.arguments</key>
+					<value>-e</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.core.errorOutputParser</key>
+					<value>org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser;</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+					<value>false</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.environment</key>
+					<value>OSTYPE=windows|CONFIG=debug|MAKESUPPORT_HOME=${project_loc}|</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.enableFullBuild</key>
+					<value>true</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.build.target.inc</key>
+					<value>all</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>
+					<value>true</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.build.target.clean</key>
+					<value>clean</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.build.command</key>
+					<value>mingw32-make.exe</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+					<value>true</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.append_environment</key>
+					<value>true</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+					<value>false</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.build.target.auto</key>
+					<value>all</value>
+				</dictionary>
+				<dictionary>
+					<key>org.eclipse.cdt.make.core.stopOnError</key>
+					<value>false</value>
+				</dictionary>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.cdt.core.cnature</nature>
+		<nature>org.eclipse.cdt.make.core.makeNature</nature>
+		<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>
+		<nature>org.eclipse.cdt.core.ccnature</nature>
+	</natures>
+</projectDescription>

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/.project
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/.settings/org.eclipse.cdt.core.prefs
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/.settings/org.eclipse.cdt.core.prefs?view=auto&rev=452154
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/.settings/org.eclipse.cdt.core.prefs (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/.settings/org.eclipse.cdt.core.prefs Mon Oct  2 11:12:57 2006
@@ -0,0 +1,3 @@
+#Mon Oct 02 09:05:02 EDT 2006
+eclipse.preferences.version=1
+indexerId=org.eclipse.cdt.core.fastIndexer

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/makefile
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/makefile?view=diff&rev=452154&r1=452153&r2=452154
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/makefile (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/makefile Mon Oct  2 11:12:57 2006
@@ -26,6 +26,12 @@
     \
 	$(OUTDIR)/main/activemq/connector/stomp/marshal/Marshaler.o \
     \
+	$(OUTDIR)/main/activemq/connector/openwire/utils/BooleanStream.o \
+	$(OUTDIR)/main/activemq/connector/openwire/OpenWireFormatFactory.o \
+	$(OUTDIR)/main/activemq/connector/openwire/OpenWireFormat.o \
+    \
+	$(OUTDIR)/main/activemq/connector/openwire/commands/WireFormatInfo.o \
+    \
 	$(OUTDIR)/main/activemq/core/ActiveMQConnectionFactory.o \
 	$(OUTDIR)/main/activemq/core/ActiveMQConnection.o \
 	$(OUTDIR)/main/activemq/core/ActiveMQSession.o \
@@ -34,8 +40,8 @@
 	$(OUTDIR)/main/activemq/core/ActiveMQTransaction.o \
 	$(OUTDIR)/main/activemq/core/ActiveMQConstants.o \
 	\
-	$(OUTDIR)/main/activemq/io/EndianReader.o \
-	$(OUTDIR)/main/activemq/io/EndianWriter.o \
+	$(OUTDIR)/main/activemq/io/DataInputStream.o \
+	$(OUTDIR)/main/activemq/io/DataOutputStream.o \
 	$(OUTDIR)/main/activemq/io/BufferedInputStream.o \
 	$(OUTDIR)/main/activemq/io/BufferedOutputStream.o \
 	$(OUTDIR)/main/activemq/io/ByteArrayInputStream.o \
@@ -59,7 +65,53 @@
     $(OUTDIR)/main/activemq/concurrent/Thread.o \
     $(OUTDIR)/main/activemq/concurrent/Mutex.o \
     $(OUTDIR)/main/activemq/concurrent/ThreadPool.o \
-    $(OUTDIR)/main/activemq/concurrent/PooledThread.o 
+    $(OUTDIR)/main/activemq/concurrent/PooledThread.o \
+    \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/BrokerInfo.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/ConnectionControl.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/ConnectionError.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/ConnectionId.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/ConnectionInfo.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/ConsumerControl.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/ConsumerId.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/ConsumerInfo.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/ControlCommand.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/DataArrayResponse.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/DataResponse.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/DestinationInfo.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/DiscoveryEvent.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/ExceptionResponse.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/FlushCommand.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/IntegerResponse.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/JournalQueueAck.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/JournalTopicAck.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/JournalTrace.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/JournalTransaction.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/KeepAliveInfo.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/LastPartialCommand.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/LocalTransactionId.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/Message.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/MessageAck.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/MessageDispatch.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/MessageDispatchNotification.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/MessageId.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/MessagePull.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/NetworkBridgeFilter.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/PartialCommand.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/ProducerId.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/ProducerInfo.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/RemoveInfo.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/RemoveSubscriptionInfo.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/ReplayCommand.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/Response.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/SessionId.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/SessionInfo.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/ShutdownInfo.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/SubscriptionInfo.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/TransactionId.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/TransactionInfo.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/WireFormatInfo.o \
+    $(OUTDIR)/main/activemq/connector/openwire/commands/XATransactionId.o 
 
 OTESTFILES = \
     $(OUTDIR)/test/main.o \
@@ -100,14 +152,16 @@
     $(OUTDIR)/test/activemq/connector/ConnectorFactoryMapRegistrarTest.o \
     $(OUTDIR)/test/activemq/connector/ConnectorFactoryMapTest.o \
     \
+    $(OUTDIR)/test/activemq/connector/openwire/utils/BooleanStreamTest.o \
+    \
     $(OUTDIR)/test/activemq/exceptions/ActiveMQExceptionTest.o \
     \
     $(OUTDIR)/test/activemq/io/BufferedInputStreamTest.o \
 	$(OUTDIR)/test/activemq/io/BufferedOutputStreamTest.o \
 	$(OUTDIR)/test/activemq/io/ByteArrayInputStreamTest.o \
 	$(OUTDIR)/test/activemq/io/ByteArrayOutputStreamTest.o \
-	$(OUTDIR)/test/activemq/io/EndianReaderTest.o \
-	$(OUTDIR)/test/activemq/io/EndianWriterTest.o \
+	$(OUTDIR)/test/activemq/io/DataInputStreamTest.o \
+	$(OUTDIR)/test/activemq/io/DataOutputStreamTest.o \
 	\
 	$(OUTDIR)/test/activemq/logger/LoggerTest.o \
 	\

Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/makefile.cfg
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/makefile.cfg?view=diff&rev=452154&r1=452153&r2=452154
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/makefile.cfg (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/makefile.cfg Mon Oct  2 11:12:57 2006
@@ -138,6 +138,12 @@
 	     $(MD) $(OUTDIR)/main/activemq/connector/stomp; \
 	     $(MD) $(OUTDIR)/main/activemq/connector/stomp/commands; \
 	     $(MD) $(OUTDIR)/main/activemq/connector/stomp/marshal; \
+	     $(MD) $(OUTDIR)/main/activemq/connector/openwire; \
+	     $(MD) $(OUTDIR)/main/activemq/connector/openwire/commands; \
+	     $(MD) $(OUTDIR)/main/activemq/connector/openwire/marshal; \
+	     $(MD) $(OUTDIR)/main/activemq/connector/openwire/marshal/v1; \
+	     $(MD) $(OUTDIR)/main/activemq/connector/openwire/marshal/v2; \
+	     $(MD) $(OUTDIR)/main/activemq/connector/openwire/utils; \
 	     $(MD) $(OUTDIR)/main/activemq/core; \
 	     $(MD) $(OUTDIR)/main/activemq/io; \
 	     $(MD) $(OUTDIR)/main/activemq/logger; \
@@ -163,6 +169,12 @@
 	     $(MD) $(OUTDIR)/test/activemq/connector/stomp; \
 	     $(MD) $(OUTDIR)/test/activemq/connector/stomp/commands; \
 	     $(MD) $(OUTDIR)/test/activemq/connector/stomp/marshal; \
+	     $(MD) $(OUTDIR)/test/activemq/connector/openwire; \
+	     $(MD) $(OUTDIR)/test/activemq/connector/openwire/commands; \
+	     $(MD) $(OUTDIR)/test/activemq/connector/openwire/marshal; \
+	     $(MD) $(OUTDIR)/test/activemq/connector/openwire/marshal/V1; \
+	     $(MD) $(OUTDIR)/test/activemq/connector/openwire/marshal/V2; \
+	     $(MD) $(OUTDIR)/test/activemq/connector/openwire/utils; \
 	     $(MD) $(OUTDIR)/test/activemq/core; \
 	     $(MD) $(OUTDIR)/test/activemq/io; \
 	     $(MD) $(OUTDIR)/test/activemq/logger; \

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.cpp?view=auto&rev=452154
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.cpp (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.cpp Mon Oct  2 11:12:57 2006
@@ -0,0 +1,267 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <activemq/io/DataInputStream.h>
+#include <activemq/util/Endian.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::io;
+using namespace activemq::util;
+using namespace activemq::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+DataInputStream::DataInputStream( InputStream* inputStream, bool own )
+ : FilterInputStream( inputStream, own ) {}
+
+////////////////////////////////////////////////////////////////////////////////
+DataInputStream::~DataInputStream() {}
+
+////////////////////////////////////////////////////////////////////////////////
+int DataInputStream::read( std::vector<unsigned char>& buffer ) 
+    throw ( io::IOException ) {
+        
+    try {
+        return this->read( &buffer[0], 0, buffer.size() );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int DataInputStream::read( unsigned char* buffer, int offset, int length ) 
+    throw ( io::IOException, exceptions::IndexOutOfBoundsException, exceptions::NullPointerException ) {
+
+    if( length < 0 || offset < 0 ) {
+        throw IndexOutOfBoundsException( 
+            __FILE__, __LINE__,
+            "DataInputStream::read - len or offset params invalid" );
+    }
+    
+    if( buffer == NULL ) {
+        throw NullPointerException( 
+            __FILE__, __LINE__,
+            "DataInputStream::read - Buffer is null" );
+    }
+    
+    try {
+        int read = 0;
+        
+        try {
+            read = inputStream->read( &buffer[offset], length );
+        } catch( io::EOFException& ex ){
+            if( read == 0 ) 
+                return -1;
+        }
+
+        if( read == 0 ){
+            throw IOException( 
+                __FILE__, __LINE__,
+                "DataInputStream::read - failed to extract data, not EOF." );
+        }
+        
+        return read;
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool DataInputStream::readBoolean() 
+    throw( io::IOException, io::EOFException ) {
+
+    try {
+        char value = 0;
+        this->readFully( ( unsigned char* )&value, 0, sizeof( char ) );
+        return (char)( value != 0 );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+char DataInputStream::readByte() 
+    throw ( io::IOException, io::EOFException ) {
+    
+    try {
+        char value = 0;
+        this->readFully( ( unsigned char* )&value, 0, sizeof( char ) );
+        return (char)( value );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned char DataInputStream::readUnsignedByte() 
+    throw ( io::IOException, io::EOFException ) {
+
+    try {
+        unsigned char value = 0;
+        this->readFully( ( unsigned char* )&value, 0, sizeof( unsigned char ) );
+        return (char)( value );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+} 
+
+////////////////////////////////////////////////////////////////////////////////
+char DataInputStream::readChar() throw ( io::IOException, io::EOFException ) {
+    try {
+        char value = 0;
+        this->readFully( ( unsigned char* )&value, 0, sizeof( char ) );
+        return (char)( value );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+short DataInputStream::readShort() throw ( io::IOException, io::EOFException ) {
+    try {
+        unsigned short value = 0;
+        this->readFully( ( unsigned char* )&value, 0, sizeof( unsigned short ) );
+        return (short)Endian::byteSwap( value );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned short DataInputStream::readUnsignedShort() 
+    throw ( io::IOException, io::EOFException ) {
+    try {
+        unsigned short value;
+        this->readFully( ( unsigned char* )&value, 0, sizeof( unsigned short ) );
+        return Endian::byteSwap( value );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int DataInputStream::readInt() throw ( io::IOException, io::EOFException ) {
+    try {
+        unsigned int value;    
+        this->readFully( ( unsigned char* )&value, 0, sizeof( unsigned int ) );
+        return (int)Endian::byteSwap( value );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double DataInputStream::readDouble() throw ( io::IOException, io::EOFException ) {
+    try {
+        double value;
+        this->readFully( ( unsigned char* )&value, 0, sizeof( double ) );
+        return Endian::byteSwap( value );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+float DataInputStream::readFloat() throw ( io::IOException, io::EOFException ) {
+    try {
+        float value;
+        this->readFully( ( unsigned char* )&value, 0, sizeof( float ) );
+        return Endian::byteSwap( value );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long DataInputStream::readLong()
+    throw ( io::IOException, io::EOFException ) {
+    try {
+        unsigned long long value;
+        this->readFully( ( unsigned char* )&value, 0, sizeof( unsigned long long ) );
+        return (long long)Endian::byteSwap( value );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string DataInputStream::readUTF() 
+    throw ( io::IOException, io::EOFException ) {
+    try {
+        return "";
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )    
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataInputStream::readFully( std::vector< unsigned char >& buffer ) 
+    throw ( io::IOException, io::EOFException ) {
+    try {
+        readFully( &buffer[0], 0, buffer.size() );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataInputStream::readFully( unsigned char* buffer, int offset, int length ) 
+    throw ( io::IOException, io::EOFException, exceptions::IndexOutOfBoundsException, exceptions::NullPointerException ) {
+    try {
+        if( length < 0 || offset < 0 ) {
+            throw IndexOutOfBoundsException(
+                __FILE__, __LINE__,
+                "DataInputStream::readFully - Len or Offset were invalid" );
+        }
+        
+        if( buffer == NULL ) {
+            throw NullPointerException( 
+                __FILE__, __LINE__,
+                "DataInputStream::read - Buffer is null" );
+        }
+    
+        int n = 0;
+        while( n < length ) {
+            int count = inputStream->read( &buffer[offset + n], length - n );
+            if( count < 0 ) {
+                throw EOFException(
+                    __FILE__, __LINE__,
+                    "DataInputStream::readFully - Reached EOF" );
+            }
+            n += count;
+        }
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )    
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int DataInputStream::skipBytes( int num ) throw( io::IOException ) {
+    try {
+        int total = 0;
+        int cur = 0;
+
+        while( ( total < num ) && 
+               ( ( cur = (int)inputStream->skip( num-total ) ) > 0 ) ) {
+            total += cur;
+        }
+
+        return total;
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.h?view=auto&rev=452154
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.h (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.h Mon Oct  2 11:12:57 2006
@@ -0,0 +1,330 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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_IO_DATAINPUTSTREAM_H_
+#define _ACTIVEMQ_IO_DATAINPUTSTREAM_H_
+
+#include <activemq/io/FilterInputStream.h>
+#include <activemq/io/IOException.h>
+#include <activemq/io/EOFException.h>
+#include <activemq/exceptions/NullPointerException.h>
+#include <activemq/exceptions/IndexOutOfBoundsException.h>
+
+namespace activemq{
+namespace io{
+
+    /**
+     * A data input stream lets an application read primitive Java data 
+     * types from an underlying input stream in a machine-independent way. 
+     * An application uses a data output stream to write data that can 
+     * later be read by a data input stream.
+     * 
+     * Due to the lack of garbage collection in C++ a design decision was 
+     * made to add a boolean parameter to the constructor indicating if the
+     * wrapped <code>InputStream</code> is owned by this object.  That way
+     * creation of the underlying stream can occur in a Java like way. Ex:
+     * 
+     *  DataInputStream os = new DataInputStream( new InputStream(), true )
+     */
+    class DataInputStream : public FilterInputStream
+    {
+    public:
+    
+        /**
+         * Creates a DataInputStream that uses the specified underlying 
+         * InputStream.
+         * @param inputStream the InputStream instance to wrap.
+         * @param own, indicates if this class owns the wrapped string
+         * defaults to false.
+         */
+        DataInputStream( InputStream* inputStream, bool own = false );
+        
+        virtual ~DataInputStream();
+
+        /**
+         * Reads some number of bytes from the contained input stream and 
+         * stores them into the buffer array b. The number of bytes actually
+         * read is returned as an integer. This method blocks until input 
+         * data is available, end of file is detected, or an exception is 
+         * thrown.
+         * <p>
+         * If the length of buffer is zero, then no bytes are read and 0 is 
+         * returned; otherwise, there is an attempt to read at least one 
+         * byte. If no byte is available because the stream is at end of 
+         * file, the value -1 is returned; otherwise, at least one byte is 
+         * read and stored into buffer.
+         * <p>
+         * The first byte read is stored into element buffer[0], the next one 
+         * into buffer[1], and so on. The number of bytes read is, at most, 
+         * equal to the length of buffer. Let k be the number of bytes actually 
+         * read; these bytes will be stored in elements b[0] through b[k-1],
+         * leaving elements buffer[k] through buffer[buffer.length-1] 
+         * unaffected.
+         * <p>
+         * If the first byte cannot be read for any reason other than end 
+         * of file, then an IOException is thrown. In particular, an 
+         * IOException is thrown if the input stream has been closed.
+         * <p>
+         * The read( buffer ) method has the same effect as:
+         *      read( buffer, 0, b.length )
+         * @param buffer - byte array to insert read data into
+         * @returns the total number of bytes read, or -1 if there is no
+         *          more data because the stream is EOF.
+         * @throws IOException 
+         */   
+        virtual int read( std::vector< unsigned char >& buffer ) 
+            throw ( io::IOException );
+
+        /**
+         * Reads up to len bytes of data from the contained input stream 
+         * into an array of bytes. An attempt is made to read as many as 
+         * len bytes, but a smaller number may be read, possibly zero. The 
+         * number of bytes actually read is returned as an integer.
+         * <p>
+         * This method blocks until input data is available, end of file is
+         * detected, or an exception is thrown.
+         * <p>
+         * If buffer is null, a NullPointerException is thrown.
+         * <p>
+         * If off is negative, or len is negative then an 
+         * IndexOutOfBoundsException is thrown, if off + len is greater that
+         * the allocated length of the array, an IOException will result
+         * depending on the platform and compiler settings.
+         * <p>
+         * If len is zero, then no bytes are read and 0 is returned; 
+         * otherwise, there is an attempt to read at least one byte. If no 
+         * byte is available because the stream is at end of file, the 
+         * value -1 is returned; otherwise, at least one byte is read and 
+         * stored into buffer.
+         * <p>
+         * The first byte read is stored into element b[off], the next one 
+         * into buffer[off+1], and so on. The number of bytes read is, at most, 
+         * equal to len. Let k be the number of bytes actually read; these 
+         * bytes will be stored in elements buffer[off] through buffer[off+k-1], 
+         * leaving elements buffer[off+k] through buffer[off+len-1] unaffected.
+         * <p>
+         * In every case, elements buffer[0] through buffer[off] and elements 
+         * buffer[off+len] through buffer[buffer.length-1] are unaffected.
+         * <p>
+         * If the first byte cannot be read for any reason other than end of 
+         * file, then an IOException is thrown. In particular, an IOException 
+         * is thrown if the input stream has been closed.
+         * @param buffer - byte array to insert read data into
+         * @param offset - location in buffer to start writing
+         * @param length - number of bytes to read 
+         * @returns the total number of bytes read, or -1 if there is no
+         *          more data because the stream is EOF.
+         * @throws IOException 
+         */
+        virtual int read( unsigned char* buffer, int offset, int length ) 
+            throw ( io::IOException, exceptions::IndexOutOfBoundsException, exceptions::NullPointerException );
+        
+        /**
+         * Reads one input byte and returns true if that byte is nonzero, 
+         * false if that byte is zero.
+         * @returns the boolean value read.
+         * @throws IOException
+         * @throws EOFException
+         */
+        virtual bool readBoolean() 
+            throw( io::IOException, io::EOFException );
+        
+        /**
+         * Reads and returns one input byte. The byte is treated as a 
+         * signed value in the range -128 through 127, inclusive.
+         * @returns the 8-bit value read.
+         * @throws IOException
+         * @throws EOFException
+         */
+        virtual char readByte() 
+            throw ( io::IOException, io::EOFException ); 
+
+        /**
+         * Reads one input byte, zero-extends it to type int, and returns 
+         * the result, which is therefore in the range 0  through 255. 
+         * @returns the 8 bit unsigned value read
+         * @throws IOException
+         * @throws EOFException
+         */
+        virtual unsigned char readUnsignedByte() 
+            throw ( io::IOException, io::EOFException );
+        
+        /**
+         * Reads an input char and returns the char value. A ascii char 
+         * is made up of one bytes.  This returns the same result as 
+         * <code>readByte</code>
+         * @returns the 8 bit char read
+         * @throws IOException
+         * @throws EOFException
+         */
+        virtual char readChar() throw ( io::IOException, io::EOFException );
+        
+        /**
+         * Reads eight input bytes and returns a double value. It does this
+         * by first constructing a long long  value in exactly the manner of 
+         * the readlong  method, then converting this long  value to a double
+         * in exactly the manner of the method Double.longBitsToDouble.
+         * @returns the double value read
+         * @throws IOException
+         * @throws EOFException
+         */
+        virtual double readDouble() 
+            throw ( io::IOException, io::EOFException );
+        
+        /**
+         * Reads four input bytes and returns a float value. It does this 
+         * by first constructing an int  value in exactly the manner of the 
+         * readInt  method, then converting this int  value to a float in 
+         * exactly the manner of the method Float.intBitsToFloat.
+         * @returns the float value read
+         * @throws IOException
+         * @throws EOFException
+         */
+        virtual float readFloat() throw ( io::IOException, io::EOFException );
+
+        /**
+         * Reads four input bytes and returns an int value. Let a  be the 
+         * first byte read, b be the second byte, c be the third byte, and 
+         * d be the fourth byte. The value returned is: <p>
+         *  (((a & 0xff) << 24) | ((b & 0xff) << 16) |
+         *   ((c & 0xff) << 8) | (d & 0xff))
+         * @returns the int value read
+         * @throws IOException 
+         * @throws EOFException
+         */
+        virtual int readInt() throw ( io::IOException, io::EOFException );
+        
+        /**
+         * Reads eight input bytes and returns a long value. Let a  be the 
+         * first byte read, b be the second byte, c be the third byte, d  
+         * be the fourth byte, e be the fifth byte, f  be the sixth byte, 
+         * g be the seventh byte, and h be the eighth byte. The value 
+         * returned is:
+         *  (((long)(a & 0xff) << 56) |
+         *   ((long)(b & 0xff) << 48) |
+         *   ((long)(c & 0xff) << 40) |
+         *   ((long)(d & 0xff) << 32) |
+         *   ((long)(e & 0xff) << 24) |
+         *   ((long)(f & 0xff) << 16) |
+         *   ((long)(g & 0xff) <<  8) |
+         *   ((long)(h & 0xff)))
+         * @returns the 64 bit long long read
+         * @throws IOException
+         * @throws EOFException
+         */
+        virtual long long readLong() 
+            throw ( io::IOException, io::EOFException );
+
+        /**
+         * Reads two input bytes and returns a short value. Let a  be the 
+         * first byte read and b  be the second byte. The value returned is:
+         *   (short)((a << 8) | (b & 0xff))
+         * @returns the 16 bit short value read
+         * @throws IOException
+         * @throws EOFException
+         */
+        virtual short readShort() throw ( io::IOException, io::EOFException );
+
+        /**
+         * Reads two input bytes and returns an int value in the range 0 
+         * through 65535. Let a  be the first byte read and b  be the 
+         * second byte. The value returned is:
+         *   (((a & 0xff) << 8) | (b & 0xff))
+         * @returns the 16 bit unsigned short read
+         * @throws IOException
+         * @throws EOFException
+         */
+        virtual unsigned short readUnsignedShort() 
+            throw ( io::IOException, io::EOFException );
+        
+        /**
+         * 
+         * @throws IOException
+         * @throws EOFException
+         */
+        virtual std::string readUTF() 
+            throw ( io::IOException, io::EOFException );
+
+        /**
+         * Reads some bytes from an input stream and stores them into the 
+         * buffer array buffer. The number of bytes read is equal to the length 
+         * of buffer.<p>
+         * This method blocks until one of the following conditions occurs:
+         *    * buffer.size() bytes of input data are available, in which case 
+         *      a normal return is made.
+         *    * End of file is detected, in which case an EOFException is 
+         *      thrown.
+         *    * An I/O error occurs, in which case an IOException other than 
+         *      EOFException is thrown. 
+         * <p>
+         * If buffer.size() is zero, then no bytes are read. Otherwise, the 
+         * first byte read is stored into element b[0], the next one into 
+         * buffer[1], and so on. If an exception is thrown from this method, 
+         * then it may be that some but not all bytes of buffer have been 
+         * updated with data from the input stream. 
+         * @param buffer - vector of char that is read to its size()
+         * @throws IOException
+         * @throws EOFException
+         */
+        virtual void readFully( std::vector< unsigned char >& buffer ) 
+            throw ( io::IOException, io::EOFException );
+                
+        /**
+         * Reads length bytes from an input stream.
+         * <p>
+         * This method blocks until one of the following conditions occurs:
+         *    * length bytes of input data are available, in which case a 
+         *      normal return is made.
+         *    * End of file is detected, in which case an EOFException is 
+         *      thrown.
+         *    * An I/O error occurs, in which case an IOException other 
+         *      than EOFException is thrown. 
+         * <p>
+         * If buffer is null, a NullPointerException is thrown. If offset is 
+         * negative, or len is negative, or offset+length is greater than the 
+         * length of the array buffer, then an IndexOutOfBoundsException is 
+         * thrown. If len is zero, then no bytes are read. Otherwise, the 
+         * first byte read is stored into element buffer[off], the next one into 
+         * buffer[offset+1], and so on. The number of bytes read is, at most, 
+         * equal to len. 
+         * @param buffer - byte array to insert read data into
+         * @param offset - location in buffer to start writing
+         * @param length - number of bytes to read 
+         * @throws IOException
+         * @throws EOFException
+         */
+        virtual void readFully( unsigned char* buffer, int offset, int length ) 
+            throw ( io::IOException, io::EOFException, exceptions::IndexOutOfBoundsException, exceptions::NullPointerException );
+
+        /**
+         * Makes an attempt to skip over n bytes of data from the input 
+         * stream, discarding the skipped bytes. However, it may skip over 
+         * some smaller number of bytes, possibly zero. This may result from
+         * any of a number of conditions; reaching end of file before n 
+         * bytes have been skipped is only one possibility. This method 
+         * never throws an EOFException. The actual number of bytes skipped
+         * is returned.
+         * @param num - number of bytes to skip
+         * @return the total number of bytes skipped
+         */
+        virtual int skipBytes( int num ) throw( io::IOException );
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_IO_DATAINPUTSTREAM_H_*/

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataInputStream.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.cpp?view=auto&rev=452154
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.cpp (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.cpp Mon Oct  2 11:12:57 2006
@@ -0,0 +1,149 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "DataOutputStream.h"
+#include <activemq/util/Endian.h>
+
+using namespace activemq;
+using namespace activemq::io;
+using namespace activemq::util;
+
+////////////////////////////////////////////////////////////////////////////////
+DataOutputStream::DataOutputStream( OutputStream* outputStream, bool own )
+ : FilterOutputStream( outputStream, own )
+{
+    // Init the written count
+    written = 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+DataOutputStream::~DataOutputStream()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataOutputStream::write( const unsigned char c ) throw ( IOException ) {
+    try {
+        outputStream->write( c );
+        written++;
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataOutputStream::write( const unsigned char* buffer, const int len )
+    throw ( IOException ) {
+
+    try {
+        outputStream->write( buffer, len );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataOutputStream::writeBoolean( bool value ) throw ( IOException ) {
+    try {
+        unsigned char ivalue = 0;
+        value == true ? ivalue = 1 : ivalue = 0;
+        ivalue = Endian::byteSwap( ivalue );
+        write( ( unsigned char* )&ivalue, sizeof( ivalue ) );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataOutputStream::writeByte( unsigned char value ) throw ( IOException ) {
+    try {
+        value = Endian::byteSwap( value );
+        write( ( unsigned char* )&value, sizeof( value ) );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataOutputStream::writeShort( short value ) throw ( IOException ) {
+    try {
+        value = Endian::byteSwap( ( unsigned short )value );
+        write( ( unsigned char* )&value, sizeof( value ) );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataOutputStream::writeChar( char value ) throw ( IOException ) {
+    try {
+        value = Endian::byteSwap( ( unsigned char )value );
+        write( ( unsigned char* )&value, sizeof( value ) );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataOutputStream::writeInt( int value ) throw ( IOException ) {
+    try {
+        value = Endian::byteSwap( ( unsigned int )value );
+        write( ( unsigned char* )&value, sizeof( value ) );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataOutputStream::writeLong( long long value ) throw ( IOException ) {
+    try {
+        value = Endian::byteSwap( ( unsigned long long )value );
+        write( ( unsigned char* )&value, sizeof( value ) );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataOutputStream::writeFloat( float value ) throw ( IOException ) {
+    try {
+        value = Endian::byteSwap( value );
+        write( ( unsigned char* )&value, sizeof( value ) );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataOutputStream::writeDouble( double value ) throw ( IOException ) {
+    try {
+        value = Endian::byteSwap( value );
+        write( ( unsigned char* )&value, sizeof( value ) );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DataOutputStream::writeBytes( const std::string& value ) throw ( IOException ) {
+    try {
+        // add one so that we write the NULL
+        this->write( (const unsigned char*)value.c_str(), value.length() + 1 );
+    }
+    AMQ_CATCH_RETHROW( IOException )
+    AMQ_CATCHALL_THROW( IOException )
+}

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.h?view=auto&rev=452154
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.h (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.h Mon Oct  2 11:12:57 2006
@@ -0,0 +1,181 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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_IO_DATAOUTPUTSTREAM_H_
+#define _ACTIVEMQ_IO_DATAOUTPUTSTREAM_H_
+
+#include <activemq/io/FilterOutputStream.h>
+
+namespace activemq{
+namespace io{
+
+    /**
+     * A data output stream lets an application write primitive Java data 
+     * types to an output stream in a portable way. An application can then
+     * use a data input stream to read the data back in.
+     */
+    class DataOutputStream : public FilterOutputStream
+    {
+    protected:
+    
+        // The number of bytes written to the data output stream so far.
+        unsigned int written;
+        
+    public:
+    
+        /**
+         * Creates a new data output stream to write data to the specified 
+         * underlying output stream.
+         * @param outputStream a stream to wrap with this one.
+         * @param own true if this objects owns the stream that it wraps.
+         */
+        DataOutputStream( OutputStream* outputStream, bool own = false );
+
+        virtual ~DataOutputStream();
+        
+        /**
+         * Returns the current value of the counter written, the number of 
+         * bytes written to this data output stream so far. If the counter 
+         * overflows, it will be wrapped to Integer.MAX_VALUE.
+         * @return the value of the written field.
+         */
+        virtual unsigned int size() const {
+            return written;
+        }
+
+        /**
+         * Writes a single byte to the output stream.  If no exception is 
+         * thrown, the counter written is incremented by 1.
+         * @param c the byte.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const unsigned char c ) throw ( IOException );
+        
+        /**
+         * Writes an array of bytes to the output stream.  the counter 
+         * written is incremented by len.
+         * @param buffer The array of bytes to write.
+         * @param len The number of bytes from the buffer to be written.
+         * @throws IOException thrown if an error occurs.
+         */
+        virtual void write( const unsigned char* buffer, const int len )
+            throw ( IOException );
+        
+        /**
+         * Writes a boolean to the underlying output stream as a 1-byte value. The 
+         * value true is written out as the value (byte)1; the value false 
+         * is written out as the value (byte)0. If no exception is thrown, 
+         * the counter written is incremented by 1.
+         * @param value the boolean to write.
+         * @throws IOException
+         * 
+         */
+        virtual void writeBoolean( bool value ) throw ( IOException );
+        
+        /**
+         * Writes out a byte to the underlying output stream as a 1-byte 
+         * value. If no exception is thrown, the counter written is 
+         * incremented by 1.
+         * @param value the unsigned char value to write.
+         * @throws IOException
+         */
+        virtual void writeByte( unsigned char value ) throw ( IOException );
+
+        /**
+         * Writes a short to the underlying output stream as two bytes, high 
+         * byte first. If no exception is thrown, the counter written is 
+         * incremented by 2.
+         * @param value the value to write.
+         * @throws IOException
+         */
+        virtual void writeShort( short value ) throw ( IOException );
+        
+        /**
+         * Writes out a char to the underlying output stream as a one byte 
+         * value If no exception is thrown, the counter written is 
+         * incremented by 1.
+         * @param value the value to write.
+         * @throws IOException
+         */
+        virtual void writeChar( char value ) throw ( IOException );
+
+        /**
+         * Writes an int to the underlying output stream as four bytes, high 
+         * byte first. If no exception is thrown, the counter written is 
+         * incremented by 4.
+         * @param value the value to write.
+         * @throws IOException
+         */
+        virtual void writeInt( int value ) throw ( IOException );
+
+        /**
+         * Writes an 64 bit long to the underlying output stream as eight 
+         * bytes, high byte first. If no exception is thrown, the counter 
+         * written is incremented by 8.
+         * @param value the value to write.
+         * @throws IOException
+         */
+        virtual void writeLong( long long value ) throw ( IOException );
+
+        /**
+         * Converts the float argument to an int using the floatToIntBits 
+         * method in class Float, and then writes that int value to the 
+         * underlying output stream as a 4-byte quantity, high byte first. 
+         * If no exception is thrown, the counter written is incremented 
+         * by 4.
+         * @param value the value to write.
+         * @throws IOException
+         */
+        virtual void writeFloat( float value ) throw ( IOException );
+
+        /**
+         * Converts the double argument to a long using the doubleToLongBits 
+         * method in class Double, and then writes that long value to the 
+         * underlying output stream as an 8-byte quantity, high byte first. 
+         * If no exception is thrown, the counter written is incremented 
+         * by 8.
+         * @param value the value to write.
+         * @throws IOException
+         */
+        virtual void writeDouble( double value ) throw ( IOException );
+
+        /**
+         * Writes out the string to the underlying output stream as a 
+         * sequence of bytes. Each character in the string is written out, 
+         * in sequence, by discarding its high eight bits. If no exception 
+         * is thrown, the counter written is incremented by the length of 
+         * value.
+         * @param value the value to write.
+         * @throws IOException
+         */
+        virtual void writeBytes( const std::string& value ) throw ( IOException );
+
+        /**
+         * Writes a string to the underlying output stream as a sequence of 
+         * characters. Each character is written to the data output stream 
+         * as if by the writeChar method. If no exception is thrown, the 
+         * counter written is incremented by twice the length of value.
+         * @param value the value to write.
+         * @throws IOException
+         */
+        virtual void writeChars( const std::string& value ) throw ( IOException ) {};
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_IO_DATAOUTPUTSTREAM_H_*/

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/io/DataOutputStream.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/WireFormat.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/WireFormat.h?view=auto&rev=452154
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/WireFormat.h (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/WireFormat.h Mon Oct  2 11:12:57 2006
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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_WIREFORMAT_WIREFORMAT_H_
+#define _ACTIVEMQ_WIREFORMAT_WIREFORMAT_H_
+
+#include <activemq/io/DataInputStream.h>
+#include <activemq/io/DataOutputStream.h>
+#include <activemq/io/IOException.h>
+
+#include <activemq/transport/Command.h>
+
+namespace activemq{
+namespace wireformat{
+
+    /**
+     * Provides a mechanism to marshal commands into and out of packets
+     * or into and out of streams, Channels and Datagrams.
+     *
+     * @version $Revision: 1.1 $
+     */
+    class WireFormat
+    {
+    public:
+
+        virtual ~WireFormat() {}
+    
+        /**
+         * Stream based marshaling
+         * @param command - The Command to Marshal
+         * @param out - the output stream to write the command to.
+         * @throws IOException 
+         */
+        virtual void marshal( transport::Command* command, io::DataOutputStream* out ) 
+            throw ( io::IOException ) = 0;
+
+        /**
+         * Packet based un-marshaling 
+         * @param in - the input stream to read the command from.
+         * @returns the newly marshaled Command, caller owns the pointer
+         * @throws IOException 
+         */
+        virtual transport::Command* unmarshal( io::DataInputStream* in ) throw ( io::IOException ) = 0;
+        
+        /**
+         * Set the Version
+         * @param the version of the wire format
+         */
+        virtual void setVersion( int version ) = 0;
+        
+        /**
+         * Get the Version
+         * @return the version of the wire format
+         */
+        virtual int getVersion() const = 0;
+    
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_WIREFORMAT_WIREFORMAT_H_*/

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/WireFormat.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/WireFormatFactory.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/WireFormatFactory.h?view=auto&rev=452154
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/WireFormatFactory.h (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/WireFormatFactory.h Mon Oct  2 11:12:57 2006
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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_WIREFORMAT_WIREFORMATFACTORY_H_
+#define _ACTIVEMQ_WIREFORMAT_WIREFORMATFACTORY_H_
+
+#include <activemq/wireformat/WireFormat.h>
+#include <activemq/util/Properties.h>
+#include <activemq/exceptions/IllegalStateException.h>
+
+namespace activemq{
+namespace wireformat{
+
+    /**
+     * The WireFormatFactory is the interface that all WireFormatFactory
+     * classes must extend.  The Factory creates a WireFormat Object based on 
+     * the properties that are set in the passed <code>Properties</code> 
+     * object.  
+     */
+    class WireFormatFactory
+    {
+    public:
+
+        virtual ~WireFormatFactory() {}
+
+        /**    
+         * Creates a new WireFormat Object passing it a set of
+         * properties from which it can obtain any optional settings
+         * @param properties - the Properties for this WireFormat
+         */
+        virtual WireFormat* createWireFormat( const util::Properties& properties ) 
+            throw ( exceptions::IllegalStateException ) = 0; 
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_WIREFORMAT_WIREFORMATFACTORY_H_*/

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/wireformat/WireFormatFactory.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/utils/BooleanStreamTest.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/utils/BooleanStreamTest.cpp?view=auto&rev=452154
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/utils/BooleanStreamTest.cpp (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/utils/BooleanStreamTest.cpp Mon Oct  2 11:12:57 2006
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 "BooleanStreamTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::connector::openwire::utils::BooleanStreamTest );

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/utils/BooleanStreamTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/utils/BooleanStreamTest.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/utils/BooleanStreamTest.h?view=auto&rev=452154
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/utils/BooleanStreamTest.h (added)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/utils/BooleanStreamTest.h Mon Oct  2 11:12:57 2006
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 _ACTYIVEMQ_CONNECTOR_OPENWIRE_UTIL_BOOLEANSTREAMTEST_H_
+#define _ACTYIVEMQ_CONNECTOR_OPENWIRE_UTIL_BOOLEANSTREAMTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/connector/openwire/utils/BooleanStream.h>
+
+#include <activemq/io/ByteArrayOutputStream.h>
+#include <activemq/io/ByteArrayInputStream.h>
+#include <activemq/io/DataOutputStream.h>
+#include <activemq/io/DataInputStream.h>
+
+namespace activemq{
+namespace connector{
+namespace openwire{
+namespace utils{
+
+    class BooleanStreamTest : public CppUnit::TestFixture {
+
+      CPPUNIT_TEST_SUITE( BooleanStreamTest );
+      CPPUNIT_TEST( test );
+      CPPUNIT_TEST( test2 );
+      CPPUNIT_TEST_SUITE_END();
+
+    public:
+    
+        BooleanStreamTest() {}
+        virtual ~BooleanStreamTest() {}
+        
+        void test(){
+
+            BooleanStream b1Stream;
+
+            io::ByteArrayOutputStream baoStream;
+            io::DataOutputStream daoStream( &baoStream );
+
+            b1Stream.writeBoolean( false );
+            b1Stream.writeBoolean( true );
+            b1Stream.writeBoolean( false );
+            b1Stream.writeBoolean( false );
+            b1Stream.writeBoolean( true );
+            b1Stream.writeBoolean( false );
+            b1Stream.writeBoolean( true );
+            b1Stream.writeBoolean( true );
+            
+            b1Stream.marshal( &daoStream );
+            
+            BooleanStream b2Stream;
+            io::ByteArrayInputStream baiStream( baoStream.getByteArray(),
+                                                baoStream.getByteArraySize() );
+            io::DataInputStream daiStream( &baiStream );
+
+            b2Stream.unmarshal( &daiStream );
+            
+            CPPUNIT_ASSERT( b2Stream.readBoolean() == false );
+            CPPUNIT_ASSERT( b2Stream.readBoolean() == true );
+            CPPUNIT_ASSERT( b2Stream.readBoolean() == false );
+            CPPUNIT_ASSERT( b2Stream.readBoolean() == false );
+            CPPUNIT_ASSERT( b2Stream.readBoolean() == true );
+            CPPUNIT_ASSERT( b2Stream.readBoolean() == false );
+            CPPUNIT_ASSERT( b2Stream.readBoolean() == true );
+            CPPUNIT_ASSERT( b2Stream.readBoolean() == true );
+
+        }
+
+        void test2(){
+
+            BooleanStream b1Stream;
+
+            io::ByteArrayOutputStream baoStream;
+            io::DataOutputStream daoStream( &baoStream );
+
+            bool value = false;
+            for( int i = 0; i < 65536; i++ ) {
+                b1Stream.writeBoolean( value );
+                value = !value;
+            }
+
+            b1Stream.marshal( &daoStream );
+            
+            BooleanStream b2Stream;
+            io::ByteArrayInputStream baiStream( baoStream.getByteArray(),
+                                                baoStream.getByteArraySize() );
+            io::DataInputStream daiStream( &baiStream );
+
+            b2Stream.unmarshal( &daiStream );
+
+            value = false;
+            for( int i = 0; i < 65536; i++ ) {
+                CPPUNIT_ASSERT( b2Stream.readBoolean() == value );
+                value = !value;
+            }
+        }
+
+    };
+
+}}}}
+
+#endif /*BOOLEANSTREAMTEST_H_*/

Propchange: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/connector/openwire/utils/BooleanStreamTest.h
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message