diff --git a/JsonListener.h b/JsonListener.h index 26c0d85..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 +#include "crossplatform.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