+// Get variable type size, e.g. strings, arrays, etc.
+int IoTRMIUtil::getVarTypeSize(string type, void* paramObj) {
+
+ int paramLen = 0;
+ if (type.compare("String") == 0) {
+ // Get the length of the string through void* casting to string*
+ paramLen = (*(string*)paramObj).length();
+ } else if ( (type.compare("String*") == 0) ||
+ (type.compare("string*") == 0) ||
+ (type.compare("vector<String>") == 0)) {
+ paramLen = IoTRMIUtil::getByteStringLength(*(vector<string>*) paramObj);
+ } else if ( (type.compare("byte*") == 0) ||
+ (type.compare("Byte*") == 0) ||
+ (type.compare("vector<Byte>") == 0)) {
+ int dataSize = getTypeSize("byte");
+ paramLen = (*(vector<char>*) paramObj).size() * dataSize;
+ } else if ( (type.compare("short*") == 0) ||
+ (type.compare("Short*") == 0) ||
+ (type.compare("vector<Short>") == 0)) {
+ int dataSize = getTypeSize("short");
+ paramLen = (*(vector<short>*) paramObj).size() * dataSize;
+ } else if ( (type.compare("int*") == 0) ||
+ (type.compare("Integer*") == 0) ||
+ (type.compare("vector<Integer>") == 0)) {
+ int dataSize = getTypeSize("int");
+ paramLen = (*(vector<int>*) paramObj).size() * dataSize;
+ } else if ( (type.compare("long*") == 0) ||
+ (type.compare("Long*") == 0) ||
+ (type.compare("vector<Long>") == 0)) {
+ int dataSize = getTypeSize("long");
+ paramLen = (*(vector<int64_t>*) paramObj).size() * dataSize;
+ } else if ( (type.compare("float*") == 0) ||
+ (type.compare("Float*") == 0) ||
+ (type.compare("vector<Float>") == 0)) {
+ int dataSize = getTypeSize("float");
+ paramLen = (*(vector<float>*) paramObj).size() * dataSize;
+ } else if ( (type.compare("double*") == 0) ||
+ (type.compare("Double*") == 0) ||
+ (type.compare("vector<Double>") == 0)) {
+ int dataSize = getTypeSize("double");
+ paramLen = (*(vector<double>*) paramObj).size() * dataSize;
+ } else if ( (type.compare("boolean*") == 0) ||
+ (type.compare("Boolean*") == 0) ||
+ (type.compare("vector<Boolean>") == 0)) {
+ int dataSize = getTypeSize("boolean");
+ paramLen = (*(vector<bool>*) paramObj).size() * dataSize;
+ } else if ( (type.compare("char*") == 0) ||
+ (type.compare("Character*") == 0) ||
+ (type.compare("vector<Character>") == 0)) {
+ int dataSize = getTypeSize("char");
+ paramLen = (*(vector<char>*) paramObj).size() * dataSize;
+ } else {
+ cerr << "IoTRMIUtil: Unrecognizable type: " << type << endl;
+ exit(-1);
+ }
+
+ return paramLen;
+}
+
+