t_ilm_int surfacero_length;
t_ilm_layer* layerro;
t_ilm_int layerro_length;
- const char* filename;
+ char* filename;
toolbox_state state;
} t_param_struct;
-const char* parseParameters(char* argv, const char* argument, const char* beginterm , const char* endterm)
+char* parseParameters(char* argv, const char* argument, const char* beginterm , const char* endterm)
{
- const char* cresult = NULL;
+ char* cresult = new char[2048];
std::string result = std::string(argv);
printf("Argument is %s\n",result.c_str());
size_t pos = result.find(std::string (argument));
endpos = result.find( std::string (endterm), beginpos);
if ( endpos != std::string::npos )
{
- cresult = (result.substr(beginpos,endpos-beginpos)).c_str();
+ strcpy(cresult,(result.substr(beginpos,endpos-beginpos)).c_str());
printf("Value is %s\n",cresult);
}
}
{
t_ilm_int *tempArray = new t_ilm_int[4];
bool result = true;
- char * pRes = new char[strlen(param)+1];
- strcpy(pRes,param);
+ std::string pRes = std::string(param);
+ size_t pos = pRes.find(",");
int i = 0;
- pRes = strtok (pRes,",");
- while (pRes != NULL)
+ while (pos != std::string::npos)
{
- tempArray[i++] = atoi(pRes);
- pRes = strtok (NULL, ",");
+ std::string tempString = pRes.substr(0,pos);
+ printf("Dim param %s\n",tempString.c_str());
+ tempArray[i++] = atoi(tempString.c_str());
+ pRes = pRes.substr(pos+1);
+ pos = pRes.find(",");
+ /*convert the last value*/
+ if ( pos == std::string::npos && i==3 )
+ {
+ tempString = pRes.substr(0);
+ printf("Dim param %s\n",tempString.c_str());
+ tempArray[i++] = atoi(tempString.c_str());
+ }
}
if (i<4)
{
memcpy(pArray,tempArray,4*sizeof(t_ilm_int));
printf("Dimension Parameter successfully filled %i %i %i %i\n",pArray[0],pArray[1],pArray[2],pArray[3]);
}
- delete[] pRes;
delete[] tempArray;
return result;
}
while ( result && i < curParam.numberArguments )
{
bool found = false;
- const char * param = NULL;
+ char * param = NULL;
switch (curParam.params[i].type)
{
case ARGUMENT_LAYERID :
if ( param != 0 )
{
found = true;
- pStruct->filename = param;
+ pStruct->filename = new char[strlen(param)+1];
+ strcpy(pStruct->filename,param);
}
printf("Filename is %s\n",pStruct->filename);
break;
result = false;
}
i++;
+ if (param != NULL)
+ delete[] param;
}
return result;
}