diff --git a/serialize/SerialArrayListAdapter.h b/serialize/SerialArrayListAdapter.h index 72b8d97f..21cbbc4d 100644 --- a/serialize/SerialArrayListAdapter.h +++ b/serialize/SerialArrayListAdapter.h @@ -78,6 +78,22 @@ public: } return result; } + + /** + * Swap the endianness of the Array list (not the length field !) + * Useful if the case the buffer type is large than uint8_t and the endianness + * is inconsistent with other SerializeElements. + * @param list + */ + static void swapArrayListEndianness(ArrayList* list) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + count_t i = 0; + while ((result == HasReturnvaluesIF::RETURN_OK) && (i < list->size)) { + T newEntry = EndianSwapper::swap(list->entries[i]); + list->entries[i] = newEntry; + ++i; + } + } private: ArrayList *adaptee; }; diff --git a/serialize/SerialFixedArrayListAdapter.h b/serialize/SerialFixedArrayListAdapter.h index 18a970b8..9613f6c1 100644 --- a/serialize/SerialFixedArrayListAdapter.h +++ b/serialize/SerialFixedArrayListAdapter.h @@ -40,6 +40,10 @@ public: bool bigEndian) { return SerialArrayListAdapter::deSerialize(this, buffer, size, bigEndian); } + + void swapArrayListEndianness() { + SerialArrayListAdapter::swapArrayListEndianness(this); + } };