diff options
author | Stefan Radomski <github@mintwerk.de> | 2016-06-16 14:51:27 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2016-06-16 14:51:27 (GMT) |
commit | fa6b4f074d4be04d913d8b7dc062920341c34ecb (patch) | |
tree | 83ae475b184a3b1bccca2a69addcefb6c12d924e /src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp | |
parent | ed6aee05e2843be65c4ab445d79e70dc8dacc07b (diff) | |
download | uscxml-fa6b4f074d4be04d913d8b7dc062920341c34ecb.zip uscxml-fa6b4f074d4be04d913d8b7dc062920341c34ecb.tar.gz uscxml-fa6b4f074d4be04d913d8b7dc062920341c34ecb.tar.bz2 |
Fixed issue86 and some more bug fixes
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index 35d9c4b..05d37d4 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -28,6 +28,8 @@ #include "uscxml/util/DOM.h" #include <easylogging++.h> +#include <boost/algorithm/string.hpp> + #define EVENT_STRING_OR_UNDEF(field, cond) \ JSStringRef field##Name = JSStringCreateWithUTF8CString( #field ); \ JSStringRef field##Val = JSStringCreateWithUTF8CString(event.field.c_str()); \ @@ -399,7 +401,23 @@ Data JSCDataModel::evalAsData(const std::string& content) { Data JSCDataModel::getAsData(const std::string& content) { // parse as JSON test 578 - return Data::fromJSON(content); + Data d = Data::fromJSON(content); + if (!d.empty()) + return d; + + std::string trimmed = boost::trim_copy(content); + if (trimmed.length() > 0) { + if (isNumeric(trimmed.c_str(), 10)) { + d = Data(trimmed, Data::INTERPRETED); + } else if (trimmed.length() >= 2 && + ((trimmed[0] == '"' && trimmed[trimmed.length() - 1] == '"') || + (trimmed[0] == '\'' && trimmed[trimmed.length() - 1] == '\''))) { + d = Data(trimmed.substr(1, trimmed.length() - 2), Data::VERBATIM); + } else { + d = Data(trimmed, Data::INTERPRETED); + } + } + return d; } JSValueRef JSCDataModel::getDataAsValue(const Data& data) { |