diff options
author | Tim Cooper <tim@buzzhives.com> | 2016-01-29 08:19:02 +0300 |
---|---|---|
committer | Tim Cooper <tim@buzzhives.com> | 2016-01-29 08:19:02 +0300 |
commit | 9434b748569303bfc67c872f1ed98d82e7f7e8f6 (patch) | |
tree | b0538fd38aa370296a69782901dcd1f21ead69f1 | |
parent | 2618747c644cc689acb0507256c5623472f52a41 (diff) | |
parent | daf758ab2f256937d0583c5db77d298f14163a33 (diff) |
Merge pull request #2 from Underground78/string_conversion_operators
Try to make some sense of the string conversion operators.
-rw-r--r-- | timxmlrpc.h | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/timxmlrpc.h b/timxmlrpc.h index 8b70bf0..96f9fd9 100644 --- a/timxmlrpc.h +++ b/timxmlrpc.h @@ -178,31 +178,16 @@ public: bool operator==(XmlRpcValue const& other) const; bool operator!=(XmlRpcValue const& other) const { return !(*this == other); } - // This is an alternative to operator std::string() that Aigner claims is needed for VS13 std::string GetStdString() { if (_type == TypeInt) { - char tmp[80]; - _itoa_s(u.asInt, tmp, 10); // itoa(u.asInt, tmp, 10); - return (std::string)tmp; + char tmp[16]; + _itoa_s(u.asInt, tmp, 10); + return tmp; } assertTypeOrInvalid(TypeString); - return std::string(u.asString); + return u.asString; } -#if defined(_MSC_VER) && (_MSC_VER > 1700) - operator const std::string& () { - if (_type == TypeInt) { - char tmp[80]; - _itoa_s(u.asInt, tmp, 10); // itoa(u.asInt, tmp, 10); - return std::move(std::string(tmp)); - } - assertTypeOrInvalid(TypeString); - return std::move(std::string(u.asString)); - } -#else - operator std::string () { return GetStdString(); } -#endif - // There are some basic type conversions here. This might mean that your // program parses stuff that strictly speaking it should report as a type error. @@ -227,9 +212,6 @@ public: assertTypeOrInvalid(TypeDouble); return 0; } - operator std::string&() { - return GetStdString(); - } operator const char*() { assertTypeOrInvalid(TypeString); return u.asString; } operator BinaryData&() { assertTypeOrInvalid(TypeBase64); return *u.asBinary; } |