diff options
Diffstat (limited to 'src/uscxml/messages')
-rw-r--r-- | src/uscxml/messages/Data.cpp | 4 | ||||
-rw-r--r-- | src/uscxml/messages/Data.h | 35 |
2 files changed, 20 insertions, 19 deletions
diff --git a/src/uscxml/messages/Data.cpp b/src/uscxml/messages/Data.cpp index 277b7d8..6c48c46 100644 --- a/src/uscxml/messages/Data.cpp +++ b/src/uscxml/messages/Data.cpp @@ -350,8 +350,8 @@ std::string Data::jsonEscape(const std::string& expr) { os << "\\n"; } else if (expr[i] == '\r') { os << "\\r"; - } else if (expr[i] == '\'') { - os << "\\'"; +// } else if (expr[i] == '\'') { +// os << "\\\'"; } else if (expr[i] == '\"') { os << "\\\""; } else if (expr[i] == '\\') { diff --git a/src/uscxml/messages/Data.h b/src/uscxml/messages/Data.h index 19134dd..b279696 100644 --- a/src/uscxml/messages/Data.h +++ b/src/uscxml/messages/Data.h @@ -23,6 +23,7 @@ #include <list> #include <map> #include <memory> +#include <type_traits> #include "uscxml/Common.h" #include "uscxml/util/Convenience.h" @@ -49,27 +50,27 @@ public: Data() : node(NULL), type(INTERPRETED) {} - Data(const char* data, size_t size, const std::string& mimeType, bool adopt = false); + explicit Data(const char* data, size_t size, const std::string& mimeType, bool adopt = false); // convenience constructors - Data(bool atom) : node(NULL), type(VERBATIM) { - if (atom) { - this->atom = "true"; - } else { - this->atom = "false"; - } - } +// explicit Data(bool atom) : node(NULL), type(VERBATIM) { +// if (atom) { +// this->atom = "true"; +// } else { +// this->atom = "false"; +// } +// } explicit Data(XERCESC_NS::DOMNode* node_) : node(node_) {} - // template <typename T> Data(T value, Type type = INTERPRETED) : atom(toStr(value)), type(type) {} - // we will have to drop this constructor as it interferes with operator Data() and requires C++11 - template <typename T> - explicit Data(T value, typename std::enable_if<! std::is_base_of<Data, T>::value>::type* = nullptr) - : node(NULL), atom(toStr(value)), type(VERBATIM) {} + explicit Data(const std::string& value) : node(NULL), atom(toStr(value)), type(VERBATIM) {} + + template <typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type> + explicit Data(T value) + : node(NULL), atom(toStr(value)), type(INTERPRETED) {} + template <typename T> - explicit Data(T value, Type type, typename std::enable_if<! std::is_base_of<Data, T>::value>::type* = nullptr) - : node(NULL), atom(toStr(value)), type(type) {} + explicit Data(T value, Type type) : node(NULL), atom(toStr(value)), type(type) {} ~Data() { } @@ -170,11 +171,11 @@ public: } bool operator==(const Data &other) const { - return (*this < other || other < *this); + return !(*this != other); } bool operator!=(const Data &other) const { - return !(*this == other); + return (*this < other || other < *this); } operator std::string() const { |