summaryrefslogtreecommitdiff
path: root/include/lib/ArduinoJson/JsonVariantImpl.hpp
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-09-07 12:57:04 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2020-09-07 12:57:04 +0200
commit0558244645611f314f47e0fa427f7323ce253eaf (patch)
tree824bcd55ec8577703345106d0a08e167407500a7 /include/lib/ArduinoJson/JsonVariantImpl.hpp
parent0248c6352f2117e50fac71dd632a79d8fa4f8737 (diff)
remove external libraries from main branch
Diffstat (limited to 'include/lib/ArduinoJson/JsonVariantImpl.hpp')
-rw-r--r--include/lib/ArduinoJson/JsonVariantImpl.hpp126
1 files changed, 0 insertions, 126 deletions
diff --git a/include/lib/ArduinoJson/JsonVariantImpl.hpp b/include/lib/ArduinoJson/JsonVariantImpl.hpp
deleted file mode 100644
index 31f96ce..0000000
--- a/include/lib/ArduinoJson/JsonVariantImpl.hpp
+++ /dev/null
@@ -1,126 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#pragma once
-
-#include "Configuration.hpp"
-#include "JsonArray.hpp"
-#include "JsonObject.hpp"
-#include "JsonVariant.hpp"
-#include "Polyfills/isFloat.hpp"
-#include "Polyfills/isInteger.hpp"
-#include "Polyfills/parseFloat.hpp"
-#include "Polyfills/parseInteger.hpp"
-
-#include <string.h> // for strcmp
-
-namespace ArduinoJson {
-
-inline JsonVariant::JsonVariant(const JsonArray &array) {
- if (array.success()) {
- _type = Internals::JSON_ARRAY;
- _content.asArray = const_cast<JsonArray *>(&array);
- } else {
- _type = Internals::JSON_UNDEFINED;
- }
-}
-
-inline JsonVariant::JsonVariant(const JsonObject &object) {
- if (object.success()) {
- _type = Internals::JSON_OBJECT;
- _content.asObject = const_cast<JsonObject *>(&object);
- } else {
- _type = Internals::JSON_UNDEFINED;
- }
-}
-
-inline JsonArray &JsonVariant::variantAsArray() const {
- if (_type == Internals::JSON_ARRAY) return *_content.asArray;
- return JsonArray::invalid();
-}
-
-inline JsonObject &JsonVariant::variantAsObject() const {
- if (_type == Internals::JSON_OBJECT) return *_content.asObject;
- return JsonObject::invalid();
-}
-
-template <typename T>
-inline T JsonVariant::variantAsInteger() const {
- using namespace Internals;
- switch (_type) {
- case JSON_UNDEFINED:
- return 0;
- case JSON_POSITIVE_INTEGER:
- case JSON_BOOLEAN:
- return T(_content.asInteger);
- case JSON_NEGATIVE_INTEGER:
- return T(~_content.asInteger + 1);
- case JSON_STRING:
- case JSON_UNPARSED:
- return parseInteger<T>(_content.asString);
- default:
- return T(_content.asFloat);
- }
-}
-
-inline const char *JsonVariant::variantAsString() const {
- using namespace Internals;
- if (_type == JSON_UNPARSED && _content.asString &&
- !strcmp("null", _content.asString))
- return NULL;
- if (_type == JSON_STRING || _type == JSON_UNPARSED) return _content.asString;
- return NULL;
-}
-
-template <typename T>
-inline T JsonVariant::variantAsFloat() const {
- using namespace Internals;
- switch (_type) {
- case JSON_UNDEFINED:
- return 0;
- case JSON_POSITIVE_INTEGER:
- case JSON_BOOLEAN:
- return static_cast<T>(_content.asInteger);
- case JSON_NEGATIVE_INTEGER:
- return -static_cast<T>(_content.asInteger);
- case JSON_STRING:
- case JSON_UNPARSED:
- return parseFloat<T>(_content.asString);
- default:
- return static_cast<T>(_content.asFloat);
- }
-}
-
-inline bool JsonVariant::variantIsBoolean() const {
- using namespace Internals;
- if (_type == JSON_BOOLEAN) return true;
-
- if (_type != JSON_UNPARSED || _content.asString == NULL) return false;
-
- return !strcmp(_content.asString, "true") ||
- !strcmp(_content.asString, "false");
-}
-
-inline bool JsonVariant::variantIsInteger() const {
- using namespace Internals;
-
- return _type == JSON_POSITIVE_INTEGER || _type == JSON_NEGATIVE_INTEGER ||
- (_type == JSON_UNPARSED && isInteger(_content.asString));
-}
-
-inline bool JsonVariant::variantIsFloat() const {
- using namespace Internals;
-
- return _type == JSON_FLOAT || _type == JSON_POSITIVE_INTEGER ||
- _type == JSON_NEGATIVE_INTEGER ||
- (_type == JSON_UNPARSED && isFloat(_content.asString));
-}
-
-#if ARDUINOJSON_ENABLE_STD_STREAM
-inline std::ostream &operator<<(std::ostream &os, const JsonVariant &source) {
- return source.printTo(os);
-}
-#endif
-
-} // namespace ArduinoJson