summaryrefslogtreecommitdiff
path: root/include/lib/ArduinoJson/StringTraits
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/StringTraits
parent0248c6352f2117e50fac71dd632a79d8fa4f8737 (diff)
remove external libraries from main branch
Diffstat (limited to 'include/lib/ArduinoJson/StringTraits')
-rw-r--r--include/lib/ArduinoJson/StringTraits/ArduinoStream.hpp61
-rw-r--r--include/lib/ArduinoJson/StringTraits/CharPointer.hpp64
-rw-r--r--include/lib/ArduinoJson/StringTraits/FlashString.hpp61
-rw-r--r--include/lib/ArduinoJson/StringTraits/StdStream.hpp60
-rw-r--r--include/lib/ArduinoJson/StringTraits/StdString.hpp77
-rw-r--r--include/lib/ArduinoJson/StringTraits/StringTraits.hpp36
6 files changed, 0 insertions, 359 deletions
diff --git a/include/lib/ArduinoJson/StringTraits/ArduinoStream.hpp b/include/lib/ArduinoJson/StringTraits/ArduinoStream.hpp
deleted file mode 100644
index 5db0852..0000000
--- a/include/lib/ArduinoJson/StringTraits/ArduinoStream.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#pragma once
-
-#if ARDUINOJSON_ENABLE_ARDUINO_STREAM
-
-#include <Stream.h>
-
-namespace ArduinoJson {
-namespace Internals {
-
-struct ArduinoStreamTraits {
- class Reader {
- Stream& _stream;
- char _current, _next;
-
- public:
- Reader(Stream& stream) : _stream(stream), _current(0), _next(0) {}
-
- void move() {
- _current = _next;
- _next = 0;
- }
-
- char current() {
- if (!_current) _current = read();
- return _current;
- }
-
- char next() {
- // assumes that current() has been called
- if (!_next) _next = read();
- return _next;
- }
-
- private:
- char read() {
- // don't use _stream.read() as it ignores the timeout
- char c = 0;
- _stream.readBytes(&c, 1);
- return c;
- }
- };
-
- static const bool has_append = false;
- static const bool has_equals = false;
-};
-
-template <typename TStream>
-struct StringTraits<
- TStream,
- // match any type that is derived from Stream:
- typename EnableIf<
- IsBaseOf<Stream, typename RemoveReference<TStream>::type>::value>::type>
- : ArduinoStreamTraits {};
-}
-}
-
-#endif
diff --git a/include/lib/ArduinoJson/StringTraits/CharPointer.hpp b/include/lib/ArduinoJson/StringTraits/CharPointer.hpp
deleted file mode 100644
index 98896cc..0000000
--- a/include/lib/ArduinoJson/StringTraits/CharPointer.hpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#pragma once
-
-namespace ArduinoJson {
-namespace Internals {
-
-template <typename TChar>
-struct CharPointerTraits {
- class Reader {
- const TChar* _ptr;
-
- public:
- Reader(const TChar* ptr)
- : _ptr(ptr ? ptr : reinterpret_cast<const TChar*>("")) {}
-
- void move() {
- ++_ptr;
- }
-
- char current() const {
- return char(_ptr[0]);
- }
-
- char next() const {
- return char(_ptr[1]);
- }
- };
-
- static bool equals(const TChar* str, const char* expected) {
- const char* actual = reinterpret_cast<const char*>(str);
- if (!actual || !expected) return actual == expected;
- return strcmp(actual, expected) == 0;
- }
-
- static bool is_null(const TChar* str) {
- return !str;
- }
-
- typedef const char* duplicate_t;
-
- template <typename Buffer>
- static duplicate_t duplicate(const TChar* str, Buffer* buffer) {
- if (!str) return NULL;
- size_t size = strlen(reinterpret_cast<const char*>(str)) + 1;
- void* dup = buffer->alloc(size);
- if (dup != NULL) memcpy(dup, str, size);
- return static_cast<duplicate_t>(dup);
- }
-
- static const bool has_append = false;
- static const bool has_equals = true;
- static const bool should_duplicate = !IsConst<TChar>::value;
-};
-
-// char*, unsigned char*, signed char*
-// const char*, const unsigned char*, const signed char*
-template <typename TChar>
-struct StringTraits<TChar*, typename EnableIf<IsChar<TChar>::value>::type>
- : CharPointerTraits<TChar> {};
-} // namespace Internals
-} // namespace ArduinoJson
diff --git a/include/lib/ArduinoJson/StringTraits/FlashString.hpp b/include/lib/ArduinoJson/StringTraits/FlashString.hpp
deleted file mode 100644
index 0701b9b..0000000
--- a/include/lib/ArduinoJson/StringTraits/FlashString.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#pragma once
-
-#if ARDUINOJSON_ENABLE_PROGMEM
-
-namespace ArduinoJson {
-namespace Internals {
-template <>
-struct StringTraits<const __FlashStringHelper*, void> {
- class Reader {
- const char* _ptr;
-
- public:
- Reader(const __FlashStringHelper* ptr)
- : _ptr(reinterpret_cast<const char*>(ptr)) {}
-
- void move() {
- _ptr++;
- }
-
- char current() const {
- return pgm_read_byte_near(_ptr);
- }
-
- char next() const {
- return pgm_read_byte_near(_ptr + 1);
- }
- };
-
- static bool equals(const __FlashStringHelper* str, const char* expected) {
- const char* actual = reinterpret_cast<const char*>(str);
- if (!actual || !expected) return actual == expected;
- return strcmp_P(expected, actual) == 0;
- }
-
- static bool is_null(const __FlashStringHelper* str) {
- return !str;
- }
-
- typedef const char* duplicate_t;
-
- template <typename Buffer>
- static duplicate_t duplicate(const __FlashStringHelper* str, Buffer* buffer) {
- if (!str) return NULL;
- size_t size = strlen_P((const char*)str) + 1;
- void* dup = buffer->alloc(size);
- if (dup != NULL) memcpy_P(dup, (const char*)str, size);
- return static_cast<duplicate_t>(dup);
- }
-
- static const bool has_append = false;
- static const bool has_equals = true;
- static const bool should_duplicate = true;
-};
-} // namespace Internals
-} // namespace ArduinoJson
-
-#endif
diff --git a/include/lib/ArduinoJson/StringTraits/StdStream.hpp b/include/lib/ArduinoJson/StringTraits/StdStream.hpp
deleted file mode 100644
index 227c744..0000000
--- a/include/lib/ArduinoJson/StringTraits/StdStream.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#pragma once
-
-#if ARDUINOJSON_ENABLE_STD_STREAM
-
-#include <istream>
-
-namespace ArduinoJson {
-namespace Internals {
-
-struct StdStreamTraits {
- class Reader {
- std::istream& _stream;
- char _current, _next;
-
- public:
- Reader(std::istream& stream) : _stream(stream), _current(0), _next(0) {}
-
- void move() {
- _current = _next;
- _next = 0;
- }
-
- char current() {
- if (!_current) _current = read();
- return _current;
- }
-
- char next() {
- // assumes that current() has been called
- if (!_next) _next = read();
- return _next;
- }
-
- private:
- Reader& operator=(const Reader&); // Visual Studio C4512
-
- char read() {
- return _stream.eof() ? '\0' : static_cast<char>(_stream.get());
- }
- };
-
- static const bool has_append = false;
- static const bool has_equals = false;
-};
-
-template <typename TStream>
-struct StringTraits<
- TStream,
- // match any type that is derived from std::istream:
- typename EnableIf<IsBaseOf<
- std::istream, typename RemoveReference<TStream>::type>::value>::type>
- : StdStreamTraits {};
-}
-}
-
-#endif
diff --git a/include/lib/ArduinoJson/StringTraits/StdString.hpp b/include/lib/ArduinoJson/StringTraits/StdString.hpp
deleted file mode 100644
index 35f4461..0000000
--- a/include/lib/ArduinoJson/StringTraits/StdString.hpp
+++ /dev/null
@@ -1,77 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#pragma once
-
-#if ARDUINOJSON_ENABLE_STD_STRING || ARDUINOJSON_ENABLE_ARDUINO_STRING
-
-#if ARDUINOJSON_ENABLE_ARDUINO_STRING
-#include <WString.h>
-#endif
-
-#if ARDUINOJSON_ENABLE_STD_STRING
-#include <string>
-#endif
-
-namespace ArduinoJson {
-namespace Internals {
-
-template <typename TString>
-struct StdStringTraits {
- typedef const char* duplicate_t;
-
- template <typename Buffer>
- static duplicate_t duplicate(const TString& str, Buffer* buffer) {
- if (!str.c_str()) return NULL; // <- Arduino string can return NULL
- size_t size = str.length() + 1;
- void* dup = buffer->alloc(size);
- if (dup != NULL) memcpy(dup, str.c_str(), size);
- return static_cast<duplicate_t>(dup);
- }
-
- static bool is_null(const TString& str) {
- // Arduino's String::c_str() can return NULL
- return !str.c_str();
- }
-
- struct Reader : CharPointerTraits<char>::Reader {
- Reader(const TString& str) : CharPointerTraits<char>::Reader(str.c_str()) {}
- };
-
- static bool equals(const TString& str, const char* expected) {
- // Arduino's String::c_str() can return NULL
- const char* actual = str.c_str();
- if (!actual || !expected) return actual == expected;
- return 0 == strcmp(actual, expected);
- }
-
- static void append(TString& str, char c) {
- str += c;
- }
-
- static void append(TString& str, const char* s) {
- str += s;
- }
-
- static const bool has_append = true;
- static const bool has_equals = true;
- static const bool should_duplicate = true;
-};
-
-#if ARDUINOJSON_ENABLE_ARDUINO_STRING
-template <>
-struct StringTraits<String, void> : StdStringTraits<String> {};
-template <>
-struct StringTraits<StringSumHelper, void> : StdStringTraits<StringSumHelper> {
-};
-#endif
-
-#if ARDUINOJSON_ENABLE_STD_STRING
-template <>
-struct StringTraits<std::string, void> : StdStringTraits<std::string> {};
-#endif
-} // namespace Internals
-} // namespace ArduinoJson
-
-#endif
diff --git a/include/lib/ArduinoJson/StringTraits/StringTraits.hpp b/include/lib/ArduinoJson/StringTraits/StringTraits.hpp
deleted file mode 100644
index dd5694b..0000000
--- a/include/lib/ArduinoJson/StringTraits/StringTraits.hpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// ArduinoJson - arduinojson.org
-// Copyright Benoit Blanchon 2014-2018
-// MIT License
-
-#pragma once
-
-#include <string.h>
-#include "../Configuration.hpp"
-#include "../TypeTraits/EnableIf.hpp"
-#include "../TypeTraits/IsBaseOf.hpp"
-#include "../TypeTraits/IsChar.hpp"
-#include "../TypeTraits/IsConst.hpp"
-#include "../TypeTraits/RemoveReference.hpp"
-
-namespace ArduinoJson {
-namespace Internals {
-
-template <typename TString, typename Enable = void>
-struct StringTraits {
- static const bool has_append = false;
- static const bool has_equals = false;
-};
-
-template <typename TString>
-struct StringTraits<const TString, void> : StringTraits<TString> {};
-
-template <typename TString>
-struct StringTraits<TString&, void> : StringTraits<TString> {};
-}
-}
-
-#include "ArduinoStream.hpp"
-#include "CharPointer.hpp"
-#include "FlashString.hpp"
-#include "StdStream.hpp"
-#include "StdString.hpp"