[PATCH 2.3.1 2/5] MAMACPP: Complete support of Vector Bool and Vector Char field types.


Alireza Assadzadeh <Alireza.Assadzadeh@...>
 

Update MAMACPP for Mama message field, cache field, and cache field
types to complete support of Vector Bool and Vector Char.

Signed-off-by: Alireza Assadzadeh <Alireza.Assadzadeh@solacesystems.com>
---
mama/c_cpp/src/cpp/MamaMsgField.cpp | 6 +++
.../src/cpp/fieldcache/MamaFieldCacheField.cpp | 2 +
.../cpp/fieldcache/MamaFieldCacheFieldTypes.cpp | 60 ++++++++++++++++++++++
mama/c_cpp/src/cpp/mama/MamaMsgField.h | 9 ++++
.../cpp/mama/fieldcache/MamaFieldCacheFieldTypes.h | 36 +++++++++++++
5 files changed, 113 insertions(+)

diff --git a/mama/c_cpp/src/cpp/MamaMsgField.cpp b/mama/c_cpp/src/cpp/MamaMsgField.cpp
index 0898825..f2f287c 100644
--- a/mama/c_cpp/src/cpp/MamaMsgField.cpp
+++ b/mama/c_cpp/src/cpp/MamaMsgField.cpp
@@ -242,6 +242,12 @@ namespace Wombat
mamaTry (mamaMsgField_getDateTime (mField, result.getCValue()));
}

+ void MamaMsgField::getVectorBool (const mama_bool_t*& result,
+ size_t& resultLen) const
+ {
+ mamaTry (mamaMsgField_getVectorBool (mField, &result, &resultLen));
+ }
+
void MamaMsgField::getVectorChar (const char*& result,
size_t& resultLen) const
{
diff --git a/mama/c_cpp/src/cpp/fieldcache/MamaFieldCacheField.cpp b/mama/c_cpp/src/cpp/fieldcache/MamaFieldCacheField.cpp
index ee785f7..69d5de9 100644
--- a/mama/c_cpp/src/cpp/fieldcache/MamaFieldCacheField.cpp
+++ b/mama/c_cpp/src/cpp/fieldcache/MamaFieldCacheField.cpp
@@ -198,6 +198,8 @@ bool MamaFieldCacheField::isVector() const
{
switch (getType())
{
+ case MAMA_FIELD_TYPE_VECTOR_BOOL:
+ case MAMA_FIELD_TYPE_VECTOR_CHAR:
case MAMA_FIELD_TYPE_VECTOR_I8:
case MAMA_FIELD_TYPE_VECTOR_U8:
case MAMA_FIELD_TYPE_VECTOR_I16:
diff --git a/mama/c_cpp/src/cpp/fieldcache/MamaFieldCacheFieldTypes.cpp b/mama/c_cpp/src/cpp/fieldcache/MamaFieldCacheFieldTypes.cpp
index 0a02613..c1a64d7 100644
--- a/mama/c_cpp/src/cpp/fieldcache/MamaFieldCacheFieldTypes.cpp
+++ b/mama/c_cpp/src/cpp/fieldcache/MamaFieldCacheFieldTypes.cpp
@@ -273,6 +273,66 @@ const MamaDateTime& MamaFieldCacheFieldDateTime::get(const MamaFieldCacheField&
return mDateTime;
}

+// MAMA_FIELD_TYPE_VECTOR_BOOL
+template <>
+void MamaFieldCacheFieldBoolVector::set(MamaFieldCacheField& field,
+ const mama_bool_t* values,
+ mama_size_t size)
+{
+ checkType(field);
+ mamaFieldCacheField_setBoolVector(field.getCValue(), values, size);
+}
+template <>
+void MamaFieldCacheFieldBoolVector::get(const MamaFieldCacheField& field,
+ const mama_bool_t*& values,
+ mama_size_t& size) const
+{
+ checkType(field);
+ mamaFieldCacheField_getBoolVector(field.getCValue(), &values, &size);
+}
+template <>
+const mama_bool_t& MamaFieldCacheFieldBoolVector::get(const MamaFieldCacheField& field,
+ mama_size_t index) const
+{
+ checkType(field);
+ const mama_bool_t* values = NULL;
+ mama_size_t size = 0;
+ mamaFieldCacheField_getBoolVector(field.getCValue(), &values, &size);
+ if (index < size)
+ return values[index];
+ throw std::out_of_range("MamaFieldCacheFieldBoolVector::get");
+}
+
+// MAMA_FIELD_TYPE_VECTOR_CHAR
+template <>
+void MamaFieldCacheFieldCharVector::set(MamaFieldCacheField& field,
+ const char* values,
+ mama_size_t size)
+{
+ checkType(field);
+ mamaFieldCacheField_setCharVector(field.getCValue(), values, size);
+}
+template <>
+void MamaFieldCacheFieldCharVector::get(const MamaFieldCacheField& field,
+ const char*& values,
+ mama_size_t& size) const
+{
+ checkType(field);
+ mamaFieldCacheField_getCharVector(field.getCValue(), &values, &size);
+}
+template <>
+const char& MamaFieldCacheFieldCharVector::get(const MamaFieldCacheField& field,
+ mama_size_t index) const
+{
+ checkType(field);
+ const char* values = NULL;
+ mama_size_t size = 0;
+ mamaFieldCacheField_getCharVector(field.getCValue(), &values, &size);
+ if (index < size)
+ return values[index];
+ throw std::out_of_range("MamaFieldCacheFieldCharVector::get");
+}
+
// MAMA_FIELD_TYPE_VECTOR_I8
template <>
void MamaFieldCacheFieldI8Vector::set(MamaFieldCacheField& field,
diff --git a/mama/c_cpp/src/cpp/mama/MamaMsgField.h b/mama/c_cpp/src/cpp/mama/MamaMsgField.h
index b81a844..f763dca 100644
--- a/mama/c_cpp/src/cpp/mama/MamaMsgField.h
+++ b/mama/c_cpp/src/cpp/mama/MamaMsgField.h
@@ -201,6 +201,15 @@ namespace Wombat
MamaMsg& result) const;

/**
+ * Get a vector of boolean.
+ * @param result (out) the vector.
+ * @param resultLen (out) the size of the vector.
+ */
+ void getVectorBool (
+ const mama_bool_t*& result,
+ mama_size_t& resultLen) const;
+
+ /**
* Get a vector of characters.
* @param result (out) the vector.
* @param resultLen (out) the size of the vector.
diff --git a/mama/c_cpp/src/cpp/mama/fieldcache/MamaFieldCacheFieldTypes.h b/mama/c_cpp/src/cpp/mama/fieldcache/MamaFieldCacheFieldTypes.h
index 79c8713..fe164df 100644
--- a/mama/c_cpp/src/cpp/mama/fieldcache/MamaFieldCacheFieldTypes.h
+++ b/mama/c_cpp/src/cpp/mama/fieldcache/MamaFieldCacheFieldTypes.h
@@ -278,6 +278,18 @@ protected:
};

/**
+ * MamaFieldCacheFieldBoolVector.
+ * Class used to set and get the value of a mama_bool_t vector <code>MamaFieldCacheField</code>.
+ */
+typedef MamaFieldCacheFieldVectorBasic<mama_bool_t, MAMA_FIELD_TYPE_VECTOR_BOOL>
+ MamaFieldCacheFieldBoolVector;
+/**
+ * MamaFieldCacheFieldCharVector.
+ * Class used to set and get the value of a char vector <code>MamaFieldCacheField</code>.
+ */
+typedef MamaFieldCacheFieldVectorBasic<char, MAMA_FIELD_TYPE_VECTOR_CHAR>
+ MamaFieldCacheFieldCharVector;
+/**
* MamaFieldCacheFieldI8Vector.
* Class used to set and get the value of a mama_i8_t vector <code>MamaFieldCacheField</code>.
*/
@@ -887,6 +899,18 @@ void setFieldValue(MamaFieldCacheField& field, const T* values, mama_size_t size
{
switch(field.getType())
{
+ case MAMA_FIELD_TYPE_VECTOR_BOOL:
+ {
+ MamaFieldCacheFieldBoolVector getField;
+ getField.set(field, (const mama_bool_t*)values, size);
+ break;
+ }
+ case MAMA_FIELD_TYPE_VECTOR_CHAR:
+ {
+ MamaFieldCacheFieldCharVector getField;
+ getField.set(field, (const char*)values, size);
+ break;
+ }
case MAMA_FIELD_TYPE_VECTOR_I8:
{
MamaFieldCacheFieldI8Vector getField;
@@ -999,6 +1023,18 @@ void getFieldValue(const MamaFieldCacheField& field, const T*& values, mama_size
{
switch(field.getType())
{
+ case MAMA_FIELD_TYPE_VECTOR_BOOL:
+ {
+ MamaFieldCacheFieldBoolVector getField;
+ getField.get(field, (const mama_bool_t*&)values, size);
+ break;
+ }
+ case MAMA_FIELD_TYPE_VECTOR_CHAR:
+ {
+ MamaFieldCacheFieldCharVector getField;
+ getField.get(field, (const char*&)values, size);
+ break;
+ }
case MAMA_FIELD_TYPE_VECTOR_I8:
{
MamaFieldCacheFieldI8Vector getField;
--
1.9.3