+// 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) {
+ paramLen = IoTRMIUtil::getByteStringLength(*(vector<string>*) paramObj);
+ } else if (type.compare("byte[]") == 0) {
+ int dataSize = getTypeSize("byte");
+ paramLen = (*(vector<char>*) paramObj).size() * dataSize;
+ } else if (type.compare("short[]") == 0) {
+ int dataSize = getTypeSize("short");
+ paramLen = (*(vector<short>*) paramObj).size() * dataSize;
+ } else if (type.compare("int[]") == 0) {
+ int dataSize = getTypeSize("int");
+ paramLen = (*(vector<int>*) paramObj).size() * dataSize;
+ } else if (type.compare("long[]") == 0) {
+ int dataSize = getTypeSize("long");
+ paramLen = (*(vector<int64_t>*) paramObj).size() * dataSize;
+ } else if (type.compare("float[]") == 0) {
+ int dataSize = getTypeSize("float");
+ paramLen = (*(vector<float>*) paramObj).size() * dataSize;
+ } else if (type.compare("double[]") == 0) {
+ int dataSize = getTypeSize("double");
+ paramLen = (*(vector<double>*) paramObj).size() * dataSize;
+ } else if (type.compare("bool[]") == 0) {
+ int dataSize = getTypeSize("bool");
+ paramLen = (*(vector<bool>*) paramObj).size() * dataSize;
+ } else if (type.compare("char[]") == 0) {
+ int dataSize = getTypeSize("char");
+ paramLen = (*(vector<char>*) paramObj).size() * dataSize;
+ } else {
+ string error = "IoTRMICall: Unrecognizable type: " + type;
+ throw error;
+ }
+
+ return paramLen;
+}
+
+