blob: 268b09451c6036e1138acc88f4408aca48546f56 [file] [log] [blame]
CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request, Json::Value & value)
{
VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT);
// Copy to track which members we already processed.
Json::Value valueCopy(value);
{{#zcl_struct_items}}
{{#unless isOptional}}
{{~! Fabric index fields are not sent on writes, so don't force people to
provide them. ~}}
{{#unless (is_num_equal fieldIdentifier 254)}}
ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("{{parent.name}}.{{asLowerCamelCase label}}", "{{asLowerCamelCase label}}", value.isMember("{{asLowerCamelCase label}}")));
{{/unless}}
{{/unless}}
{{/zcl_struct_items}}
char labelWithMember[kMaxLabelLength];
{{#zcl_struct_items}}
{{#if isOptional}}
if (value.isMember("{{asLowerCamelCase label}}"))
{
{{else if (is_num_equal fieldIdentifier 254)}}
if (value.isMember("{{asLowerCamelCase label}}"))
{
{{/if}}
snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "{{asLowerCamelCase label}}");
ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.{{asLowerCamelCase label}}, value["{{asLowerCamelCase label}}"]));
{{#if isOptional}}
}
{{else if (is_num_equal fieldIdentifier 254)}}
}
{{/if}}
valueCopy.removeMember("{{asLowerCamelCase label}}");
{{/zcl_struct_items}}
return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy);
}
void ComplexArgumentParser::Finalize(chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request)
{
{{#zcl_struct_items}}
ComplexArgumentParser::Finalize(request.{{asLowerCamelCase label}});
{{/zcl_struct_items}}
}