Changeset 7860 for issm/trunk/src/c/io/OptionParse.cpp
- Timestamp:
- 04/12/11 15:37:07 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/io/OptionParse.cpp
r7761 r7860 42 42 43 43 OptionDouble *odouble = NULL; 44 const mwSize *ipt = NULL;45 44 46 45 /*check and parse the name */ … … 54 53 } 55 54 56 odouble->numel=mxGetNumberOfElements(prhs[0]); 57 odouble->ndims=mxGetNumberOfDimensions(prhs[0]); 58 ipt =mxGetDimensions(prhs[0]); 59 odouble->size =(int *) xmalloc(odouble->ndims*sizeof(int)); 60 for (int i=0; i<odouble->ndims; i++) odouble->size[i]=(int)ipt[i]; 61 62 // note that FetchData does not correctly handle ndims >= 3 63 if (odouble->ndims > 2) { 64 _printf_(true,"WARNING -- option \"%s\" of class \"%s\" has ndims=%d and will be skipped.\n",odouble->name,mxGetClassName(prhs[0]),odouble->ndims); 65 odouble->numel=0; 66 } 67 else FetchData(&odouble->values,NULL,NULL,prhs[0]); 55 FetchData(&odouble->values,&odouble->numel,&odouble->ndims,&odouble->size,prhs[0]); 68 56 69 57 return(odouble); … … 73 61 74 62 OptionLogical *ological = NULL; 75 const mwSize *ipt = NULL;76 bool btemp;77 63 78 64 /*check and parse the name */ … … 86 72 } 87 73 88 ological->numel=mxGetNumberOfElements(prhs[0]); 89 ological->ndims=mxGetNumberOfDimensions(prhs[0]); 90 ipt =mxGetDimensions(prhs[0]); 91 ological->size =(int *) xmalloc(ological->ndims*sizeof(int)); 92 for (int i=0; i<ological->ndims; i++) ological->size[i]=(int)ipt[i]; 93 94 // note that FetchData does not correctly handle non-scalar logicals 95 if (ological->ndims > 2 || ological->size[0] > 1 || ological->size[1] > 1) { 96 _printf_(true,"WARNING -- option \"%s\" of class \"%s\" is more than [1x1] and will be skipped.\n",ological->name,mxGetClassName(prhs[0])); 97 ological->numel=0; 98 } 99 else { 100 //FetchData(&ological->values,prhs[0]); 101 //could be memory leak until FetchData handles logical arrays 102 ological->values=(bool *) xmalloc(sizeof(bool)); 103 FetchData(ological->values,prhs[0]); 104 } 74 FetchData(&ological->values,&ological->numel,&ological->ndims,&ological->size,prhs[0]); 105 75 106 76 return(ological); … … 110 80 111 81 OptionChar *ochar = NULL; 112 const mwSize *ipt = NULL;113 82 114 83 /*check and parse the name */ … … 122 91 } 123 92 124 ochar->numel=mxGetNumberOfElements(prhs[0]); 125 ochar->ndims=mxGetNumberOfDimensions(prhs[0]); 126 ipt =mxGetDimensions(prhs[0]); 127 ochar->size =(int *) xmalloc(ochar->ndims*sizeof(int)); 128 for(int i=0; i<ochar->ndims; i++) ochar->size[i]=(int)ipt[i]; 129 130 //note that FetchData does not correctly handle ndims >= 2 or multiple rows 131 if (ochar->ndims > 2 || ochar->size[0] > 1) { 132 _printf_(true,"WARNING -- option \"%s\" of class \"%s\" is more than [1xn] and will be skipped.\n",ochar->name,mxGetClassName(prhs[0])); 133 ochar->numel=0; 134 } 135 else FetchData(&ochar->values,prhs[0]); 93 FetchData(&ochar->values,&ochar->numel,&ochar->ndims,&ochar->size,prhs[0]); 136 94 137 95 return(ochar);
Note:
See TracChangeset
for help on using the changeset viewer.