Refactoring type size handler; using Java types as standard
[iot2.git] / iotjava / iotrmi / C++ / IoTRMICall.hpp
index eb767dd5a84f8c4f2fed0037df3582c9c4b1a08c..11797f92de09d661189db1814a51739a650e6c4f 100644 (file)
@@ -90,6 +90,7 @@ void* IoTRMICall::remoteCall(string methodSign, string retType, string paramCls[
                int retLen = 0;
                char* retObjBytes = NULL;
                retObjBytes = rmiClient->receiveBytes(retObjBytes, &retLen);
+               IoTRMIUtil::printBytes(retObjBytes, retLen, false);
                retObj = IoTRMIUtil::getParamObject(retObj, retType.c_str(), retObjBytes, retLen);
        }
        
@@ -107,15 +108,7 @@ int IoTRMICall::methodLength(string paramCls[], void* paramObj[], int numParam)
                // Find the parameter length
                int paramLen = rmiUtil->getTypeSize(paramCls[i]);
                if (paramLen == -1) { // Store the length of the field - indefinite length
-                       if (paramCls[i].compare("string") == 0) {
-                               // Get the length of the string through void* casting to string*
-                               paramLen = (*(string*)paramObj[i]).length();
-                       } else if (paramCls[i].compare("string[]") == 0) {
-                               paramLen = IoTRMIUtil::getByteStringLength(*(vector<string>*) paramObj[i]);
-                       } else {
-                               string error = "IoTRMICall: Unrecognizable type: " + paramCls[i];
-                               throw error;
-                       }
+                       paramLen = rmiUtil->getVarTypeSize(paramCls[i], paramObj[i]);
                        // Some space for param length, i.e. 32 bits for integer                
                        methodLen = methodLen + IoTRMIUtil::PARAM_LEN;
                }
@@ -141,15 +134,7 @@ char* IoTRMICall::methodToBytes(string methodSign, string paramCls[],
                // Find the parameter length
                int paramLen = rmiUtil->getTypeSize(paramCls[i]);
                if (paramLen == -1) { // Store the length of the field - indefinite length
-                       if (paramCls[i].compare("string") == 0) {
-                               // Get the length of the string through void* casting to string*
-                               paramLen = (*(string*)paramObj[i]).length();
-                       } else if (paramCls[i].compare("string[]") == 0) {
-                               paramLen = IoTRMIUtil::getByteStringLength(*(vector<string>*) paramObj[i]);
-                       } else {
-                               string error = "IoTRMICall: Unrecognizable type: " + paramCls[i];
-                               throw error;
-                       }
+                       paramLen = rmiUtil->getVarTypeSize(paramCls[i], paramObj[i]);
                        // Write the parameter length
                        char prmLenBytes[IoTRMIUtil::METHOD_ID_LEN];
                        IoTRMIUtil::intToByteArray(paramLen, prmLenBytes);