summaryrefslogtreecommitdiffstats
path: root/matlab
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2016-07-28 15:32:38 +0200
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2016-07-28 15:32:38 +0200
commit302b0c7eacf46c7315f2390e270ad20f5025c342 (patch)
treec0a26ab810dc22e2f3157a70c05ea91ed533d3b4 /matlab
parent2d110508560a434b23fc03e93019167d1968331d (diff)
downloadastra-302b0c7eacf46c7315f2390e270ad20f5025c342.tar.gz
astra-302b0c7eacf46c7315f2390e270ad20f5025c342.tar.bz2
astra-302b0c7eacf46c7315f2390e270ad20f5025c342.tar.xz
astra-302b0c7eacf46c7315f2390e270ad20f5025c342.zip
Convert one more string parsing function to stringToDouble
Diffstat (limited to 'matlab')
-rw-r--r--matlab/mex/mexHelpFunctions.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/matlab/mex/mexHelpFunctions.cpp b/matlab/mex/mexHelpFunctions.cpp
index 13c4ade..b13dde3 100644
--- a/matlab/mex/mexHelpFunctions.cpp
+++ b/matlab/mex/mexHelpFunctions.cpp
@@ -402,16 +402,13 @@ mxArray* stringToMxArray(std::string input)
return pVector;
}
- // number
- char* end;
- double content = ::strtod(input.c_str(), &end);
- bool isnumber = !*end;
- if (isnumber) {
- return mxCreateDoubleScalar(content);
+ try {
+ // number
+ return mxCreateDoubleScalar(StringUtil::stringToDouble(input));
+ } catch (const StringUtil::bad_cast &) {
+ // string
+ return mxCreateString(input.c_str());
}
-
- // string
- return mxCreateString(input.c_str());
}
//-----------------------------------------------------------------------------------------
// turn a c++ map into a matlab struct