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 2011/02/08 23:34:37 UTC

svn commit: r1068648 - in /activemq/activemq-cpp/trunk/activemq-c/src/main/c: CMS_BytesMessage.cpp CMS_BytesMessage.h Makefile.am cms.h

Author: tabish
Date: Tue Feb  8 22:34:37 2011
New Revision: 1068648

URL: http://svn.apache.org/viewvc?rev=1068648&view=rev
Log:
Implement the wrapper around the BytesMessage methods.

Added:
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_BytesMessage.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_BytesMessage.h   (with props)
Modified:
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/Makefile.am
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/cms.h

Added: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_BytesMessage.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_BytesMessage.cpp?rev=1068648&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_BytesMessage.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_BytesMessage.cpp Tue Feb  8 22:34:37 2011
@@ -0,0 +1,721 @@
+/*
+ * 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 <CMS_Message.h>
+#include <CMS_BytesMessage.h>
+
+#include <Config.h>
+#include <types/CMS_Types.h>
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <memory>
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getMessageBodyLength(CMS_Message* message, int* length) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && length != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+        *length = bytesMessage->getBodyLength();
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status bytesMessageReset(CMS_Message* message) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            bytesMessage->reset();
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status readBooleanFromBytesMessage(CMS_Message* message, int* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            *value = bytesMessage->readBoolean();
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotReadableException& ex) {
+            result = CMS_MESSAGE_NOT_READABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status writeBooleanToBytesMessage(CMS_Message* message, int value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            bytesMessage->writeBoolean((bool)value);
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status readByteFromBytesMessage(CMS_Message* message, unsigned char* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            *value = bytesMessage->readByte();
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotReadableException& ex) {
+            result = CMS_MESSAGE_NOT_READABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status writeByteToBytesMessage(CMS_Message* message, unsigned char value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            bytesMessage->writeByte(value);
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status readCharFromBytesMessage(CMS_Message* message, char* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            *value = bytesMessage->readChar();
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotReadableException& ex) {
+            result = CMS_MESSAGE_NOT_READABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status writeCharToBytesMessage(CMS_Message* message, char value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            bytesMessage->writeChar(value);
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status readFloatFromBytesMessage(CMS_Message* message, float* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            *value = bytesMessage->readFloat();
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotReadableException& ex) {
+            result = CMS_MESSAGE_NOT_READABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status writeFloatToBytesMessage(CMS_Message* message, float value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            bytesMessage->writeFloat(value);
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status readDoubleFromBytesMessage(CMS_Message* message, double* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            *value = bytesMessage->readDouble();
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotReadableException& ex) {
+            result = CMS_MESSAGE_NOT_READABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status writeDoubleToBytesMessage(CMS_Message* message, double value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            bytesMessage->writeDouble(value);
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status readShortFromBytesMessage(CMS_Message* message, short* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            *value = bytesMessage->readShort();
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotReadableException& ex) {
+            result = CMS_MESSAGE_NOT_READABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status writeShortToBytesMessage(CMS_Message* message, short value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            bytesMessage->writeShort(value);
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status readIntFromBytesMessage(CMS_Message* message, int* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            *value = bytesMessage->readInt();
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotReadableException& ex) {
+            result = CMS_MESSAGE_NOT_READABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status writeIntToBytesMessage(CMS_Message* message, int value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            bytesMessage->writeInt(value);
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status readLongFromBytesMessage(CMS_Message* message, long long* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            *value = bytesMessage->readLong();
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotReadableException& ex) {
+            result = CMS_MESSAGE_NOT_READABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status writeLongToBytesMessage(CMS_Message* message, long long value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL) {
+
+        if( message->type != CMS_BYTES_MESSAGE ) {
+            return CMS_INVALID_MESSAGE_TYPE;
+        }
+
+        cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+        try{
+            bytesMessage->writeLong(value);
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status readBytesFromBytesMessage(CMS_Message* message, unsigned char* value, int size) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && value != NULL) {
+
+        try{
+
+            if( message->type != CMS_BYTES_MESSAGE ) {
+                return CMS_INVALID_MESSAGE_TYPE;
+            }
+
+            cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+            int readCount = bytesMessage->readBytes(value, size);
+
+            if( readCount != -1 ) {
+                result = CMS_INCOMPLETE_READ;
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotReadableException& ex) {
+            result = CMS_MESSAGE_NOT_READABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status writeBytesToBytesMessage(CMS_Message* message, const unsigned char* value, int offset, int length) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && value != NULL) {
+
+        try{
+
+            if( message->type != CMS_BYTES_MESSAGE ) {
+                return CMS_INVALID_MESSAGE_TYPE;
+            }
+
+            cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+            bytesMessage->writeBytes(value, offset, length);
+
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status readStringFromBytesMessage(CMS_Message* message, char* value, int size) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && value != NULL) {
+
+        try{
+
+            if( message->type != CMS_BYTES_MESSAGE ) {
+                return CMS_INVALID_MESSAGE_TYPE;
+            }
+
+            cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+            std::string str = bytesMessage->readString();
+
+            if(!str.empty()) {
+
+                std::size_t pos = 0;
+                for(; pos < str.size() && pos < (std::size_t)size - 1; ++pos) {
+                    value[pos] = str.at(pos);
+                }
+
+                value[pos] = '\0';
+            } else {
+                value[0] = '\0';
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            value[0] = '\0';
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotReadableException& ex) {
+            value[0] = '\0';
+            result = CMS_MESSAGE_NOT_READABLE;
+        } catch(...) {
+            value[0] = '\0';
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status writeStringToBytesMessage(CMS_Message* message, const char* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && value != NULL) {
+
+        try{
+
+            if( message->type != CMS_BYTES_MESSAGE ) {
+                return CMS_INVALID_MESSAGE_TYPE;
+            }
+
+            cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+            if(strlen(value) > 0) {
+                bytesMessage->writeString(value);
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status readUTFFromBytesMessage(CMS_Message* message, char* value, int size) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && value != NULL) {
+
+        try{
+
+            if( message->type != CMS_BYTES_MESSAGE ) {
+                return CMS_INVALID_MESSAGE_TYPE;
+            }
+
+            cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+            std::string str = bytesMessage->readUTF();
+
+            if(!str.empty()) {
+
+                std::size_t pos = 0;
+                for(; pos < str.size() && pos < (std::size_t)size - 1; ++pos) {
+                    value[pos] = str.at(pos);
+                }
+
+                value[pos] = '\0';
+            } else {
+                value[0] = '\0';
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            value[0] = '\0';
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotReadableException& ex) {
+            value[0] = '\0';
+            result = CMS_MESSAGE_NOT_READABLE;
+        } catch(...) {
+            value[0] = '\0';
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status writeUTFToBytesMessage(CMS_Message* message, const char* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && value != NULL) {
+
+        try{
+
+            if( message->type != CMS_BYTES_MESSAGE ) {
+                return CMS_INVALID_MESSAGE_TYPE;
+            }
+
+            cms::BytesMessage* bytesMessage = dynamic_cast<cms::BytesMessage*>( message->message );
+
+            if(strlen(value) > 0) {
+                bytesMessage->writeUTF(value);
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}

Propchange: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_BytesMessage.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_BytesMessage.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_BytesMessage.h?rev=1068648&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_BytesMessage.h (added)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_BytesMessage.h Tue Feb  8 22:34:37 2011
@@ -0,0 +1,328 @@
+/*
+ * 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 <cms.h>
+
+#ifndef CMSBYTESMESSAGE_H_
+#define CMSBYTESMESSAGE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Gets the number of bytes contained in this BytesMessage.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param length
+ *      The number of bytes contained in the Message body.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getMessageBodyLength(CMS_Message* message, int* length);
+
+/**
+ * Puts the message body in read-only mode and repositions the stream
+ * of bytes to the beginning.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status resetBytesMessage(CMS_Message* message);
+
+/**
+ * Reads a boolean value from the Bytes Message Body (reads one byte).
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      Pointer to the location to store the read value.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status readBooleanFromBytesMessage(CMS_Message* message, int* value);
+
+/**
+ * Write a boolean value to the Bytes Message body as one byte (either zero or one).
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      The value to write to the Message body.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status writeBooleanToBytesMessage(CMS_Message* message, int value);
+
+/**
+ * Reads a byte from the Bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      Pointer to the location to store the read value.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status readByteFromBytesMessage(CMS_Message* message, unsigned char* value);
+
+/**
+ * Writes a byte to the bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      The value to write to the Message body.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status writeByteToBytesMessage(CMS_Message* message, unsigned char value);
+
+/**
+ * Reads a char from the Bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      Pointer to the location to store the read value.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status readCharFromBytesMessage(CMS_Message* message, char* value);
+
+/**
+ * Writes a char to the bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      The value to write to the Message body.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status writeCharToBytesMessage(CMS_Message* message, char value);
+
+/**
+ * Reads a float from the Bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      Pointer to the location to store the read value.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status readFloatFromBytesMessage(CMS_Message* message, float* value);
+
+/**
+ * Writes a float to the bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      The value to write to the Message body.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status writeFloatToBytesMessage(CMS_Message* message, float value);
+
+/**
+ * Reads a double from the Bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      Pointer to the location to store the read value.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status readDoubleFromBytesMessage(CMS_Message* message, double* value);
+
+/**
+ * Writes a double to the bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      The value to write to the Message body.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status writeDoubleToBytesMessage(CMS_Message* message, double value);
+
+/**
+ * Reads a short from the Bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      Pointer to the location to store the read value.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status readShortFromBytesMessage(CMS_Message* message, short* value);
+
+/**
+ * Writes a short to the bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      The value to write to the Message body.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status writeShortToBytesMessage(CMS_Message* message, short value);
+
+/**
+ * Reads a int from the Bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      Pointer to the location to store the read value.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status readIntFromBytesMessage(CMS_Message* message, int* value);
+
+/**
+ * Writes a int to the bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      The value to write to the Message body.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status writeIntToBytesMessage(CMS_Message* message, int value);
+
+/**
+ * Reads a long long from the Bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      Pointer to the location to store the read value.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status readLongFromBytesMessage(CMS_Message* message, long long* value);
+
+/**
+ * Writes a long long to the bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      The value to write to the Message body.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status writeLongToBytesMessage(CMS_Message* message, long long value);
+
+/**
+ * Reads raw bytes from the Bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      Pointer to the location to store the read value.
+ * @param size
+ *      The size of the passed in string buffer, only that amount will be stored.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status readBytesFromBytesMessage(CMS_Message* message, unsigned char* value, int size);
+
+/**
+ * Writes raw bytes string to the bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      The value to write to the Message body.
+ * @param offset
+ *      The position in the passed buffer to start writing from.
+ * @param length
+ *      The number of bytes to write to the Message.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status writeBytesToBytesMessage(CMS_Message* message, const unsigned char* value, int offset, int length);
+
+/**
+ * Reads a null terminated ASCII string from the Bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      Pointer to the location to store the read value.
+ * @param size
+ *      The size of the passed in string buffer, only that amount will be stored.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status readStringFromBytesMessage(CMS_Message* message, char* value, int size);
+
+/**
+ * Writes a null terminated ASCII string to the bytes message stream.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      The value to write to the Message body.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status writeStringToBytesMessage(CMS_Message* message, const char* value);
+
+/**
+ * Reads a null terminated UTF-8 string from the Bytes message stream and decodes it.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      Pointer to the location to store the read value.
+ * @param size
+ *      The size of the passed in string buffer, only that amount will be stored.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status readUTFFromBytesMessage(CMS_Message* message, char* value, int size);
+
+/**
+ * Writes a null terminated UTF-8 string to the bytes message stream encoding it first.
+ *
+ * @param message
+ *      The CMS Message instance to operate on.
+ * @param value
+ *      The value to write to the Message body.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status writeUTFToBytesMessage(CMS_Message* message, const char* value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CMSBYTESMESSAGE_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_BytesMessage.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/Makefile.am?rev=1068648&r1=1068647&r2=1068648&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/Makefile.am Tue Feb  8 22:34:37 2011
@@ -16,6 +16,7 @@
 # ---------------------------------------------------------------------------
 
 cc_sources = \
+    CMS_BytesMessage.cpp \
     CMS_Connection.cpp \
     CMS_ConnectionFactory.cpp \
     CMS_Destination.cpp \
@@ -28,6 +29,7 @@ cc_sources = \
 
 
 h_sources = \
+    CMS_BytesMessage.h \
     CMS_Connection.h \
     CMS_ConnectionFactory.h \
     CMS_Destination.h \

Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/cms.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/cms.h?rev=1068648&r1=1068647&r2=1068648&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/cms.h (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/cms.h Tue Feb  8 22:34:37 2011
@@ -107,6 +107,7 @@ typedef int cms_status;
 #define CMS_MESSAGE_NOT_WRITABLE    11
 #define CMS_MESSAGE_FORMAT_ERROR    12
 #define CMS_UNKNOWN_ACKTYPE         13
+#define CMS_INCOMPLETE_READ         14
 
 /**
  * C Functions used to initialize and shutdown the ActiveMQ-C library.