From 0dec72e5a6dc43206a82a540b3e8bb790e6ed250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mih=C3=A1ly=20Rozovits?= Date: Mon, 24 Mar 2025 23:32:22 +0100 Subject: [PATCH 1/2] making the library cross platform to be abe to be used on native builds for testing projects --- JsonListener.h | 2 +- JsonStreamingParser.h | 2 +- crossplatform.h | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 crossplatform.h diff --git a/JsonListener.h b/JsonListener.h index 26c0d85..5850079 100644 --- a/JsonListener.h +++ b/JsonListener.h @@ -25,7 +25,7 @@ See more at http://blog.squix.ch and https://github.com/squix78/json-streaming-p #pragma once -#include +#include "multiplatform.h" class JsonListener { private: diff --git a/JsonStreamingParser.h b/JsonStreamingParser.h index 377e846..0acf8f3 100644 --- a/JsonStreamingParser.h +++ b/JsonStreamingParser.h @@ -25,7 +25,7 @@ See more at http://blog.squix.ch and https://github.com/squix78/json-streaming-p #pragma once -#include +#include "crossplatform.h" #include "JsonListener.h" #define STATE_START_DOCUMENT 0 diff --git a/crossplatform.h b/crossplatform.h new file mode 100644 index 0000000..431f4aa --- /dev/null +++ b/crossplatform.h @@ -0,0 +1,35 @@ +#ifndef __MULTIPLATFORM_H__ +#define __MULTIPLATFORM_H__ + +#ifdef ARDUINO +#include +#else + +#include +// #include + +template inline T min(T a, T b){ + return a > b ? b : a; +} +template inline T max(T a, T b){ + return a > b ? a : b; +} + +typedef bool boolean; + +class String : public std::string { + public: + String(const char* c_str) : std::string(c_str) {} + String(std::string str) : std::string(str) {} + + boolean equals(String other){ + return compare(other) == 0; + } + + String operator +(String other){ + return String(this->append(other)); + } +}; + +#endif // ARDUINO +#endif // __MULTIPLATFORM_H__ \ No newline at end of file From c5bba89353fdd05d8162227c0e5d3a6bc7716316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mih=C3=A1ly=20Rozovits?= Date: Mon, 24 Mar 2025 23:52:30 +0100 Subject: [PATCH 2/2] fixed wrong include --- JsonListener.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JsonListener.h b/JsonListener.h index 5850079..b473edd 100644 --- a/JsonListener.h +++ b/JsonListener.h @@ -25,7 +25,7 @@ See more at http://blog.squix.ch and https://github.com/squix78/json-streaming-p #pragma once -#include "multiplatform.h" +#include "crossplatform.h" class JsonListener { private: