activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1027597 - in /activemq/activemq-cpp/trunk/activemq-c/src/main/c: CMS_Message.cpp CMS_Message.h cms.h
Date Tue, 26 Oct 2010 15:40:17 GMT
Author: tabish
Date: Tue Oct 26 15:40:17 2010
New Revision: 1027597

URL: http://svn.apache.org/viewvc?rev=1027597&view=rev
Log:
API Wrappers for the Message Property setters / getters

Modified:
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h
    activemq/activemq-cpp/trunk/activemq-c/src/main/c/cms.h

Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp?rev=1027597&r1=1027596&r2=1027597&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.cpp Tue Oct 26 15:40:17
2010
@@ -23,6 +23,12 @@
 #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>
 
@@ -245,3 +251,452 @@ cms_status clearMessageProperties(CMS_Me
 
     return result;
 }
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getNumMessageProperties(CMS_Message* message, int* numProperties) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && numProperties != NULL) {
+
+        try{
+            *numProperties = (int) message->message->getPropertyNames().size();
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status messagePropertyExists(CMS_Message* message, const char* key, int* exists ) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL && exists != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                *exists = (int) message->message->propertyExists(key);
+            } else {
+                *exists = 0;
+            }
+
+        } catch(...) {
+            *exists = 0;
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getMessageBooleanProperty(CMS_Message* message, const char* key, int* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL && value != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                *value = (int) message->message->getBooleanProperty(key);
+            } else {
+                *value = 0;
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            *value = 0;
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(...) {
+            *value = 0;
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getMessageByteProperty(CMS_Message* message, const char* key, unsigned char* value)
{
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL && value != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                *value = message->message->getByteProperty(key);
+            } else {
+                *value = 0;
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            *value = 0;
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(...) {
+            *value = 0;
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getMessageDoubleProperty(CMS_Message* message, const char* key, double* value)
{
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL && value != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                *value = message->message->getDoubleProperty(key);
+            } else {
+                *value = 0;
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            *value = 0;
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(...) {
+            *value = 0;
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getMessageFloatProperty(CMS_Message* message, const char* key, float* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL && value != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                *value = message->message->getFloatProperty(key);
+            } else {
+                *value = 0;
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            *value = 0;
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(...) {
+            *value = 0;
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getMessageIntProperty(CMS_Message* message, const char* key, int* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL && value != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                *value = message->message->getIntProperty(key);
+            } else {
+                *value = 0;
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            *value = 0;
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(...) {
+            *value = 0;
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getMessageLongProperty(CMS_Message* message, const char* key, long long* value)
{
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL && value != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                *value = message->message->getLongProperty(key);
+            } else {
+                *value = 0;
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            *value = 0;
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(...) {
+            *value = 0;
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getMessageShortProperty(CMS_Message* message, const char* key, short* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL && value != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                *value = message->message->getShortProperty(key);
+            } else {
+                *value = 0;
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            *value = 0;
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(...) {
+            *value = 0;
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status getMessageStringProperty(CMS_Message* message, const char* key, char* value, int
size) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL && value != NULL) {
+
+        try{
+
+            std::string property = message->message->getStringProperty(key);
+
+            if(!property.empty()) {
+
+                std::size_t pos = 0;
+                for(; pos < property.size() && pos < size - 1; ++pos) {
+                    value[pos] = property.at(pos);
+                }
+
+                value[pos] = '\0';
+            } else {
+                value[0] = '\0';
+            }
+
+        } catch(cms::MessageFormatException& ex) {
+            value[0] = '\0';
+            result = CMS_MESSAGE_FORMAT_ERROR;
+        } catch(...) {
+            value[0] = '\0';
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setMessageBooleanProperty(CMS_Message* message, const char* key, int value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                message->message->setBooleanProperty(key, value > 0 ? true : false);
+            }
+
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setMessageByteProperty(CMS_Message* message, const char* key, unsigned char value)
{
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                message->message->setByteProperty(key, value);
+            }
+
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setMessageDoubleProperty(CMS_Message* message, const char* key, double value)
{
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                message->message->setDoubleProperty(key, value);
+            }
+
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setMessageFloatProperty(CMS_Message* message, const char* key, float value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                message->message->setFloatProperty(key, value);
+            }
+
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setMessageIntProperty(CMS_Message* message, const char* key, int value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                message->message->setIntProperty(key, value);
+            }
+
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setMessageLongProperty(CMS_Message* message, const char* key, long long value)
{
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                message->message->setLongProperty(key, value);
+            }
+
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setShortProperty(CMS_Message* message, const char* key, short value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                message->message->setShortProperty(key, value);
+            }
+
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+cms_status setStringProperty(CMS_Message* message, const char* key, const char* value) {
+
+    cms_status result = CMS_SUCCESS;
+
+    if(message != NULL && key != NULL) {
+
+        try{
+
+            if(strlen(key) > 0) {
+                message->message->setStringProperty(key, value);
+            }
+
+        } catch(cms::MessageNotWriteableException& ex) {
+            result = CMS_MESSAGE_NOT_WRITABLE;
+        } catch(...) {
+            result = CMS_ERROR;
+        }
+    }
+
+    return result;
+}

Modified: activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h?rev=1027597&r1=1027596&r2=1027597&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h (original)
+++ activemq/activemq-cpp/trunk/activemq-c/src/main/c/CMS_Message.h Tue Oct 26 15:40:17 2010
@@ -112,6 +112,8 @@ cms_status destroyMessage(CMS_Message* m
  *      The Message to clone.
  * @param clone
  *      The address of the location to store the new Message instance.
+ *
+ * @return result code indicating the success or failure of the operation.
  */
 cms_status cloneMessage(CMS_Message* original, CMS_Message** clone);
 
@@ -120,6 +122,8 @@ cms_status cloneMessage(CMS_Message* ori
  *
  * @param message
  *      The Message to acknowledge.
+ *
+ * @return result code indicating the success or failure of the operation.
  */
 cms_status acknowledgeMessage(CMS_Message* message);
 
@@ -129,6 +133,8 @@ cms_status acknowledgeMessage(CMS_Messag
  *
  * @param message
  *      The Message whose body is to be cleared.
+ *
+ * @return result code indicating the success or failure of the operation.
  */
 cms_status clearBody(CMS_Message* message);
 
@@ -142,9 +148,270 @@ cms_status clearBody(CMS_Message* messag
  *
  * @param message
  *      The Message whose properties are to be cleared.
+ *
+ * @return result code indicating the success or failure of the operation.
  */
 cms_status clearMessageProperties(CMS_Message* message);
 
+/**
+ * Gets a count of the number of properties that are contained in the given Message.
+ *
+ * @param message
+ *      The Message whose property count is to be fetched.
+ * @param numProperties
+ *      The address where the number of properties value is to be stored.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getNumMessageProperties(CMS_Message* message, int* numProperties);
+
+/*********************************/
+/* TODO                          */
+/*cms_status getMessagePropertyNames(CMS_Message* message, char** properties, int* size);*/
+/*********************************/
+
+/**
+ * Indicates whether or not a given property exists in the supplied Message instance.
+ * If the property is contained in the Message than the exists value is set to 1 otherwise
+ * it is set to zero.
+ *
+ * @param message
+ *      The message that should be queried for the given property name.
+ * @param key
+ *      The name of the property that the message should be checked for.
+ * @param exists
+ *      The address to store the boolean result of this operation.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status messagePropertyExists(CMS_Message* message, const char* key, int* exists);
+
+/**
+ * Gets a boolean property.
+ *
+ * @param message
+ *      The message that should be queried for the given property.
+ * @param key
+ *      The name of the property that should be fetched from the Message instance.
+ * @param value
+ *      The address to store the value of the requested property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getMessageBooleanProperty(CMS_Message* message, const char* key, int* value);
+
+/**
+ * Gets a byte property.
+ *
+ * @param message
+ *      The message that should be queried for the given property.
+ * @param key
+ *      The name of the property that should be fetched from the Message instance.
+ * @param value
+ *      The address to store the value of the requested property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getMessageByteProperty(CMS_Message* message, const char* key, unsigned char* value);
+
+/**
+ * Gets a double property.
+ *
+ * @param message
+ *      The message that should be queried for the given property.
+ * @param key
+ *      The name of the property that should be fetched from the Message instance.
+ * @param value
+ *      The address to store the value of the requested property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getMessageDoubleProperty(CMS_Message* message, const char* key, double* value);
+
+/**
+ * Gets a float property.
+ *
+ * @param message
+ *      The message that should be queried for the given property.
+ * @param key
+ *      The name of the property that should be fetched from the Message instance.
+ * @param value
+ *      The address to store the value of the requested property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getMessageFloatProperty(CMS_Message* message, const char* key, float* value);
+
+/**
+ * Gets a int property.
+ *
+ * @param message
+ *      The message that should be queried for the given property.
+ * @param key
+ *      The name of the property that should be fetched from the Message instance.
+ * @param value
+ *      The address to store the value of the requested property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getMessageIntProperty(CMS_Message* message, const char* key, int* value);
+
+/**
+ * Gets a long property.
+ *
+ * @param message
+ *      The message that should be queried for the given property.
+ * @param key
+ *      The name of the property that should be fetched from the Message instance.
+ * @param value
+ *      The address to store the value of the requested property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getMessageLongProperty(CMS_Message* message, const char* key, long long* value);
+
+/**
+ * Gets a short property.
+ *
+ * @param message
+ *      The message that should be queried for the given property.
+ * @param key
+ *      The name of the property that should be fetched from the Message instance.
+ * @param value
+ *      The address to store the value of the requested property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getMessageShortProperty(CMS_Message* message, const char* key, short* value);
+
+/**
+ * Gets a string property.
+ *
+ * @param message
+ *      The message that should be queried for the given property.
+ * @param key
+ *      The name of the property that should be fetched from the Message instance.
+ * @param value
+ *      The address to store the value of the requested property.
+ * @param size
+ *      The size of the character array that is provided to receive the string payload.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status getMessageStringProperty(CMS_Message* message, const char* key, char* value, int
size);
+
+/**
+ * Sets a boolean property.
+ *
+ * @param message
+ *      The message that the property is to be set in.
+ * @param key
+ *      The name of the property that should be set in the Message instance.
+ * @param value
+ *      The value to store in the given message property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setMessageBooleanProperty(CMS_Message* message, const char* key, int value);
+
+/**
+ * Sets a byte property.
+ *
+ * @param message
+ *      The message that the property is to be set in.
+ * @param key
+ *      The name of the property that should be set in the Message instance.
+ * @param value
+ *      The value to store in the given message property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setMessageByteProperty(CMS_Message* message, const char* key, unsigned char value);
+
+/**
+ * Sets a double property.
+ *
+ * @param message
+ *      The message that the property is to be set in.
+ * @param key
+ *      The name of the property that should be set in the Message instance.
+ * @param value
+ *      The value to store in the given message property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setMessageDoubleProperty(CMS_Message* message, const char* key, double value);
+
+/**
+ * Sets a float property.
+ *
+ * @param message
+ *      The message that the property is to be set in.
+ * @param key
+ *      The name of the property that should be set in the Message instance.
+ * @param value
+ *      The value to store in the given message property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setMessageFloatProperty(CMS_Message* message, const char* key, float value);
+
+/**
+ * Sets a int property.
+ *
+ * @param message
+ *      The message that the property is to be set in.
+ * @param key
+ *      The name of the property that should be set in the Message instance.
+ * @param value
+ *      The value to store in the given message property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setMessageIntProperty(CMS_Message* message, const char* key, int value);
+
+/**
+ * Sets a long property.
+ *
+ * @param message
+ *      The message that the property is to be set in.
+ * @param key
+ *      The name of the property that should be set in the Message instance.
+ * @param value
+ *      The value to store in the given message property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setMessageLongProperty(CMS_Message* message, const char* key, long long value);
+
+/**
+ * Sets a short property.
+ *
+ * @param message
+ *      The message that the property is to be set in.
+ * @param key
+ *      The name of the property that should be set in the Message instance.
+ * @param value
+ *      The value to store in the given message property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setShortProperty(CMS_Message* message, const char* key, short value);
+
+/**
+ * Sets a string property.
+ *
+ * @param message
+ *      The message that the property is to be set in.
+ * @param key
+ *      The name of the property that should be set in the Message instance.
+ * @param value
+ *      The value to store in the given message property.
+ *
+ * @return result code indicating the success or failure of the operation.
+ */
+cms_status setStringProperty(CMS_Message* message, const char* key, const char* value);
+
 #ifdef __cplusplus
 }
 #endif

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=1027597&r1=1027596&r2=1027597&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 Oct 26 15:40:17 2010
@@ -105,7 +105,8 @@ typedef int cms_status;
 #define CMS_MESSAGE_EOF             9
 #define CMS_MESSAGE_NOT_READABLE    10
 #define CMS_MESSAGE_NOT_WRITABLE    11
-#define CMS_UNKNOWN_ACKTYPE         12
+#define CMS_MESSAGE_FORMAT_ERROR    12
+#define CMS_UNKNOWN_ACKTYPE         13
 
 /**
  * C Functions used to initialize and shutdown the ActiveMQ-C library.



Mime
View raw message