activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r589108 - /activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp
Date Sat, 27 Oct 2007 14:09:35 GMT
Author: tabish
Date: Sat Oct 27 07:09:34 2007
New Revision: 589108

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

Little more cleanup

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

Modified: activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp?rev=589108&r1=589107&r2=589108&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/openwire/marshal/BaseDataStreamMarshaller.cpp
Sat Oct 27 07:09:34 2007
@@ -300,8 +300,7 @@
     try{
 
         dataOut->writeBoolean( value != "" );
-        if( value != "" )
-        {
+        if( value != "" ) {
             dataOut->writeUTF( value );
         }
     }
@@ -334,29 +333,24 @@
 
     try{
 
-        if( value == 0L )
-        {
+        if( value == 0L ) {
+
             bs->writeBoolean( false );
             bs->writeBoolean( false );
             return 0;
-        }
-        else
-        {
+
+        } else {
+
             unsigned long long ul = (unsigned long long)value;
-            if( (ul & 0xFFFFFFFFFFFF0000LL) == 0LL )
-            {
+            if( (ul & 0xFFFFFFFFFFFF0000ULL) == 0ULL ) {
                 bs->writeBoolean(false);
                 bs->writeBoolean(true);
                 return 2;
-            }
-            else if( (ul & 0xFFFFFFFF00000000LL) == 0LL )
-            {
+            } else if( (ul & 0xFFFFFFFF00000000ULL) == 0ULL ) {
                 bs->writeBoolean(true);
                 bs->writeBoolean(false);
                 return 4;
-            }
-            else
-            {
+            } else {
                 bs->writeBoolean(true);
                 bs->writeBoolean(true);
                 return 8;
@@ -415,7 +409,7 @@
         } else {
 
             if( bs->readBoolean()) {
-                return (unsigned short)dataIn->readShort();
+                return dataIn->readUnsignedShort();
             } else {
                 return 0;
             }
@@ -447,7 +441,6 @@
         throw ( io::IOException ) {
 
     try{
-
         return dataIn->readLong();
     }
     AMQ_CATCH_RETHROW( IOException )
@@ -463,20 +456,19 @@
 
     try{
 
-        if( bs->readBoolean() )
-        {
+        if( bs->readBoolean() ) {
+
             BrokerError* answer = new BrokerError();
 
             answer->setExceptionClass( tightUnmarshalString( dataIn, bs ) );
             answer->setMessage( tightUnmarshalString( dataIn, bs ) );
 
-            if( wireFormat->isStackTraceEnabled() )
-            {
+            if( wireFormat->isStackTraceEnabled() ) {
                 short length = dataIn->readShort();
                 std::vector< BrokerError::StackTraceElement* > stackTrace;
 
-                for( int i = 0; i < length; ++i )
-                {
+                for( int i = 0; i < length; ++i ) {
+
                     BrokerError::StackTraceElement* element =
                         new BrokerError::StackTraceElement;
 
@@ -486,14 +478,15 @@
                     element->LineNumber = dataIn->readInt();
                     stackTrace.push_back( element );
                 }
+
                 answer->setStackTraceElements( stackTrace );
                 answer->setCause( dynamic_cast<BrokerError*>(
                     tightUnmarshalBrokerError( wireFormat, dataIn, bs ) ) );
             }
+
             return answer;
-        }
-        else
-        {
+
+        } else {
             return NULL;
         }
     }
@@ -507,8 +500,8 @@
     OpenWireFormat* wireFormat,
     commands::DataStructure* data,
     utils::BooleanStream* bs )
-        throw ( io::IOException )
-{
+        throw ( io::IOException ) {
+
     try{
 
         BrokerError* error = dynamic_cast<BrokerError*>( data );
@@ -714,6 +707,7 @@
         throw ( io::IOException ) {
 
     try{
+
         if( dataIn->readBoolean() ) {
             int size = dataIn->readInt();
             std::vector<unsigned char> data;
@@ -765,8 +759,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string BaseDataStreamMarshaller::toString( const commands::MessageId* id )
-{
+std::string BaseDataStreamMarshaller::toString( const commands::MessageId* id ) {
     if( id == NULL ) return "";
 
     return toString( id->getProducerId() ) + ":" +
@@ -774,27 +767,23 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string BaseDataStreamMarshaller::toString( const commands::ProducerId* id )
-{
+std::string BaseDataStreamMarshaller::toString( const commands::ProducerId* id ) {
     return id->getConnectionId() + ":" +
            Long::toString( id->getSessionId() ) + ":" +
            Long::toString( id->getValue() );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string BaseDataStreamMarshaller::toString( const commands::TransactionId* txnId )
-{
+std::string BaseDataStreamMarshaller::toString( const commands::TransactionId* txnId ) {
+
     const LocalTransactionId* ltxnId =
         dynamic_cast<const LocalTransactionId*>( txnId );
     const XATransactionId* xaTxnId =
         dynamic_cast<const XATransactionId*>( txnId );
 
-    if( ltxnId != NULL )
-    {
+    if( ltxnId != NULL ) {
         return Long::toString( ltxnId->getValue() );
-    }
-    else if( xaTxnId != NULL )
-    {
+    } else if( xaTxnId != NULL ) {
         return string("XID:") + Integer::toString( xaTxnId->getFormatId() ) + ":" +
                toHexFromBytes( xaTxnId->getGlobalTransactionId() ) + ":" +
                toHexFromBytes( xaTxnId->getBranchQualifier() );
@@ -805,12 +794,11 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 std::string BaseDataStreamMarshaller::toHexFromBytes(
-    const std::vector<unsigned char>& data )
-{
+    const std::vector<unsigned char>& data ) {
+
     std::string buffer = "";
 
-    for( unsigned int i = 0; i < data.size(); i++ )
-    {
+    for( unsigned int i = 0; i < data.size(); i++ ) {
         buffer.append( hexTable[ data[i] ] );
     }
 
@@ -820,8 +808,8 @@
 ////////////////////////////////////////////////////////////////////////////////
 std::string BaseDataStreamMarshaller::readAsciiString(
     io::DataInputStream* dataIn )
-        throw ( io::IOException )
-{
+        throw ( io::IOException ) {
+
     try{
 
         int size = dataIn->readShort() + 1; // add space c++ NULL



Mime
View raw message