|
|
@ -13,21 +13,11 @@ |
|
|
|
#include "AutoConnectElementJson.h" |
|
|
|
#include "AutoConnectElementJson.h" |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Set items common to any type of AutoConnectElement from JSON objects. |
|
|
|
* Returns JSON object size. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @return An object size for JsonBuffer. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void AutoConnectElementJson::_setElement(const JsonObject& json) { |
|
|
|
const size_t AutoConnectElementJson::getObjectSize() const { |
|
|
|
name = json.get<String>(F(AUTOCONNECT_JSON_KEY_NAME)); |
|
|
|
return JSON_OBJECT_SIZE(3); |
|
|
|
value = json.get<String>(F(AUTOCONNECT_JSON_KEY_VALUE)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Serialize AutoConnectElement to JSON. |
|
|
|
|
|
|
|
* This function is base for each element. |
|
|
|
|
|
|
|
* @param json JSON object to be serialized. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void AutoConnectElementJson::_serialize(JsonObject& json) { |
|
|
|
|
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_NAME), name); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -36,10 +26,10 @@ void AutoConnectElementJson::_serialize(JsonObject& json) { |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
bool AutoConnectElementJson::loadElement(const JsonObject& json) { |
|
|
|
bool AutoConnectElementJson::loadMember(const JsonObject& json) { |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACELEMENT))) { |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACELEMENT))) { |
|
|
|
_setElement(json); |
|
|
|
_setMember(json); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -50,20 +40,47 @@ bool AutoConnectElementJson::loadElement(const JsonObject& json) { |
|
|
|
* @param json JSON object to be serialized. |
|
|
|
* @param json JSON object to be serialized. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void AutoConnectElementJson::serialize(JsonObject& json) { |
|
|
|
void AutoConnectElementJson::serialize(JsonObject& json) { |
|
|
|
|
|
|
|
_serialize(json); |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_TYPE), F(AUTOCONNECT_JSON_TYPE_ACELEMENT)); |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_TYPE), F(AUTOCONNECT_JSON_TYPE_ACELEMENT)); |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_VALUE), value); |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_VALUE), value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Serialize AutoConnectElement to JSON. |
|
|
|
|
|
|
|
* This function is base for each element. |
|
|
|
|
|
|
|
* @param json JSON object to be serialized. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void AutoConnectElementJson::_serialize(JsonObject& json) { |
|
|
|
|
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_NAME), name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Set items common to any type of AutoConnectElement from JSON objects. |
|
|
|
|
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void AutoConnectElementJson::_setMember(const JsonObject& json) { |
|
|
|
|
|
|
|
name = json.get<String>(F(AUTOCONNECT_JSON_KEY_NAME)); |
|
|
|
|
|
|
|
value = json.get<String>(F(AUTOCONNECT_JSON_KEY_VALUE)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns JSON object size. |
|
|
|
|
|
|
|
* @return An object size for JsonBuffer. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
const size_t AutoConnectButtonJson::getObjectSize() const { |
|
|
|
|
|
|
|
return AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Load a button element attribute member from the JSON object. |
|
|
|
* Load a button element attribute member from the JSON object. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
bool AutoConnectButtonJson::loadElement(const JsonObject& json) { |
|
|
|
bool AutoConnectButtonJson::loadMember(const JsonObject& json) { |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACBUTTON))) { |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACBUTTON))) { |
|
|
|
_setElement(json); |
|
|
|
_setMember(json); |
|
|
|
action = json.get<String>(F(AUTOCONNECT_JSON_KEY_ACTION)); |
|
|
|
action = json.get<String>(F(AUTOCONNECT_JSON_KEY_ACTION)); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -81,16 +98,24 @@ void AutoConnectButtonJson::serialize(JsonObject& json) { |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_ACTION), action); |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_ACTION), action); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns JSON object size. |
|
|
|
|
|
|
|
* @return An object size for JsonBuffer. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
const size_t AutoConnectCheckboxJson::getObjectSize() const { |
|
|
|
|
|
|
|
return AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Load a checkbox element attribute member from the JSON object. |
|
|
|
* Load a checkbox element attribute member from the JSON object. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
bool AutoConnectCheckboxJson::loadElement(const JsonObject& json) { |
|
|
|
bool AutoConnectCheckboxJson::loadMember(const JsonObject& json) { |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACCHECKBOX))) { |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACCHECKBOX))) { |
|
|
|
_setElement(json); |
|
|
|
_setMember(json); |
|
|
|
label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL)); |
|
|
|
label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL)); |
|
|
|
checked = json.get<bool>(F(AUTOCONNECT_JSON_KEY_CHECKED)); |
|
|
|
checked = json.get<bool>(F(AUTOCONNECT_JSON_KEY_CHECKED)); |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -111,16 +136,24 @@ void AutoConnectCheckboxJson::serialize(JsonObject& json) { |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_CHECKED), checked); |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_CHECKED), checked); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns JSON object size. |
|
|
|
|
|
|
|
* @return An object size for JsonBuffer. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
const size_t AutoConnectInputJson::getObjectSize() const { |
|
|
|
|
|
|
|
return AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Load a input-box element attribute member from the JSON object. |
|
|
|
* Load a input-box element attribute member from the JSON object. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
bool AutoConnectInputJson::loadElement(const JsonObject& json) { |
|
|
|
bool AutoConnectInputJson::loadMember(const JsonObject& json) { |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACINPUT))) { |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACINPUT))) { |
|
|
|
_setElement(json); |
|
|
|
_setMember(json); |
|
|
|
placeholder = json.get<String>(F(AUTOCONNECT_JSON_KEY_PLACEHOLDER)); |
|
|
|
placeholder = json.get<String>(F(AUTOCONNECT_JSON_KEY_PLACEHOLDER)); |
|
|
|
label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL)); |
|
|
|
label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL)); |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -140,16 +173,24 @@ void AutoConnectInputJson::serialize(JsonObject& json) { |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_LABEL), label); |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_LABEL), label); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns JSON object size. |
|
|
|
|
|
|
|
* @return An object size for JsonBuffer. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
const size_t AutoConnectRadioJson::getObjectSize() const { |
|
|
|
|
|
|
|
return AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(3) + _values.size() * JSON_OBJECT_SIZE(1) + JSON_ARRAY_SIZE(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Load a radio-button element attribute member from the JSON object. |
|
|
|
* Load a radio-button element attribute member from the JSON object. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
bool AutoConnectRadioJson::loadElement(const JsonObject& json) { |
|
|
|
bool AutoConnectRadioJson::loadMember(const JsonObject& json) { |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACRADIO))) { |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACRADIO))) { |
|
|
|
_setElement(json); |
|
|
|
_setMember(json); |
|
|
|
label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL)); |
|
|
|
label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL)); |
|
|
|
checked = static_cast<uint8_t>(json.get<int>(F(AUTOCONNECT_JSON_KEY_CHECKED))); |
|
|
|
checked = static_cast<uint8_t>(json.get<int>(F(AUTOCONNECT_JSON_KEY_CHECKED))); |
|
|
|
String arrange = json.get<String>(F(AUTOCONNECT_JSON_KEY_ARRANGE)); |
|
|
|
String arrange = json.get<String>(F(AUTOCONNECT_JSON_KEY_ARRANGE)); |
|
|
@ -188,16 +229,24 @@ void AutoConnectRadioJson::serialize(JsonObject& json) { |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_CHECKED), checked); |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_CHECKED), checked); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns JSON object size. |
|
|
|
|
|
|
|
* @return An object size for JsonBuffer. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
const size_t AutoConnectSelectJson::getObjectSize() const { |
|
|
|
|
|
|
|
return AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(3) + _options.size() * JSON_OBJECT_SIZE(1) + JSON_ARRAY_SIZE(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Load a select element attribute member from the JSON object. |
|
|
|
* Load a select element attribute member from the JSON object. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
bool AutoConnectSelectJson::loadElement(const JsonObject& json) { |
|
|
|
bool AutoConnectSelectJson::loadMember(const JsonObject& json) { |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACSELECT))) { |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACSELECT))) { |
|
|
|
_setElement(json); |
|
|
|
_setMember(json); |
|
|
|
label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL)); |
|
|
|
label = json.get<String>(F(AUTOCONNECT_JSON_KEY_LABEL)); |
|
|
|
empty(); |
|
|
|
empty(); |
|
|
|
JsonArray& optionArray = json[AUTOCONNECT_JSON_KEY_OPTION]; |
|
|
|
JsonArray& optionArray = json[AUTOCONNECT_JSON_KEY_OPTION]; |
|
|
@ -221,16 +270,24 @@ void AutoConnectSelectJson::serialize(JsonObject& json) { |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_LABEL), label); |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_LABEL), label); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns JSON object size. |
|
|
|
|
|
|
|
* @return An object size for JsonBuffer. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
const size_t AutoConnectSubmitJson::getObjectSize() const { |
|
|
|
|
|
|
|
return AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Load a submit element attribute member from the JSON object. |
|
|
|
* Load a submit element attribute member from the JSON object. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
bool AutoConnectSubmitJson::loadElement(const JsonObject& json) { |
|
|
|
bool AutoConnectSubmitJson::loadMember(const JsonObject& json) { |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACSUBMIT))) { |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACSUBMIT))) { |
|
|
|
_setElement(json); |
|
|
|
_setMember(json); |
|
|
|
uri = json.get<String>(F(AUTOCONNECT_JSON_KEY_URI)); |
|
|
|
uri = json.get<String>(F(AUTOCONNECT_JSON_KEY_URI)); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -248,16 +305,24 @@ void AutoConnectSubmitJson::serialize(JsonObject& json) { |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_URI), uri); |
|
|
|
json.set(F(AUTOCONNECT_JSON_KEY_URI), uri); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns JSON object size. |
|
|
|
|
|
|
|
* @return An object size for JsonBuffer. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
const size_t AutoConnectTextJson::getObjectSize() const { |
|
|
|
|
|
|
|
return AutoConnectElementJson::getObjectSize() + JSON_OBJECT_SIZE(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Load a text element attribute member from the JSON object. |
|
|
|
* Load a text element attribute member from the JSON object. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @param json JSON object with the definition of AutoConnectElement. |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return true AutoConnectElement loaded |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
* @return false Type of AutoConnectElement is mismatched. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
bool AutoConnectTextJson::loadElement(const JsonObject& json) { |
|
|
|
bool AutoConnectTextJson::loadMember(const JsonObject& json) { |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
String type = json.get<String>(F(AUTOCONNECT_JSON_KEY_TYPE)); |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACTEXT))) { |
|
|
|
if (type.equalsIgnoreCase(F(AUTOCONNECT_JSON_TYPE_ACTEXT))) { |
|
|
|
_setElement(json); |
|
|
|
_setMember(json); |
|
|
|
style = json.get<String>(F(AUTOCONNECT_JSON_KEY_STYLE)); |
|
|
|
style = json.get<String>(F(AUTOCONNECT_JSON_KEY_STYLE)); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|