| {{#if isOptional}} |
| if ({{source}}.HasValue()) { |
| {{>decode_value target=target source=(concat source ".Value()") cluster=cluster errorCode=errorCode depth=(incrementDepth depth) isOptional=false}} |
| } else { |
| {{target}} = nil; |
| } |
| {{else if isNullable}} |
| if ({{source}}.IsNull()) { |
| {{target}} = nil; |
| } else { |
| {{>decode_value target=target source=(concat source ".Value()") cluster=cluster errorCode=errorCode depth=(incrementDepth depth) isNullable=false}} |
| } |
| {{else if isArray}} |
| { // Scope for our temporary variables |
| auto * array_{{depth}} = [NSMutableArray new]; |
| auto iter_{{depth}} = {{source}}.begin(); |
| while (iter_{{depth}}.Next()) { |
| auto & entry_{{depth}} = iter_{{depth}}.GetValue(); |
| {{asObjectiveCClass type cluster forceNotList=true}} * newElement_{{depth}}; |
| {{>decode_value target=(concat "newElement_" depth) source=(concat "entry_" depth) cluster=cluster errorCode=errorCode depth=(incrementDepth depth) isArray=false}} |
| [array_{{depth}} addObject:newElement_{{depth}}]; |
| } |
| CHIP_ERROR err = iter_{{depth}}.GetStatus(); |
| if (err != CHIP_NO_ERROR) { |
| {{errorCode}} |
| } |
| {{target}} = array_{{depth}}; |
| } |
| {{else}} |
| {{#if_is_struct type}} |
| {{target}} = [{{asObjectiveCClass type cluster forceNotList=true}} new]; |
| {{#zcl_struct_items_by_struct_name type}} |
| {{>decode_value target=(concat ../target "." (asStructPropertyName label)) source=(concat ../source "." (asLowerCamelCase label)) cluster=../cluster errorCode=../errorCode depth=(incrementDepth ../depth) }} |
| {{/zcl_struct_items_by_struct_name}} |
| {{else}} |
| {{#if_is_strongly_typed_chip_enum type}} |
| {{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:chip::to_underlying({{source}})]; |
| {{else}} |
| {{#if_is_strongly_typed_bitmap type}} |
| {{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:{{source}}.Raw()]; |
| {{else if (isOctetString type)}} |
| {{target}} = [NSData dataWithBytes:{{source}}.data() length:{{source}}.size()]; |
| {{else if (isCharString type)}} |
| {{target}} = [[NSString alloc] initWithBytes:{{source}}.data() length:{{source}}.size() encoding:NSUTF8StringEncoding]; |
| {{else}} |
| {{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:{{source}}]; |
| {{/if_is_strongly_typed_bitmap}} |
| {{/if_is_strongly_typed_chip_enum}} |
| {{/if_is_struct}} |
| {{/if}} |