You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2008/05/31 19:29:18 UTC
svn commit: r662050 [1/3] - in /activemq/activemq-cpp/trunk/src: main/
main/activemq/connector/openwire/marshal/ main/activemq/util/
main/decaf/util/ test/ test/activemq/cmsutil/ test/activemq/connector/
test/activemq/connector/openwire/ test/activemq/...
Author: tabish
Date: Sat May 31 10:29:16 2008
New Revision: 662050
URL: http://svn.apache.org/viewvc?rev=662050&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-172
Added:
activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.cpp
activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.h
activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueNode.cpp
activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueNode.h
activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueTypes.h
activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveListTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveListTest.h
activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveValueNodeTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveValueNodeTest.h
Modified:
activemq/activemq-cpp/trunk/src/main/Makefile.am
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp
activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.h
activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveMap.cpp
activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveMap.h
activemq/activemq-cpp/trunk/src/main/decaf/util/List.h
activemq/activemq-cpp/trunk/src/test/Makefile.am
activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsAccessorTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsDestinationAccessorTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DynamicDestinationResolverTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/ConnectorFactoryMapRegistrarTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/ConnectorFactoryMapTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/OpenWireFormatTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/commands/ActiveMQBytesMessageTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/commands/ActiveMQDestinationTest2.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/commands/ActiveMQMapMessageTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/commands/ActiveMQMessageTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/commands/ActiveMQQueueTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/commands/ActiveMQTempQueueTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/commands/ActiveMQTempTopicTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/commands/ActiveMQTextMessageTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/commands/ActiveMQTopicTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/commands/BrokerIdTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/commands/BrokerInfoTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/marshal/BaseDataStreamMarshallerTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/utils/BooleanStreamTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/utils/HexTableTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/openwire/utils/OpenwireStringSupportTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompCommandReaderTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompCommandWriterTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompConnectorTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompDestinationTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompFrameTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/StompSessionManagerTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/AbortCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/AckCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/BeginCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/BytesMessageCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/CommandConstantsTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/CommitCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/ConnectCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/ConnectedCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/DisconnectCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/ErrorCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/MessageCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/ReceiptCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/SubscribeCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/TextMessageCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/commands/UnsubscribeCommandTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/connector/stomp/marshal/MarshalerTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/core/ActiveMQConnectionTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/core/ActiveMQSessionTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/exceptions/ActiveMQExceptionTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/exceptions/ActiveMQExceptionTest.h
activemq/activemq-cpp/trunk/src/test/activemq/transport/IOTransportTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportFactoryMapRegistrarTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportFactoryMapRegistrarTest.h
activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportFactoryMapTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/transport/TransportFactoryMapTest.h
activemq/activemq-cpp/trunk/src/test/activemq/transport/filters/ResponseCorrelatorTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/transport/filters/ResponseCorrelatorTest.h
activemq/activemq-cpp/trunk/src/test/activemq/util/LongSequenceGeneratorTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/util/PrimitiveMapTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/util/URISupportTest.cpp
activemq/activemq-cpp/trunk/src/test/testRegistry.cpp
Modified: activemq/activemq-cpp/trunk/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/Makefile.am?rev=662050&r1=662049&r2=662050&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/main/Makefile.am Sat May 31 10:29:16 2008
@@ -20,6 +20,8 @@
activemq/io/LoggingOutputStream.cpp \
activemq/exceptions/ActiveMQException.cpp \
activemq/util/PrimitiveMap.cpp \
+ activemq/util/PrimitiveList.cpp \
+ activemq/util/PrimitiveValueNode.cpp \
activemq/util/LongSequenceGenerator.cpp \
activemq/util/URISupport.cpp \
activemq/cmsutil/DynamicDestinationResolver.cpp \
@@ -265,7 +267,10 @@
activemq/util/Config.h \
activemq/util/ActiveMQProperties.h \
activemq/util/LongSequenceGenerator.h \
+ activemq/util/PrimitiveValueNode.h \
activemq/util/PrimitiveMap.h \
+ activemq/util/PrimitiveList.h \
+ activemq/util/PrimitiveValueTypes.h \
activemq/util/URISupport.h \
cms/DeliveryMode.h \
cms/TemporaryQueue.h \
@@ -378,6 +383,7 @@
decaf/util/Iterator.h \
decaf/util/Collection.h \
decaf/util/Comparator.h \
+ decaf/util/List.h \
decaf/util/Map.h \
decaf/util/Properties.h \
decaf/util/Queue.h \
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp?rev=662050&r1=662049&r2=662050&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.cpp Sat May 31 10:29:16 2008
@@ -17,6 +17,7 @@
#include "PrimitiveMapMarshaller.h"
+#include <activemq/util/PrimitiveValueTypes.h>
#include <decaf/io/ByteArrayInputStream.h>
#include <decaf/io/ByteArrayOutputStream.h>
#include <decaf/io/DataInputStream.h>
@@ -56,7 +57,7 @@
for(; iter != keys.end(); ++iter ) {
OpenwireStringSupport::writeString( dataOut, &(*iter) );
- PrimitiveMap::ValueNode value = map->getValue( *iter );
+ PrimitiveValueNode value = map->getValue( *iter );
marshalPrimitive( dataOut, value );
}
}
@@ -129,69 +130,69 @@
///////////////////////////////////////////////////////////////////////////////
void PrimitiveMapMarshaller::marshalPrimitive( io::DataOutputStream& dataOut,
- activemq::util::PrimitiveMap::ValueNode& value )
+ activemq::util::PrimitiveValueNode& value )
throw ( decaf::io::IOException ) {
try {
- if( value.getValueType() == PrimitiveMap::BOOLEAN_TYPE ) {
+ if( value.getValueType() == BOOLEAN_TYPE ) {
- dataOut.writeByte( PrimitiveMap::BOOLEAN_TYPE );
+ dataOut.writeByte( BOOLEAN_TYPE );
dataOut.writeBoolean( value.getBool() );
- } else if( value.getValueType() == PrimitiveMap::BYTE_TYPE ) {
+ } else if( value.getValueType() == BYTE_TYPE ) {
- dataOut.writeByte( PrimitiveMap::BYTE_TYPE );
+ dataOut.writeByte( BYTE_TYPE );
dataOut.writeByte( value.getByte() );
- } else if( value.getValueType() == PrimitiveMap::CHAR_TYPE ) {
+ } else if( value.getValueType() == CHAR_TYPE ) {
- dataOut.writeByte( PrimitiveMap::CHAR_TYPE );
+ dataOut.writeByte( CHAR_TYPE );
dataOut.writeChar( value.getChar() );
- } else if( value.getValueType() == PrimitiveMap::SHORT_TYPE ) {
+ } else if( value.getValueType() == SHORT_TYPE ) {
- dataOut.writeByte( PrimitiveMap::SHORT_TYPE );
+ dataOut.writeByte( SHORT_TYPE );
dataOut.writeShort( value.getShort() );
- } else if( value.getValueType() == PrimitiveMap::INTEGER_TYPE ) {
+ } else if( value.getValueType() == INTEGER_TYPE ) {
- dataOut.writeByte( PrimitiveMap::INTEGER_TYPE );
+ dataOut.writeByte( INTEGER_TYPE );
dataOut.writeInt( value.getInt() );
- } else if( value.getValueType() == PrimitiveMap::LONG_TYPE ) {
+ } else if( value.getValueType() == LONG_TYPE ) {
- dataOut.writeByte( PrimitiveMap::LONG_TYPE );
+ dataOut.writeByte( LONG_TYPE );
dataOut.writeLong( value.getLong() );
- } else if( value.getValueType() == PrimitiveMap::FLOAT_TYPE ) {
+ } else if( value.getValueType() == FLOAT_TYPE ) {
- dataOut.writeByte( PrimitiveMap::FLOAT_TYPE );
+ dataOut.writeByte( FLOAT_TYPE );
dataOut.writeFloat( value.getFloat() );
- } else if( value.getValueType() == PrimitiveMap::DOUBLE_TYPE ) {
+ } else if( value.getValueType() == DOUBLE_TYPE ) {
- dataOut.writeByte( PrimitiveMap::DOUBLE_TYPE );
+ dataOut.writeByte( DOUBLE_TYPE );
dataOut.writeDouble( value.getDouble() );
- } else if( value.getValueType() == PrimitiveMap::BYTE_ARRAY_TYPE ) {
+ } else if( value.getValueType() == BYTE_ARRAY_TYPE ) {
- dataOut.writeByte( PrimitiveMap::BYTE_ARRAY_TYPE );
+ dataOut.writeByte( BYTE_ARRAY_TYPE );
std::vector<unsigned char> data = value.getByteArray();
dataOut.writeInt( (int)data.size() );
dataOut.write( data );
- } else if( value.getValueType() == PrimitiveMap::STRING_TYPE ) {
+ } else if( value.getValueType() == STRING_TYPE ) {
std::string data = value.getString();
// is the string big??
if( data.size() > 8191 ) {
- dataOut.writeByte( PrimitiveMap::BIG_STRING_TYPE );
+ dataOut.writeByte( BIG_STRING_TYPE );
} else {
- dataOut.writeByte( PrimitiveMap::STRING_TYPE );
+ dataOut.writeByte( STRING_TYPE );
}
OpenwireStringSupport::writeString( dataOut, &data );
@@ -220,34 +221,34 @@
switch( type )
{
- case PrimitiveMap::NULL_TYPE:
+ case NULL_TYPE:
map.setString( key, "" );
break;
- case PrimitiveMap::BYTE_TYPE:
+ case BYTE_TYPE:
map.setByte( key, dataIn.readByte() );
break;
- case PrimitiveMap::BOOLEAN_TYPE:
+ case BOOLEAN_TYPE:
map.setBool( key, dataIn.readBoolean() );
break;
- case PrimitiveMap::CHAR_TYPE:
+ case CHAR_TYPE:
map.setChar( key, dataIn.readChar() );
break;
- case PrimitiveMap::SHORT_TYPE:
+ case SHORT_TYPE:
map.setShort( key, dataIn.readShort() );
break;
- case PrimitiveMap::INTEGER_TYPE:
+ case INTEGER_TYPE:
map.setInt( key, dataIn.readInt() );
break;
- case PrimitiveMap::LONG_TYPE:
+ case LONG_TYPE:
map.setLong( key, dataIn.readLong() );
break;
- case PrimitiveMap::FLOAT_TYPE:
+ case FLOAT_TYPE:
map.setFloat( key, dataIn.readFloat() );
break;
- case PrimitiveMap::DOUBLE_TYPE:
+ case DOUBLE_TYPE:
map.setDouble( key, dataIn.readDouble() );
break;
- case PrimitiveMap::BYTE_ARRAY_TYPE:
+ case BYTE_ARRAY_TYPE:
{
int size = dataIn.readInt();
std::vector<unsigned char> data;
@@ -256,8 +257,8 @@
map.setByteArray( key, data );
break;
}
- case PrimitiveMap::STRING_TYPE:
- case PrimitiveMap::BIG_STRING_TYPE:
+ case STRING_TYPE:
+ case BIG_STRING_TYPE:
map.setString(
key,
OpenwireStringSupport::readString( dataIn ) );
Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.h?rev=662050&r1=662049&r2=662050&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/PrimitiveMapMarshaller.h Sat May 31 10:29:16 2008
@@ -19,6 +19,7 @@
#define _ACTIVEMQ_CONNECTOR_OPENWIRE_MARSHAL_PRIMITIVEMAPMARSHALLER_H_
#include <cms/CMSException.h>
+#include <activemq/util/PrimitiveValueNode.h>
#include <activemq/util/PrimitiveMap.h>
#include <decaf/io/DataOutputStream.h>
#include <decaf/io/DataInputStream.h>
@@ -79,7 +80,7 @@
* @throws CMSException
*/
static void marshalPrimitive( decaf::io::DataOutputStream& dataOut,
- util::PrimitiveMap::ValueNode& value )
+ util::PrimitiveValueNode& value )
throw ( decaf::io::IOException );
/**
Added: activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.cpp?rev=662050&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.cpp Sat May 31 10:29:16 2008
@@ -0,0 +1,216 @@
+/**
+ * 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 "PrimitiveList.h"
+
+#include <stdio.h>
+#include <string.h>
+
+using namespace activemq;
+using namespace activemq::util;
+using namespace decaf::lang::exceptions;
+using namespace decaf::util;
+using namespace std;
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveList::PrimitiveList() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveList::PrimitiveList( const PrimitiveList& src )
+ : List<PrimitiveValueNode>( src ){
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string PrimitiveList::toString() const {
+
+ ostringstream stream;
+
+ stream << "Begin Class PrimitiveList:" << std::endl;
+
+ for( std::size_t i = 0; i < this->size(); ++i ) {
+ stream << "list[" << i << "] = "
+ << this->get( i ).toString() << std::endl;
+ }
+
+ stream << "End Class PrimitiveList:" << std::endl;
+
+ return stream.str();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool PrimitiveList::getBool( std::size_t index ) const
+ throw( IndexOutOfBoundsException ){
+
+ PrimitiveValueNode node = this->get( index );
+ return node.getBool();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveList::setBool( std::size_t index, bool value ){
+
+ PrimitiveValueNode node;
+ node.setBool( value );
+
+ this->set( index, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned char PrimitiveList::getByte( std::size_t index ) const
+ throw( IndexOutOfBoundsException ){
+
+ PrimitiveValueNode node = this->get( index );
+ return node.getByte();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveList::setByte( std::size_t index, unsigned char value ){
+ PrimitiveValueNode node;
+ node.setByte( value );
+
+ this->set( index, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+char PrimitiveList::getChar( std::size_t index ) const
+ throw( IndexOutOfBoundsException ){
+
+ PrimitiveValueNode node = this->get( index );
+ return node.getChar();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveList::setChar( std::size_t index, char value ){
+ PrimitiveValueNode node;
+ node.setChar( value );
+
+ this->set( index, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+short PrimitiveList::getShort( std::size_t index ) const
+ throw( IndexOutOfBoundsException ){
+
+ PrimitiveValueNode node = this->get( index );
+ return node.getShort();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveList::setShort( std::size_t index, short value ){
+ PrimitiveValueNode node;
+ node.setShort( value );
+
+ this->set( index, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int PrimitiveList::getInt( std::size_t index ) const
+ throw( IndexOutOfBoundsException ){
+
+ PrimitiveValueNode node = this->get( index );
+ return node.getInt();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveList::setInt( std::size_t index, int value ){
+ PrimitiveValueNode node;
+ node.setInt( value );
+
+ this->set( index, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long PrimitiveList::getLong( std::size_t index ) const
+ throw( IndexOutOfBoundsException ){
+
+ PrimitiveValueNode node = this->get( index );
+ return node.getLong();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveList::setLong( std::size_t index, long long value ){
+ PrimitiveValueNode node;
+ node.setLong( value );
+
+ this->set( index, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double PrimitiveList::getDouble( std::size_t index ) const
+ throw( IndexOutOfBoundsException ){
+
+ PrimitiveValueNode node = this->get( index );
+ return node.getDouble();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveList::setDouble( std::size_t index, double value ){
+ PrimitiveValueNode node;
+ node.setDouble( value );
+
+ this->set( index, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+float PrimitiveList::getFloat( std::size_t index ) const
+ throw( IndexOutOfBoundsException ){
+
+ PrimitiveValueNode node = this->get( index );
+ return node.getFloat();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveList::setFloat( std::size_t index, float value ){
+ PrimitiveValueNode node;
+ node.setFloat( value );
+
+ this->set( index, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+string PrimitiveList::getString( std::size_t index ) const
+ throw( IndexOutOfBoundsException ){
+
+ PrimitiveValueNode node = this->get( index );
+ return node.getString();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveList::setString( std::size_t index, const string& value ){
+ PrimitiveValueNode node;
+ node.setString( value );
+
+ this->set( index, node );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::vector<unsigned char> PrimitiveList::getByteArray( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException ) {
+
+ PrimitiveValueNode node = this->get( index );
+ return node.getByteArray();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveList::setByteArray( std::size_t index,
+ const std::vector<unsigned char>& value ) {
+
+ PrimitiveValueNode node;
+ node.setByteArray( value );
+
+ this->set( index, node );
+}
Added: activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.h?rev=662050&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.h (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveList.h Sat May 31 10:29:16 2008
@@ -0,0 +1,98 @@
+/**
+ * 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_UTIL_PRIMITIVELIST_H_
+#define _ACTIVEMQ_UTIL_PRIMITIVELIST_H_
+
+#include <string>
+#include <vector>
+#include <decaf/util/List.h>
+#include <decaf/lang/exceptions/NoSuchElementException.h>
+#include <stdio.h>
+#include <activemq/util/PrimitiveValueTypes.h>
+#include <activemq/util/PrimitiveValueNode.h>
+
+namespace activemq{
+namespace util{
+
+ /**
+ * List of primitives.
+ */
+ class PrimitiveList : public decaf::util::List<PrimitiveValueNode> {
+ public:
+
+ PrimitiveList();
+ virtual ~PrimitiveList() {}
+
+ /**
+ * Copy Constructor
+ * @param list - the PrimitiveList to copy
+ */
+ PrimitiveList( const PrimitiveList& src );
+
+ /**
+ * Converts the contents into a formatted string that can be output
+ * in a Log File or other debugging tool.
+ * @returns formatted String of all elements in the list.
+ */
+ std::string toString() const;
+
+ virtual bool getBool( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+ virtual void setBool( std::size_t index, bool value );
+
+ virtual unsigned char getByte( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+ virtual void setByte( std::size_t index, unsigned char value );
+
+ virtual char getChar( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+ virtual void setChar( std::size_t index, char value );
+
+ virtual short getShort( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+ virtual void setShort( std::size_t index, short value );
+
+ virtual int getInt( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+ virtual void setInt( std::size_t index, int value );
+
+ virtual long long getLong( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+ virtual void setLong( std::size_t index, long long value );
+
+ virtual double getDouble( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+ virtual void setDouble( std::size_t index, double value );
+
+ virtual float getFloat( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+ virtual void setFloat( std::size_t index, float value );
+
+ virtual std::string getString( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+ virtual void setString( std::size_t index, const std::string& value );
+
+ virtual std::vector<unsigned char> getByteArray( std::size_t index ) const
+ throw( decaf::lang::exceptions::IndexOutOfBoundsException );
+ virtual void setByteArray( std::size_t index, const std::vector<unsigned char>& value );
+
+ };
+
+}}
+
+#endif /*_ACTIVEMQ_UTIL_PRIMITIVELIST_H_*/
Modified: activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveMap.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveMap.cpp?rev=662050&r1=662049&r2=662050&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveMap.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveMap.cpp Sat May 31 10:29:16 2008
@@ -18,6 +18,8 @@
#include "PrimitiveMap.h"
#include <sstream>
+#include <stdio.h>
+#include <string.h>
using namespace activemq;
using namespace activemq::util;
@@ -52,7 +54,7 @@
<< valueNodeMap.getValue( keys[i] ).toString() << std::endl;
}
- stream << "Begin Class PrimitiveMap:" << std::endl;
+ stream << "End Class PrimitiveMap:" << std::endl;
return stream.str();
}
@@ -84,16 +86,16 @@
////////////////////////////////////////////////////////////////////////////////
bool PrimitiveMap::getBool( const string& key ) const
- throw(NoSuchElementException){
+ throw( NoSuchElementException ){
- ValueNode node = valueNodeMap.getValue( key );
+ PrimitiveValueNode node = valueNodeMap.getValue( key );
return node.getBool();
}
////////////////////////////////////////////////////////////////////////////////
void PrimitiveMap::setBool( const string& key, bool value ){
- ValueNode node;
+ PrimitiveValueNode node;
node.setBool( value );
valueNodeMap.setValue( key, node );
@@ -103,13 +105,13 @@
unsigned char PrimitiveMap::getByte( const string& key ) const
throw( NoSuchElementException ){
- ValueNode node = valueNodeMap.getValue( key );
+ PrimitiveValueNode node = valueNodeMap.getValue( key );
return node.getByte();
}
////////////////////////////////////////////////////////////////////////////////
void PrimitiveMap::setByte( const string& key, unsigned char value ){
- ValueNode node;
+ PrimitiveValueNode node;
node.setByte( value );
valueNodeMap.setValue( key, node );
@@ -119,13 +121,13 @@
char PrimitiveMap::getChar( const string& key ) const
throw( NoSuchElementException ){
- ValueNode node = valueNodeMap.getValue( key );
+ PrimitiveValueNode node = valueNodeMap.getValue( key );
return node.getChar();
}
////////////////////////////////////////////////////////////////////////////////
void PrimitiveMap::setChar( const string& key, char value ){
- ValueNode node;
+ PrimitiveValueNode node;
node.setChar( value );
valueNodeMap.setValue( key, node );
@@ -135,13 +137,13 @@
short PrimitiveMap::getShort( const string& key ) const
throw( NoSuchElementException ){
- ValueNode node = valueNodeMap.getValue( key );
+ PrimitiveValueNode node = valueNodeMap.getValue( key );
return node.getShort();
}
////////////////////////////////////////////////////////////////////////////////
void PrimitiveMap::setShort( const string& key, short value ){
- ValueNode node;
+ PrimitiveValueNode node;
node.setShort( value );
valueNodeMap.setValue( key, node );
@@ -151,13 +153,13 @@
int PrimitiveMap::getInt( const string& key ) const
throw( NoSuchElementException ){
- ValueNode node = valueNodeMap.getValue( key );
+ PrimitiveValueNode node = valueNodeMap.getValue( key );
return node.getInt();
}
////////////////////////////////////////////////////////////////////////////////
void PrimitiveMap::setInt( const string& key, int value ){
- ValueNode node;
+ PrimitiveValueNode node;
node.setInt( value );
valueNodeMap.setValue( key, node );
@@ -167,13 +169,13 @@
long long PrimitiveMap::getLong( const string& key ) const
throw( NoSuchElementException ){
- ValueNode node = valueNodeMap.getValue( key );
+ PrimitiveValueNode node = valueNodeMap.getValue( key );
return node.getLong();
}
////////////////////////////////////////////////////////////////////////////////
void PrimitiveMap::setLong( const string& key, long long value ){
- ValueNode node;
+ PrimitiveValueNode node;
node.setLong( value );
valueNodeMap.setValue( key, node );
@@ -183,13 +185,13 @@
double PrimitiveMap::getDouble( const string& key ) const
throw( NoSuchElementException ){
- ValueNode node = valueNodeMap.getValue( key );
+ PrimitiveValueNode node = valueNodeMap.getValue( key );
return node.getDouble();
}
////////////////////////////////////////////////////////////////////////////////
void PrimitiveMap::setDouble( const string& key, double value ){
- ValueNode node;
+ PrimitiveValueNode node;
node.setDouble( value );
valueNodeMap.setValue( key, node );
@@ -199,13 +201,13 @@
float PrimitiveMap::getFloat( const string& key ) const
throw( NoSuchElementException ){
- ValueNode node = valueNodeMap.getValue( key );
+ PrimitiveValueNode node = valueNodeMap.getValue( key );
return node.getFloat();
}
////////////////////////////////////////////////////////////////////////////////
void PrimitiveMap::setFloat( const string& key, float value ){
- ValueNode node;
+ PrimitiveValueNode node;
node.setFloat( value );
valueNodeMap.setValue( key, node );
@@ -215,13 +217,13 @@
string PrimitiveMap::getString( const string& key ) const
throw( NoSuchElementException ){
- ValueNode node = valueNodeMap.getValue( key );
+ PrimitiveValueNode node = valueNodeMap.getValue( key );
return node.getString();
}
////////////////////////////////////////////////////////////////////////////////
void PrimitiveMap::setString( const string& key, const string& value ){
- ValueNode node;
+ PrimitiveValueNode node;
node.setString( value );
valueNodeMap.setValue( key, node );
@@ -231,7 +233,7 @@
std::vector<unsigned char> PrimitiveMap::getByteArray( const std::string& key ) const
throw( decaf::lang::exceptions::NoSuchElementException ) {
- ValueNode node = valueNodeMap.getValue( key );
+ PrimitiveValueNode node = valueNodeMap.getValue( key );
return node.getByteArray();
}
@@ -239,7 +241,7 @@
void PrimitiveMap::setByteArray( const std::string& key,
const std::vector<unsigned char>& value ) {
- ValueNode node;
+ PrimitiveValueNode node;
node.setByteArray( value );
valueNodeMap.setValue( key, node );
@@ -252,18 +254,16 @@
////////////////////////////////////////////////////////////////////////////////
vector<string> PrimitiveMap::getKeys() const{
-
return valueNodeMap.getKeys();
}
////////////////////////////////////////////////////////////////////////////////
-vector<PrimitiveMap::ValueNode> PrimitiveMap::getValues() const{
-
+vector<PrimitiveValueNode> PrimitiveMap::getValues() const{
return valueNodeMap.getValues();
}
////////////////////////////////////////////////////////////////////////////////
-PrimitiveMap::ValueNode PrimitiveMap::getValue( const std::string& key ) const
+PrimitiveValueNode PrimitiveMap::getValue( const std::string& key ) const
throw ( decaf::lang::exceptions::NoSuchElementException ) {
return valueNodeMap.getValue( key );
Modified: activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveMap.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveMap.h?rev=662050&r1=662049&r2=662050&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveMap.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveMap.h Sat May 31 10:29:16 2008
@@ -22,8 +22,8 @@
#include <vector>
#include <decaf/util/Map.h>
#include <decaf/lang/exceptions/NoSuchElementException.h>
-#include <stdio.h>
-#include <string.h>
+#include <activemq/util/PrimitiveValueTypes.h>
+#include <activemq/util/PrimitiveValueNode.h>
namespace activemq{
namespace util{
@@ -32,345 +32,9 @@
* Map of named primitives.
*/
class PrimitiveMap {
- public:
-
- /**
- * Enumeration for the various primitive types.
- */
- enum ValueTypeEnum{
- NULL_TYPE = 0,
- BOOLEAN_TYPE = 1,
- BYTE_TYPE = 2,
- CHAR_TYPE = 3,
- SHORT_TYPE = 4,
- INTEGER_TYPE = 5,
- LONG_TYPE = 6,
- DOUBLE_TYPE = 7,
- FLOAT_TYPE = 8,
- STRING_TYPE = 9,
- BYTE_ARRAY_TYPE = 10,
- MAP_TYPE = 11,
- LIST_TYPE = 12,
- BIG_STRING_TYPE = 13
- };
-
- /**
- * Define a union type comprised of the various types.
- */
- union Value {
-
- bool boolValue;
- unsigned char byteValue;
- char charValue;
- short shortValue;
- int intValue;
- long long longValue;
- double doubleValue;
- float floatValue;
- std::string* stringValue;
- std::vector<unsigned char>* byteArrayValue;
- };
-
- /**
- * Class that wraps around a single value of one of the
- * many types. Manages memory for complex types, such
- * as strings. Note: the destructor was left non-virtual
- * so no virtual table will be created. This probaly isn't
- * necessary, but will avoid needless memory allocation. Since
- * we'll never extend this class, not having a virtual
- * destructor isn't a concern.
- */
- class ValueNode{
- private:
-
- ValueTypeEnum valueType;
- Value value;
-
- public:
-
- ValueNode(){
- valueType = NULL_TYPE;
- memset( &value, 0, sizeof(value) );
- }
-
- ValueNode( const ValueNode& node ){
- valueType = NULL_TYPE;
- memset( &value, 0, sizeof(value) );
- (*this) = node;
- }
-
- ~ValueNode(){
- clear();
- }
-
- ValueNode& operator =( const ValueNode& node ){
- clear();
- valueType = node.valueType;
-
- if( valueType == STRING_TYPE && node.value.stringValue != NULL ){
- value.stringValue = new std::string( *node.value.stringValue );
- } else if( valueType == BYTE_ARRAY_TYPE && node.value.byteArrayValue != NULL ){
- value.byteArrayValue = new std::vector<unsigned char>( *node.value.byteArrayValue );
- } else{
- value = node.value;
- }
-
- return *this;
- }
-
- bool operator==( const ValueNode& node ) const{
-
- if( valueType != node.valueType ) {
- return false;
- }
-
- if( valueType == BOOLEAN_TYPE &&
- value.boolValue == node.value.boolValue ) {
- return true;
- } else if( valueType == BYTE_TYPE &&
- value.byteValue == node.value.byteValue ) {
- return true;
- } else if( valueType == CHAR_TYPE &&
- value.charValue == node.value.charValue ) {
- return true;
- } else if( valueType == SHORT_TYPE &&
- value.shortValue == node.value.shortValue ) {
- return true;
- } else if( valueType == INTEGER_TYPE &&
- value.intValue == node.value.intValue ) {
- return true;
- } else if( valueType == LONG_TYPE &&
- value.longValue == node.value.longValue ) {
- return true;
- } else if( valueType == DOUBLE_TYPE &&
- value.doubleValue == node.value.doubleValue ) {
- return true;
- } else if( valueType == FLOAT_TYPE &&
- value.floatValue == node.value.floatValue ) {
- return true;
- } else if( valueType == STRING_TYPE &&
- *value.stringValue == *node.value.stringValue ) {
- return true;
- } else if( valueType == BYTE_ARRAY_TYPE &&
- *value.byteArrayValue == *node.value.byteArrayValue ) {
- return true;
- }
-
- return false;
- }
-
- ValueTypeEnum getValueType() const { return valueType; }
-
- void clear(){
- if( valueType == STRING_TYPE && value.stringValue != NULL ){
- delete value.stringValue;
- }
- if( valueType == BYTE_ARRAY_TYPE && value.byteArrayValue != NULL ){
- delete value.byteArrayValue;
- }
- valueType = NULL_TYPE;
- memset( &value, 0, sizeof(value) );
- }
-
- void setBool( bool lvalue ){
- clear();
- valueType = BOOLEAN_TYPE;
- value.boolValue = lvalue;
- }
-
- bool getBool() const throw( decaf::lang::exceptions::NoSuchElementException ){
- if( valueType != BOOLEAN_TYPE ){
- throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
- __LINE__, "Value is not BOOLEAN_TYPE" );
- }
-
- return value.boolValue;
- }
-
- void setByte( unsigned char lvalue ){
- clear();
- valueType = BYTE_TYPE;
- value.byteValue = lvalue;
- }
-
- unsigned char getByte() const throw( decaf::lang::exceptions::NoSuchElementException){
- if( valueType != BYTE_TYPE ){
- throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
- __LINE__, "Value is not BYTE_TYPE" );
- }
-
- return value.byteValue;
- }
-
- void setChar( char lvalue ){
- clear();
- valueType = CHAR_TYPE;
- value.charValue = lvalue;
- }
-
- char getChar() const throw(decaf::lang::exceptions::NoSuchElementException){
- if( valueType != CHAR_TYPE ){
- throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
- __LINE__, "Value is not CHAR_TYPE" );
- }
-
- return value.charValue;
- }
-
- void setShort( short lvalue ){
- clear();
- valueType = SHORT_TYPE;
- value.shortValue = lvalue;
- }
-
- short getShort() const throw(decaf::lang::exceptions::NoSuchElementException){
- if( valueType != SHORT_TYPE ){
- throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
- __LINE__, "Value is not SHORT_TYPE" );
- }
-
- return value.shortValue;
- }
-
- void setInt( int lvalue ){
- clear();
- valueType = INTEGER_TYPE;
- value.intValue = lvalue;
- }
-
- int getInt() const throw(decaf::lang::exceptions::NoSuchElementException){
- if( valueType != INTEGER_TYPE ){
- throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
- __LINE__, "Value is not INTEGER_TYPE" );
- }
-
- return value.intValue;
- }
-
- void setLong( long long lvalue ){
- clear();
- valueType = LONG_TYPE;
- value.longValue = lvalue;
- }
-
- long long getLong() const throw(decaf::lang::exceptions::NoSuchElementException){
- if( valueType != LONG_TYPE ){
- throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
- __LINE__, "Value is not LONG_TYPE" );
- }
-
- return value.longValue;
- }
-
- void setDouble( double lvalue ){
- clear();
- valueType = DOUBLE_TYPE;
- value.doubleValue = lvalue;
- }
-
- double getDouble() const throw(decaf::lang::exceptions::NoSuchElementException){
- if( valueType != DOUBLE_TYPE ){
- throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
- __LINE__, "Value is not DOUBLE_TYPE" );
- }
-
- return value.doubleValue;
- }
-
- void setFloat( float lvalue ){
- clear();
- valueType = FLOAT_TYPE;
- value.floatValue = lvalue;
- }
-
- float getFloat() const throw(decaf::lang::exceptions::NoSuchElementException){
- if( valueType != FLOAT_TYPE ){
- throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
- __LINE__, "Value is not FLOAT_TYPE" );
- }
-
- return value.floatValue;
- }
-
- void setString( const std::string& lvalue ){
- clear();
- valueType = STRING_TYPE;
- value.stringValue = new std::string( lvalue );
- }
-
- std::string getString() const throw(decaf::lang::exceptions::NoSuchElementException){
- if( valueType != STRING_TYPE ){
- throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
- __LINE__, "Value is not STRING_TYPE" );
- }
-
- if( value.stringValue == NULL ){
- return std::string();
- }
-
- return *value.stringValue;
- }
-
- void setByteArray( const std::vector<unsigned char>& lvalue ){
- clear();
- valueType = BYTE_ARRAY_TYPE;
- value.byteArrayValue = new std::vector<unsigned char>( lvalue );
- }
-
- std::vector<unsigned char> getByteArray() const throw( decaf::lang::exceptions::NoSuchElementException ) {
-
- if( valueType != BYTE_ARRAY_TYPE ){
- throw decaf::lang::exceptions::NoSuchElementException(
- __FILE__,
- __LINE__,
- "Value is not BYTE_ARRAY_TYPE" );
- }
-
- if( value.byteArrayValue == NULL ){
- return std::vector<unsigned char>();
- }
-
- return *value.byteArrayValue;
- }
-
- std::string toString() const {
- std::ostringstream stream;
-
- if( valueType == BOOLEAN_TYPE ) {
- stream << value.boolValue;
- } else if( valueType == BYTE_TYPE ) {
- stream << value.byteValue;
- } else if( valueType == CHAR_TYPE ) {
- stream << value.charValue;
- } else if( valueType == SHORT_TYPE ) {
- stream << value.shortValue;
- } else if( valueType == INTEGER_TYPE ) {
- stream << value.intValue;
- } else if( valueType == LONG_TYPE ) {
- stream << value.longValue;
- } else if( valueType == DOUBLE_TYPE ) {
- stream << value.doubleValue;
- } else if( valueType == FLOAT_TYPE ) {
- stream << value.floatValue;
- } else if( valueType == STRING_TYPE ) {
- stream << *value.stringValue;
- } else if( valueType == BYTE_ARRAY_TYPE ) {
- std::vector<unsigned char>::const_iterator iter =
- value.byteArrayValue->begin();
- for( ; iter != value.byteArrayValue->end(); ++iter ) {
- stream << '[' << (int)(*iter) << ']';
- }
- }
-
- return stream.str();
- }
-
- };
-
-
private:
- decaf::util::Map<std::string, ValueNode> valueNodeMap;
+ decaf::util::Map<std::string, PrimitiveValueNode> valueNodeMap;
public:
@@ -482,15 +146,15 @@
/**
* @return the entire set of values in this map as a std::vector.
*/
- virtual std::vector<ValueNode> getValues() const;
+ virtual std::vector<PrimitiveValueNode> getValues() const;
/**
* Get a Value from the Map, or throws a NoSuchElementException
* @param key - string key to lookup
- * @returns the concrete Value
+ * @return the concrete Value
* @throws NoSuchElementException
*/
- ValueNode getValue( const std::string& key ) const
+ PrimitiveValueNode getValue( const std::string& key ) const
throw( decaf::lang::exceptions::NoSuchElementException );
};
Added: activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueNode.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueNode.cpp?rev=662050&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueNode.cpp (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueNode.cpp Sat May 31 10:29:16 2008
@@ -0,0 +1,382 @@
+/**
+ * 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 "PrimitiveValueNode.h"
+
+#include <activemq/util/PrimitiveMap.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::util;
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode::PrimitiveValueNode() {
+ valueType = NULL_TYPE;
+ memset( &value, 0, sizeof(value) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode::PrimitiveValueNode( bool value ) {
+ this->setBool( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode::PrimitiveValueNode( unsigned char value ) {
+ this->setByte( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode::PrimitiveValueNode( char value ) {
+ this->setChar( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode::PrimitiveValueNode( short value ) {
+ this->setShort( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode::PrimitiveValueNode( int value ) {
+ this->setInt( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode::PrimitiveValueNode( long long value ) {
+ this->setLong( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode::PrimitiveValueNode( float value ) {
+ this->setFloat( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode::PrimitiveValueNode( double value ) {
+ this->setDouble( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode::PrimitiveValueNode( const char* value ) {
+ if( value == NULL ) {
+ clear();
+ } else {
+ this->setString( string( value ) );
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode::PrimitiveValueNode( const std::string& value ) {
+ this->setString( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode::PrimitiveValueNode( const std::vector<unsigned char>& value ) {
+ this->setByteArray( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode::PrimitiveValueNode( const PrimitiveValueNode& node ){
+ valueType = NULL_TYPE;
+ memset( &value, 0, sizeof(value) );
+ (*this) = node;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrimitiveValueNode& PrimitiveValueNode::operator =( const PrimitiveValueNode& node ){
+ clear();
+ valueType = node.valueType;
+
+ if( valueType == STRING_TYPE && node.value.stringValue != NULL ){
+ value.stringValue = new std::string( *node.value.stringValue );
+ } else if( valueType == BYTE_ARRAY_TYPE && node.value.byteArrayValue != NULL ){
+ value.byteArrayValue = new std::vector<unsigned char>( *node.value.byteArrayValue );
+ } else{
+ value = node.value;
+ }
+
+ return *this;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool PrimitiveValueNode::operator==( const PrimitiveValueNode& node ) const{
+
+ if( valueType != node.valueType ) {
+ return false;
+ }
+
+ if( valueType == BOOLEAN_TYPE &&
+ value.boolValue == node.value.boolValue ) {
+ return true;
+ } else if( valueType == BYTE_TYPE &&
+ value.byteValue == node.value.byteValue ) {
+ return true;
+ } else if( valueType == CHAR_TYPE &&
+ value.charValue == node.value.charValue ) {
+ return true;
+ } else if( valueType == SHORT_TYPE &&
+ value.shortValue == node.value.shortValue ) {
+ return true;
+ } else if( valueType == INTEGER_TYPE &&
+ value.intValue == node.value.intValue ) {
+ return true;
+ } else if( valueType == LONG_TYPE &&
+ value.longValue == node.value.longValue ) {
+ return true;
+ } else if( valueType == DOUBLE_TYPE &&
+ value.doubleValue == node.value.doubleValue ) {
+ return true;
+ } else if( valueType == FLOAT_TYPE &&
+ value.floatValue == node.value.floatValue ) {
+ return true;
+ } else if( valueType == STRING_TYPE &&
+ *value.stringValue == *node.value.stringValue ) {
+ return true;
+ } else if( valueType == BYTE_ARRAY_TYPE &&
+ *value.byteArrayValue == *node.value.byteArrayValue ) {
+ return true;
+ }
+
+ return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveValueNode::clear(){
+ if( valueType == STRING_TYPE && value.stringValue != NULL ){
+ delete value.stringValue;
+ }
+ if( valueType == BYTE_ARRAY_TYPE && value.byteArrayValue != NULL ){
+ delete value.byteArrayValue;
+ }
+ valueType = NULL_TYPE;
+ memset( &value, 0, sizeof(value) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveValueNode::setBool( bool lvalue ){
+ clear();
+ valueType = BOOLEAN_TYPE;
+ value.boolValue = lvalue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool PrimitiveValueNode::getBool() const
+ throw( decaf::lang::exceptions::NoSuchElementException ){
+
+ if( valueType != BOOLEAN_TYPE ){
+ throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
+ __LINE__, "PrimitiveValue is not BOOLEAN_TYPE" );
+ }
+
+ return value.boolValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveValueNode::setByte( unsigned char lvalue ){
+ clear();
+ valueType = BYTE_TYPE;
+ value.byteValue = lvalue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned char PrimitiveValueNode::getByte() const throw( decaf::lang::exceptions::NoSuchElementException){
+ if( valueType != BYTE_TYPE ){
+ throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
+ __LINE__, "PrimitiveValue is not BYTE_TYPE" );
+ }
+
+ return value.byteValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveValueNode::setChar( char lvalue ){
+ clear();
+ valueType = CHAR_TYPE;
+ value.charValue = lvalue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+char PrimitiveValueNode::getChar() const throw(decaf::lang::exceptions::NoSuchElementException){
+ if( valueType != CHAR_TYPE ){
+ throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
+ __LINE__, "PrimitiveValue is not CHAR_TYPE" );
+ }
+
+ return value.charValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveValueNode::setShort( short lvalue ){
+ clear();
+ valueType = SHORT_TYPE;
+ value.shortValue = lvalue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+short PrimitiveValueNode::getShort() const throw(decaf::lang::exceptions::NoSuchElementException){
+ if( valueType != SHORT_TYPE ){
+ throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
+ __LINE__, "PrimitiveValue is not SHORT_TYPE" );
+ }
+
+ return value.shortValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveValueNode::setInt( int lvalue ){
+ clear();
+ valueType = INTEGER_TYPE;
+ value.intValue = lvalue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int PrimitiveValueNode::getInt() const throw(decaf::lang::exceptions::NoSuchElementException){
+ if( valueType != INTEGER_TYPE ){
+ throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
+ __LINE__, "PrimitiveValue is not INTEGER_TYPE" );
+ }
+
+ return value.intValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveValueNode::setLong( long long lvalue ){
+ clear();
+ valueType = LONG_TYPE;
+ value.longValue = lvalue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long PrimitiveValueNode::getLong() const throw(decaf::lang::exceptions::NoSuchElementException){
+ if( valueType != LONG_TYPE ){
+ throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
+ __LINE__, "PrimitiveValue is not LONG_TYPE" );
+ }
+
+ return value.longValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveValueNode::setDouble( double lvalue ){
+ clear();
+ valueType = DOUBLE_TYPE;
+ value.doubleValue = lvalue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double PrimitiveValueNode::getDouble() const throw(decaf::lang::exceptions::NoSuchElementException){
+ if( valueType != DOUBLE_TYPE ){
+ throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
+ __LINE__, "PrimitiveValue is not DOUBLE_TYPE" );
+ }
+
+ return value.doubleValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveValueNode::setFloat( float lvalue ){
+ clear();
+ valueType = FLOAT_TYPE;
+ value.floatValue = lvalue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+float PrimitiveValueNode::getFloat() const throw(decaf::lang::exceptions::NoSuchElementException){
+ if( valueType != FLOAT_TYPE ){
+ throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
+ __LINE__, "PrimitiveValue is not FLOAT_TYPE" );
+ }
+
+ return value.floatValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveValueNode::setString( const std::string& lvalue ){
+ clear();
+ valueType = STRING_TYPE;
+ value.stringValue = new std::string( lvalue );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string PrimitiveValueNode::getString() const throw(decaf::lang::exceptions::NoSuchElementException){
+ if( valueType != STRING_TYPE ){
+ throw decaf::lang::exceptions::NoSuchElementException( __FILE__,
+ __LINE__, "PrimitiveValue is not STRING_TYPE" );
+ }
+
+ if( value.stringValue == NULL ){
+ return std::string();
+ }
+
+ return *value.stringValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrimitiveValueNode::setByteArray( const std::vector<unsigned char>& lvalue ){
+ clear();
+ valueType = BYTE_ARRAY_TYPE;
+ value.byteArrayValue = new std::vector<unsigned char>( lvalue );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::vector<unsigned char> PrimitiveValueNode::getByteArray() const throw( decaf::lang::exceptions::NoSuchElementException ) {
+
+ if( valueType != BYTE_ARRAY_TYPE ){
+ throw decaf::lang::exceptions::NoSuchElementException(
+ __FILE__,
+ __LINE__,
+ "PrimitiveValue is not BYTE_ARRAY_TYPE" );
+ }
+
+ if( value.byteArrayValue == NULL ){
+ return std::vector<unsigned char>();
+ }
+
+ return *value.byteArrayValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string PrimitiveValueNode::toString() const {
+ std::ostringstream stream;
+
+ if( valueType == BOOLEAN_TYPE ) {
+ stream << std::boolalpha << value.boolValue;
+ } else if( valueType == BYTE_TYPE ) {
+ stream << value.byteValue;
+ } else if( valueType == CHAR_TYPE ) {
+ stream << value.charValue;
+ } else if( valueType == SHORT_TYPE ) {
+ stream << value.shortValue;
+ } else if( valueType == INTEGER_TYPE ) {
+ stream << value.intValue;
+ } else if( valueType == LONG_TYPE ) {
+ stream << value.longValue;
+ } else if( valueType == DOUBLE_TYPE ) {
+ stream << value.doubleValue;
+ } else if( valueType == FLOAT_TYPE ) {
+ stream << value.floatValue;
+ } else if( valueType == STRING_TYPE ) {
+ stream << *value.stringValue;
+ } else if( valueType == BYTE_ARRAY_TYPE ) {
+ std::vector<unsigned char>::const_iterator iter =
+ value.byteArrayValue->begin();
+ for( ; iter != value.byteArrayValue->end(); ++iter ) {
+ stream << '[' << (int)(*iter) << ']';
+ }
+ }
+
+ return stream.str();
+}
Added: activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueNode.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueNode.h?rev=662050&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueNode.h (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueNode.h Sat May 31 10:29:16 2008
@@ -0,0 +1,244 @@
+/**
+ * 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_UTIL_PRIMITIVEVALUENODE_H_
+#define _ACTIVEMQ_UTIL_PRIMITIVEVALUENODE_H_
+
+#include <activemq/util/PrimitiveValueTypes.h>
+#include <decaf/lang/exceptions/NoSuchElementException.h>
+
+namespace activemq{
+namespace util{
+
+ class PrimitiveMap;
+ class PrimitiveList;
+
+ /**
+ * Class that wraps around a single value of one of the
+ * many types. Manages memory for complex types, such
+ * as strings. Note: the destructor was left non-virtual
+ * so no virtual table will be created. This probaly isn't
+ * necessary, but will avoid needless memory allocation. Since
+ * we'll never extend this class, not having a virtual
+ * destructor isn't a concern.
+ */
+ class PrimitiveValueNode {
+ public:
+
+ /**
+ * Define a union type comprised of the various types.
+ */
+ union PrimitiveValue {
+
+ bool boolValue;
+ unsigned char byteValue;
+ char charValue;
+ short shortValue;
+ int intValue;
+ long long longValue;
+ double doubleValue;
+ float floatValue;
+ std::string* stringValue;
+ PrimitiveMap* mapValue;
+ PrimitiveList* listValue;
+ std::vector<unsigned char>* byteArrayValue;
+
+ };
+
+ private:
+
+ PrimitiveValueTypeEnum valueType;
+ PrimitiveValue value;
+
+ public:
+
+ /**
+ * Default Constructor, creates a value of the NULL_TYPE.
+ */
+ PrimitiveValueNode();
+
+ /**
+ * Boolean Value Constructor
+ * @param value - the new value to store.
+ */
+ PrimitiveValueNode( bool value );
+
+ /**
+ * Byte Value Constructor
+ * @param value - the new value to store.
+ */
+ PrimitiveValueNode( unsigned char value );
+
+ /**
+ * Char Value Constructor
+ * @param value - the new value to store.
+ */
+ PrimitiveValueNode( char value );
+
+ /**
+ * Short Value Constructor
+ * @param value - the new value to store.
+ */
+ PrimitiveValueNode( short value );
+
+ /**
+ * Int Value Constructor
+ * @param value - the new value to store.
+ */
+ PrimitiveValueNode( int value );
+
+ /**
+ * Long Value Constructor
+ * @param value - the new value to store.
+ */
+ PrimitiveValueNode( long long value );
+
+ /**
+ * Float Value Constructor
+ * @param value - the new value to store.
+ */
+ PrimitiveValueNode( float value );
+
+ /**
+ * Double Value Constructor
+ * @param value - the new value to store.
+ */
+ PrimitiveValueNode( double value );
+
+ /**
+ * String Value Constructor
+ * @param value - the new value to store.
+ */
+ PrimitiveValueNode( const char* value );
+
+ /**
+ * String Value Constructor
+ * @param value - the new value to store.
+ */
+ PrimitiveValueNode( const std::string& value );
+
+ /**
+ * Byte Array Value Constructor
+ * @param value - the new value to store.
+ */
+ PrimitiveValueNode( const std::vector<unsigned char>& value );
+
+ /**
+ * Copy constructor
+ * @param another node to copy.
+ */
+ PrimitiveValueNode( const PrimitiveValueNode& node );
+
+ /**
+ * Destructor, clears the data before destruction to free any data
+ * in the PrimitiveValue union.
+ */
+ ~PrimitiveValueNode(){
+ clear();
+ }
+
+ /**
+ * Assignment operator, copies the data from the other node.
+ */
+ PrimitiveValueNode& operator =( const PrimitiveValueNode& node );
+
+ /**
+ * Comparison Operator, compares this node to the other node.
+ * @return true if the values are the same false otherwise.
+ */
+ bool operator==( const PrimitiveValueNode& node ) const;
+
+ /**
+ * Gets the Value Type of this type wrapper.
+ * @return the PrimtiveValueTypeEnum value for this wrapper.
+ */
+ PrimitiveValueTypeEnum getValueType() const { return valueType; }
+
+ /**
+ * Gets the internal Primitive Value object from this wrapper.
+ * @return a copy of the contianed PrimitiveValue
+ */
+ PrimitiveValue getValue() const {
+ return this->value;
+ }
+
+ /**
+ * Sets the internal PrimitiveVale object to the new value
+ * along with the tag for the type that it consists of.
+ */
+ void setValue( const PrimitiveValue& value, PrimitiveValueTypeEnum valueType ) {
+ this->value = value;
+ this->valueType = valueType;
+ }
+
+ /**
+ * Clears the value from this wrapper converting it back to a blank
+ * NULL_TYPE value.
+ */
+ void clear();
+
+ void setBool( bool lvalue );
+ bool getBool() const
+ throw( decaf::lang::exceptions::NoSuchElementException );
+
+ void setByte( unsigned char lvalue );
+ unsigned char getByte() const
+ throw( decaf::lang::exceptions::NoSuchElementException );
+
+ void setChar( char lvalue );
+ char getChar() const
+ throw( decaf::lang::exceptions::NoSuchElementException );
+
+ void setShort( short lvalue );
+ short getShort() const
+ throw( decaf::lang::exceptions::NoSuchElementException );
+
+ void setInt( int lvalue );
+ int getInt() const
+ throw( decaf::lang::exceptions::NoSuchElementException );
+
+ void setLong( long long lvalue );
+ long long getLong() const
+ throw( decaf::lang::exceptions::NoSuchElementException );
+
+ void setDouble( double lvalue );
+ double getDouble() const
+ throw(decaf::lang::exceptions::NoSuchElementException );
+
+ void setFloat( float lvalue );
+ float getFloat() const
+ throw( decaf::lang::exceptions::NoSuchElementException );
+
+ void setString( const std::string& lvalue );
+ std::string getString() const
+ throw( decaf::lang::exceptions::NoSuchElementException );
+
+ void setByteArray( const std::vector<unsigned char>& lvalue );
+ std::vector<unsigned char> getByteArray() const
+ throw( decaf::lang::exceptions::NoSuchElementException );
+
+ /**
+ * Creates a string representation of this value.
+ * @return string value of this type wrapper.
+ */
+ std::string toString() const;
+
+ };
+
+}}
+
+#endif /*_ACTIVEMQ_UTIL_PRIMITIVEVALUENODE_H_*/
Added: activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueTypes.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueTypes.h?rev=662050&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueTypes.h (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/util/PrimitiveValueTypes.h Sat May 31 10:29:16 2008
@@ -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_UTIL_PRIMITIVEVALUETYPES_H_
+#define _ACTIVEMQ_UTIL_PRIMITIVEVALUETYPES_H_
+
+#include <string>
+#include <vector>
+
+namespace activemq{
+namespace util{
+
+ class PrimitiveMap;
+ class PrimitiveList;
+
+ /**
+ * Enumeration for the various primitive types.
+ */
+ enum PrimitiveValueTypeEnum{
+ NULL_TYPE = 0,
+ BOOLEAN_TYPE = 1,
+ BYTE_TYPE = 2,
+ CHAR_TYPE = 3,
+ SHORT_TYPE = 4,
+ INTEGER_TYPE = 5,
+ LONG_TYPE = 6,
+ DOUBLE_TYPE = 7,
+ FLOAT_TYPE = 8,
+ STRING_TYPE = 9,
+ BYTE_ARRAY_TYPE = 10,
+ MAP_TYPE = 11,
+ LIST_TYPE = 12,
+ BIG_STRING_TYPE = 13
+ };
+
+}}
+
+#endif /*_ACTIVEMQ_UTIL_PRIMITIVEVALUETYPES_H_*/
Modified: activemq/activemq-cpp/trunk/src/main/decaf/util/List.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/List.h?rev=662050&r1=662049&r2=662050&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/util/List.h (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/util/List.h Sat May 31 10:29:16 2008
@@ -105,6 +105,16 @@
virtual ~List(){}
/**
+ * Comparison, equality is dependant on the method of determining
+ * if the element are equal.
+ * @param source - List to compare to this one.
+ * @returns true if the List passed is equal in value to this one.
+ */
+ virtual bool equals( const List& source ) const {
+ return this->values == source.values;
+ }
+
+ /**
* Returns an iterator for this collection. The order of Iteration
* is in no particular order other than the natural ording of the
* elements in the List class.
Modified: activemq/activemq-cpp/trunk/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/Makefile.am?rev=662050&r1=662049&r2=662050&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/test/Makefile.am Sat May 31 10:29:16 2008
@@ -70,6 +70,8 @@
activemq/transport/filters/ResponseCorrelatorTest.cpp \
activemq/transport/TransportFactoryMapRegistrarTest.cpp \
activemq/transport/TransportFactoryMapTest.cpp \
+ activemq/util/PrimitiveValueNodeTest.cpp \
+ activemq/util/PrimitiveListTest.cpp \
activemq/util/PrimitiveMapTest.cpp \
activemq/util/URISupportTest.cpp \
activemq/util/LongSequenceGeneratorTest.cpp \
@@ -114,6 +116,7 @@
decaf/util/RandomTest.cpp \
decaf/util/MapTest.cpp \
decaf/util/QueueTest.cpp \
+ decaf/util/ListTest.cpp \
decaf/util/SetTest.cpp \
decaf/util/concurrent/CountDownLatchTest.cpp \
decaf/util/concurrent/MutexTest.cpp \
@@ -123,6 +126,65 @@
main.cpp
h_sources = \
+ activemq/connector/ConnectorFactoryMapRegistrarTest.h \
+ activemq/connector/ConnectorFactoryMapTest.h \
+ activemq/connector/stomp/commands/AbortCommandTest.h \
+ activemq/connector/stomp/commands/AckCommandTest.h \
+ activemq/connector/stomp/commands/BeginCommandTest.h \
+ activemq/connector/stomp/commands/BytesMessageCommandTest.h \
+ activemq/connector/stomp/commands/CommandConstantsTest.h \
+ activemq/connector/stomp/commands/CommitCommandTest.h \
+ activemq/connector/stomp/commands/ConnectCommandTest.h \
+ activemq/connector/stomp/commands/ConnectedCommandTest.h \
+ activemq/connector/stomp/commands/DisconnectCommandTest.h \
+ activemq/connector/stomp/commands/ErrorCommandTest.h \
+ activemq/connector/stomp/commands/MessageCommandTest.h \
+ activemq/connector/stomp/commands/ReceiptCommandTest.h \
+ activemq/connector/stomp/commands/SubscribeCommandTest.h \
+ activemq/connector/stomp/commands/TextMessageCommandTest.h \
+ activemq/connector/stomp/commands/UnsubscribeCommandTest.h \
+ activemq/connector/stomp/marshal/MarshalerTest.h \
+ activemq/connector/stomp/StompCommandReaderTest.h \
+ activemq/connector/stomp/StompCommandWriterTest.h \
+ activemq/connector/stomp/StompConnectorTest.h \
+ activemq/connector/stomp/StompFrameTest.h \
+ activemq/connector/stomp/StompDestinationTest.h \
+ activemq/connector/stomp/StompSessionManagerTest.h \
+ activemq/connector/openwire/OpenWireFormatTest.h \
+ activemq/connector/openwire/marshal/PrimitiveMapMarshallerTest.h \
+ activemq/connector/openwire/marshal/BaseDataStreamMarshallerTest.h \
+ activemq/connector/openwire/utils/HexTableTest.h \
+ activemq/connector/openwire/utils/BooleanStreamTest.h \
+ activemq/connector/openwire/utils/OpenwireStringSupportTest.h \
+ activemq/connector/openwire/commands/ActiveMQBytesMessageTest.h \
+ activemq/connector/openwire/commands/ActiveMQMapMessageTest.h \
+ activemq/connector/openwire/commands/ActiveMQMessageTest.h \
+ activemq/connector/openwire/commands/ActiveMQDestinationTest2.h \
+ activemq/connector/openwire/commands/ActiveMQTopicTest.h \
+ activemq/connector/openwire/commands/ActiveMQQueueTest.h \
+ activemq/connector/openwire/commands/ActiveMQTempTopicTest.h \
+ activemq/connector/openwire/commands/ActiveMQTempQueueTest.h \
+ activemq/connector/openwire/commands/ActiveMQTextMessageTest.h \
+ activemq/connector/openwire/commands/BrokerIdTest.h \
+ activemq/connector/openwire/commands/BrokerInfoTest.h \
+ activemq/core/ActiveMQConnectionFactoryTest.h \
+ activemq/core/ActiveMQConnectionTest.h \
+ activemq/core/ActiveMQSessionTest.h \
+ activemq/cmsutil/DynamicDestinationResolverTest.h \
+ activemq/cmsutil/CmsAccessorTest.h \
+ activemq/cmsutil/CmsDestinationAccessorTest.h \
+ activemq/cmsutil/SessionPoolTest.h \
+ activemq/cmsutil/CmsTemplateTest.h \
+ activemq/exceptions/ActiveMQExceptionTest.h \
+ activemq/transport/IOTransportTest.h \
+ activemq/transport/filters/ResponseCorrelatorTest.h \
+ activemq/transport/TransportFactoryMapRegistrarTest.h \
+ activemq/transport/TransportFactoryMapTest.h \
+ activemq/util/PrimitiveValueNodeTest.h \
+ activemq/util/PrimitiveListTest.h \
+ activemq/util/PrimitiveMapTest.h \
+ activemq/util/URISupportTest.h \
+ activemq/util/LongSequenceGeneratorTest.h \
decaf/internal/util/ByteArrayAdapterTest.h \
decaf/internal/nio/ByteArrayPerspectiveTest.h \
decaf/internal/nio/ByteArrayBufferTest.h \
@@ -162,6 +224,7 @@
decaf/util/DateTest.h \
decaf/util/UUIDTest.h \
decaf/util/RandomTest.h \
+ decaf/util/ListTest.h \
decaf/util/MapTest.h \
decaf/util/QueueTest.h \
decaf/util/SetTest.h \
@@ -170,14 +233,14 @@
decaf/util/concurrent/ThreadPoolTest.h \
decaf/nio/BufferTest.h
-include activemq/connector/openwire/marshal/v1/srcmakefile.mk
-include activemq/connector/openwire/marshal/v2/srcmakefile.mk
+##include activemq/connector/openwire/marshal/v1/srcmakefile.mk
+##include activemq/connector/openwire/marshal/v2/srcmakefile.mk
## Compile this as part of make check
check_PROGRAMS = activemq-test
## Also run the tests as part of make check
-## TESTS = $(check_PROGRAMS)
+TESTS = $(check_PROGRAMS)
##
## Compiler/Linker Options
Modified: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsAccessorTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsAccessorTest.cpp?rev=662050&r1=662049&r2=662050&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsAccessorTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsAccessorTest.cpp Sat May 31 10:29:16 2008
@@ -20,8 +20,6 @@
#include <activemq/cmsutil/ResourceLifecycleManager.h>
#include "DummyConnectionFactory.h"
-CPPUNIT_TEST_SUITE_REGISTRATION( activemq::cmsutil::CmsAccessorTest );
-
using namespace activemq;
using namespace activemq::cmsutil;
@@ -33,7 +31,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-void CmsAccessorTest::tearDown() {
+void CmsAccessorTest::tearDown() {
delete accessor;
delete cf;
}
@@ -48,10 +46,10 @@
void CmsAccessorTest::testAckMode() {
CPPUNIT_ASSERT(accessor->getSessionAcknowledgeMode() == cms::Session::AUTO_ACKNOWLEDGE);
-
+
accessor->setSessionAcknowledgeMode(cms::Session::CLIENT_ACKNOWLEDGE);
-
- CPPUNIT_ASSERT(accessor->getSessionAcknowledgeMode() == cms::Session::CLIENT_ACKNOWLEDGE) ;
+
+ CPPUNIT_ASSERT(accessor->getSessionAcknowledgeMode() == cms::Session::CLIENT_ACKNOWLEDGE) ;
}
////////////////////////////////////////////////////////////////////////////////
@@ -59,17 +57,17 @@
cms::Connection* c = accessor->createConnection();
CPPUNIT_ASSERT( c != NULL);
-
+
cms::Session* s = accessor->createSession(c);
CPPUNIT_ASSERT( s != NULL);
-
+
CPPUNIT_ASSERT(s->getAcknowledgeMode() == cms::Session::AUTO_ACKNOWLEDGE);
-
+
accessor->setSessionAcknowledgeMode(cms::Session::CLIENT_ACKNOWLEDGE);
-
+
s = accessor->createSession(c);
CPPUNIT_ASSERT( s != NULL);
-
+
CPPUNIT_ASSERT(s->getAcknowledgeMode() == cms::Session::CLIENT_ACKNOWLEDGE);
}
Modified: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsDestinationAccessorTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsDestinationAccessorTest.cpp?rev=662050&r1=662049&r2=662050&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsDestinationAccessorTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsDestinationAccessorTest.cpp Sat May 31 10:29:16 2008
@@ -20,8 +20,6 @@
#include <activemq/cmsutil/ResourceLifecycleManager.h>
#include "DummyConnectionFactory.h"
-CPPUNIT_TEST_SUITE_REGISTRATION( activemq::cmsutil::CmsDestinationAccessorTest );
-
using namespace activemq;
using namespace activemq::cmsutil;
@@ -43,28 +41,28 @@
void CmsDestinationAccessorTest::test() {
DummySession s(NULL);
-
+
// Create a queue destination
cms::Destination* d = accessor->resolveDestinationName(&s, "hello");
CPPUNIT_ASSERT( d != NULL );
-
+
// Make sure it's a queue.
cms::Queue* queue1 = dynamic_cast<cms::Queue*>(d);
CPPUNIT_ASSERT( queue1 != NULL );
-
+
// Get the same queue again and make sure it's the same object
d = accessor->resolveDestinationName(&s, "hello");
cms::Queue* queue2 = dynamic_cast<cms::Queue*>(d);
CPPUNIT_ASSERT( queue2 == queue1 );
-
+
// Change type to topics
accessor->setPubSubDomain(true);
CPPUNIT_ASSERT( accessor->isPubSubDomain() == true );
-
+
// Get the same dest and make sure it's a topic.
d = accessor->resolveDestinationName(&s, "hello");
cms::Topic* topic1 = dynamic_cast<cms::Topic*>(d);
- CPPUNIT_ASSERT( topic1 != NULL );
+ CPPUNIT_ASSERT( topic1 != NULL );
}
Modified: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.cpp?rev=662050&r1=662049&r2=662050&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/CmsTemplateTest.cpp Sat May 31 10:29:16 2008
@@ -21,8 +21,6 @@
#include "DummyConnectionFactory.h"
#include "DummyMessageCreator.h"
-CPPUNIT_TEST_SUITE_REGISTRATION( activemq::cmsutil::CmsTemplateTest );
-
using namespace activemq;
using namespace activemq::cmsutil;
Modified: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DynamicDestinationResolverTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DynamicDestinationResolverTest.cpp?rev=662050&r1=662049&r2=662050&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DynamicDestinationResolverTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/DynamicDestinationResolverTest.cpp Sat May 31 10:29:16 2008
@@ -20,70 +20,68 @@
#include <activemq/cmsutil/ResourceLifecycleManager.h>
#include "DummySession.h"
-CPPUNIT_TEST_SUITE_REGISTRATION( activemq::cmsutil::DynamicDestinationResolverTest );
-
using namespace activemq;
using namespace activemq::cmsutil;
////////////////////////////////////////////////////////////////////////////////
void DynamicDestinationResolverTest::testTopics() {
- ResourceLifecycleManager mgr;
+ ResourceLifecycleManager mgr;
DynamicDestinationResolver resolver;
resolver.init(&mgr);
-
+
DummySession session(NULL);
-
+
// Test topic
- cms::Destination* testTopic = dynamic_cast<cms::Topic*>(resolver.resolveDestinationName(&session,
+ cms::Destination* testTopic = dynamic_cast<cms::Topic*>(resolver.resolveDestinationName(&session,
(std::string)"test", true ));
-
+
CPPUNIT_ASSERT(testTopic != NULL);
-
+
// Hello topic
- cms::Destination* helloTopic = resolver.resolveDestinationName(&session,
+ cms::Destination* helloTopic = resolver.resolveDestinationName(&session,
(std::string)"hello", true );
-
+
CPPUNIT_ASSERT(helloTopic != NULL);
CPPUNIT_ASSERT(helloTopic != testTopic);
-
- cms::Destination* testTopic2 = dynamic_cast<cms::Topic*>(resolver.resolveDestinationName(&session,
+
+ cms::Destination* testTopic2 = dynamic_cast<cms::Topic*>(resolver.resolveDestinationName(&session,
(std::string)"test", true ));
-
+
CPPUNIT_ASSERT(testTopic2 != NULL);
CPPUNIT_ASSERT(testTopic == testTopic2);
-
+
mgr.destroy();
-
+
}
////////////////////////////////////////////////////////////////////////////////
void DynamicDestinationResolverTest::testQueues() {
- ResourceLifecycleManager mgr;
+ ResourceLifecycleManager mgr;
DynamicDestinationResolver resolver;
resolver.init(&mgr);
-
+
DummySession session(NULL);
-
+
// Queue topic
- cms::Destination* testQueue = dynamic_cast<cms::Queue*>(resolver.resolveDestinationName(&session,
+ cms::Destination* testQueue = dynamic_cast<cms::Queue*>(resolver.resolveDestinationName(&session,
(std::string)"test", false ));
-
+
CPPUNIT_ASSERT(testQueue != NULL);
-
+
// Hello queue
- cms::Destination* helloQueue = resolver.resolveDestinationName(&session,
+ cms::Destination* helloQueue = resolver.resolveDestinationName(&session,
(std::string)"hello", false );
-
+
CPPUNIT_ASSERT(helloQueue != NULL);
CPPUNIT_ASSERT(helloQueue != testQueue);
-
- cms::Destination* testQueue2 = dynamic_cast<cms::Queue*>(resolver.resolveDestinationName(&session,
+
+ cms::Destination* testQueue2 = dynamic_cast<cms::Queue*>(resolver.resolveDestinationName(&session,
(std::string)"test", false ));
-
+
CPPUNIT_ASSERT(testQueue2 != NULL);
CPPUNIT_ASSERT(testQueue == testQueue2);
-
+
mgr.destroy();
}