Supports ArduinoJson V6. Issue #47

pull/57/head
Hieromon Ikasamo 6 years ago
parent e790a0f4ac
commit 920be8bb7e
  1. 16
      src/AutoConnectAux.h
  2. 2
      src/AutoConnectAuxImpl.h
  3. 60
      src/AutoConnectElementBasisImpl.h

@ -60,17 +60,17 @@ class AutoConnectAux : public PageBuilder {
bool release(const String& name); /**< Release an AutoConnectElement */ 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, const String value); /**< Set value to specified element */
bool setElementValue(const String& name, std::vector<String> const& values); /**< Set values collection to specified element */ bool setElementValue(const String& name, std::vector<String> 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 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; } void onUpload(PageBuilder::UploadFuncT uploadFunc) override { _uploadHandler = uploadFunc; }
#ifdef AUTOCONNECT_USE_JSON #ifdef AUTOCONNECT_USE_JSON
bool load(const String& in); /**< Load whole elements to AutoConnectAux Page */ bool load(const String& in); /**< Load whole elements to AutoConnectAux Page */
bool load(const __FlashStringHelper* 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 load(Stream& in); /**< Load whole elements to AutoConnectAux Page */
bool loadElement(const String& in, const String& name = String("")); /**< Load specified element */ 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(const __FlashStringHelper* in, const String& name = String("")); /**< Load specified element */
bool loadElement(Stream& 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<String> const& names = {}); /**< Write elements of AutoConnectAux to the stream */ size_t saveElement(Stream& out, std::vector<String> const& names = {}); /**< Write elements of AutoConnectAux to the stream */
#endif // !AUTOCONNECT_USE_JSON #endif // !AUTOCONNECT_USE_JSON
@ -96,7 +96,7 @@ class AutoConnectAux : public PageBuilder {
bool _parseElement(T in, const String& name); bool _parseElement(T in, const String& name);
AutoConnectElement& _loadElement(JsonObject& in, const String& name); /**< Load an element as specified name from JSON object */ 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 */ 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 #endif // !AUTOCONNECT_USE_JSON
String _title; /**< A title of the page */ String _title; /**< A title of the page */

@ -256,7 +256,7 @@ bool AutoConnectAux::_parseElement(T in, const String& name) {
AC_DBG("Deserialize:%s\n", err.c_str()); AC_DBG("Deserialize:%s\n", err.c_str());
return false; return false;
} }
jb = jsonBuffer.as<JsonObject>(); jb = jsonBuffer.as<JsonVariant>();
#endif #endif
return _loadElement(jb, name); return _loadElement(jb, name);
} }

@ -19,66 +19,6 @@
#endif #endif
#include "AutoConnectElementBasis.h" #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<AutoConnectButtonBasis&>(*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<AutoConnectCheckboxBasis&>(*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<AutoConnectFileBasis&>(*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<AutoConnectInputBasis&>(*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<AutoConnectRadioBasis&>(*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<AutoConnectSelectBasis&>(*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<AutoConnectSubmitBasis&>(*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<AutoConnectTextBasis&>(*this);
// }
/** /**
* Generate an HTML <button> element. The onclick behavior depends on * Generate an HTML <button> element. The onclick behavior depends on
* the code held in factionf member. * the code held in factionf member.

Loading…
Cancel
Save