From 920be8bb7efb90d582ff3687f7af3e61a2e877fb Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Sun, 7 Apr 2019 21:00:55 +0900 Subject: [PATCH] Supports ArduinoJson V6. Issue #47 --- src/AutoConnectAux.h | 16 ++++----- src/AutoConnectAuxImpl.h | 2 +- src/AutoConnectElementBasisImpl.h | 60 ------------------------------- 3 files changed, 9 insertions(+), 69 deletions(-) diff --git a/src/AutoConnectAux.h b/src/AutoConnectAux.h index 5d7ac7d..005292b 100644 --- a/src/AutoConnectAux.h +++ b/src/AutoConnectAux.h @@ -60,17 +60,17 @@ class AutoConnectAux : public PageBuilder { bool release(const String& name); /**< Release an AutoConnectElement */ bool setElementValue(const String& name, const String value); /**< Set value to specified element */ bool setElementValue(const String& name, std::vector const& values); /**< Set values collection to specified element */ - void setTitle(const String& title) { _title = title; } /**< Set a title of the auxiliary page */ + void setTitle(const String& title) { _title = title; } /**< Set a title of the auxiliary page */ void on(const AuxHandlerFunctionT handler, const AutoConnectExitOrder_t order = AC_EXIT_AHEAD) { _handler = handler; _order = order; } /**< Set user handler */ void onUpload(PageBuilder::UploadFuncT uploadFunc) override { _uploadHandler = uploadFunc; } #ifdef AUTOCONNECT_USE_JSON - bool load(const String& in); /**< Load whole elements to AutoConnectAux Page */ - bool load(const __FlashStringHelper* in); /**< Load whole elements to AutoConnectAux Page */ - bool load(Stream& in); /**< Load whole elements to AutoConnectAux Page */ - bool loadElement(const String& in, const String& name = String("")); /**< Load specified element */ - bool loadElement(const __FlashStringHelper* in, const String& name = String("")); /**< Load specified element */ - bool loadElement(Stream& in, const String& name = String("")); /**< Load specified element */ + bool load(const String& in); /**< Load whole elements to AutoConnectAux Page */ + bool load(const __FlashStringHelper* in); /**< Load whole elements to AutoConnectAux Page */ + bool load(Stream& in); /**< Load whole elements to AutoConnectAux Page */ + bool loadElement(const String& in, const String& name = String("")); /**< Load specified element */ + bool loadElement(const __FlashStringHelper* in, const String& name = String("")); /**< Load specified element */ + bool loadElement(Stream& in, const String& name = String("")); /**< Load specified element */ size_t saveElement(Stream& out, std::vector const& names = {}); /**< Write elements of AutoConnectAux to the stream */ #endif // !AUTOCONNECT_USE_JSON @@ -96,7 +96,7 @@ class AutoConnectAux : public PageBuilder { bool _parseElement(T in, const String& name); AutoConnectElement& _loadElement(JsonObject& in, const String& name); /**< Load an element as specified name from JSON object */ AutoConnectElement* _createElement(const JsonObject& json); /**< Create an AutoConnectElement instance from JSON object */ - static ACElement_t _asElementType(const String& type); /**< Convert a string of element type to the enumeration value */ + static ACElement_t _asElementType(const String& type); /**< Convert a string of element type to the enumeration value */ #endif // !AUTOCONNECT_USE_JSON String _title; /**< A title of the page */ diff --git a/src/AutoConnectAuxImpl.h b/src/AutoConnectAuxImpl.h index 799afbe..66d01d7 100644 --- a/src/AutoConnectAuxImpl.h +++ b/src/AutoConnectAuxImpl.h @@ -256,7 +256,7 @@ bool AutoConnectAux::_parseElement(T in, const String& name) { AC_DBG("Deserialize:%s\n", err.c_str()); return false; } - jb = jsonBuffer.as(); + jb = jsonBuffer.as(); #endif return _loadElement(jb, name); } diff --git a/src/AutoConnectElementBasisImpl.h b/src/AutoConnectElementBasisImpl.h index 43c4cf3..8437da0 100644 --- a/src/AutoConnectElementBasisImpl.h +++ b/src/AutoConnectElementBasisImpl.h @@ -19,66 +19,6 @@ #endif #include "AutoConnectElementBasis.h" -/** - * Casts only a class derived from the AutoConnectElement class to the - * actual element class. - */ -// template<> -// inline AutoConnectButtonBasis& AutoConnectElementBasis::as(void) { -// if (typeOf() != AC_Button) -// AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); -// return reinterpret_cast(*this); -// } - -// template<> -// inline AutoConnectCheckboxBasis& AutoConnectElementBasis::as(void) { -// if (typeOf() != AC_Checkbox) -// AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); -// return reinterpret_cast(*this); -// } - -// template<> -// inline AutoConnectFileBasis& AutoConnectElementBasis::as(void) { -// if (typeOf() != AC_File) -// AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); -// return reinterpret_cast(*this); -// } - -// template<> -// inline AutoConnectInputBasis& AutoConnectElementBasis::as(void) { -// if (typeOf() != AC_Input) -// AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); -// return reinterpret_cast(*this); -// } - -// template<> -// inline AutoConnectRadioBasis& AutoConnectElementBasis::as(void) { -// if (typeOf() != AC_Radio) -// AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); -// return reinterpret_cast(*this); -// } - -// template<> -// inline AutoConnectSelectBasis& AutoConnectElementBasis::as(void) { -// if (typeOf() != AC_Select) -// AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); -// return reinterpret_cast(*this); -// } - -// template<> -// inline AutoConnectSubmitBasis& AutoConnectElementBasis::as(void) { -// if (typeOf() != AC_Submit) -// AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); -// return reinterpret_cast(*this); -// } - -// template<> -// inline AutoConnectTextBasis& AutoConnectElementBasis::as(void) { -// if (typeOf() != AC_Text) -// AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); -// return reinterpret_cast(*this); -// } - /** * Generate an HTML