forked from bblanchon/ArduinoJson
Added support of long long
(issue #171)
Moved all build settings to `ArduinoJson/Configuration.hpp` Added AppVeyor settings in source tree
This commit is contained in:
@ -17,31 +17,7 @@ using namespace ArduinoJson::Internals;
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
template <typename TFloat>
|
||||
static TFloat parse(const char *);
|
||||
|
||||
template <>
|
||||
float parse<float>(const char *s) {
|
||||
return static_cast<float>(strtod(s, NULL));
|
||||
}
|
||||
|
||||
template <>
|
||||
double parse<double>(const char *s) {
|
||||
return strtod(s, NULL);
|
||||
}
|
||||
|
||||
template <>
|
||||
long parse<long>(const char *s) {
|
||||
return strtol(s, NULL, 10);
|
||||
}
|
||||
|
||||
template <>
|
||||
int parse<int>(const char *s) {
|
||||
return atoi(s);
|
||||
}
|
||||
|
||||
template <>
|
||||
const char *JsonVariant::as<const char *>() const {
|
||||
const char *JsonVariant::asString() const {
|
||||
if (_type == JSON_UNPARSED && _content.asString &&
|
||||
!strcmp("null", _content.asString))
|
||||
return NULL;
|
||||
@ -61,22 +37,7 @@ JsonFloat JsonVariant::asFloat() const {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
JsonInteger JsonVariant::asInteger() const {
|
||||
if (_type == JSON_INTEGER || _type == JSON_BOOLEAN) return _content.asInteger;
|
||||
|
||||
if (_type >= JSON_FLOAT_0_DECIMALS)
|
||||
return static_cast<JsonInteger>(_content.asFloat);
|
||||
|
||||
if ((_type == JSON_STRING || _type == JSON_UNPARSED) && _content.asString) {
|
||||
if (!strcmp("true", _content.asString)) return 1;
|
||||
return parse<JsonInteger>(_content.asString);
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
template <>
|
||||
String JsonVariant::as<String>() const {
|
||||
String JsonVariant::toString() const {
|
||||
String s;
|
||||
if ((_type == JSON_STRING || _type == JSON_UNPARSED) &&
|
||||
_content.asString != NULL)
|
||||
|
Reference in New Issue
Block a user