Skip to content

Commit

Permalink
CPPSDK: alignment issue fix + has_value check for parameter-serializa…
Browse files Browse the repository at this point in the history
…tion array
  • Loading branch information
HaseenaSainul committed Dec 11, 2023
1 parent 01ee147 commit be64365
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions languages/cpp/templates/parameter-serialization/array.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
WPEFramework::Core::JSON::ArrayType<WPEFramework::Core::JSON::Variant> ${property}Array;
for (auto& element : ${property}) {
${if.impl.array.optional}if (${property}.has_value()) {
for (auto& element : ${property}.value()) {
${if.object}${items.with.indent}${end.if.object}${if.non.object} ${property}Array.Add() = element;${end.if.non.object}
}
}${end.if.impl.array.optional}${if.impl.array.non.optional}for (auto& element : ${property}) {
${if.object}${items.with.indent}${end.if.object}${if.non.object} ${property}Array.Add() = element;${end.if.non.object}
}
}${end.if.impl.array.non.optional}
WPEFramework::Core::JSON::Variant ${property}Variant;
${property}Variant.Array(${property}Array);
jsonParameters.Set(_T("${property}"), ${property}Variant);
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
for (auto& element : ${property}) {
${if.object}${items.with.indent}${end.if.object}${if.non.object} ${property}Array.Add() = element;${end.if.non.object}
}
${base.title}Container.${Property.dependency}Add(_T("${property}"), &${property}Array);${end.if.impl.array.non.optional}
${base.title}Container.${Property.dependency}Add(_T("${property}"), &${property}Array);${end.if.impl.array.non.optional}
2 changes: 1 addition & 1 deletion languages/cpp/templates/types/object.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
struct ${title} {
${properties}
${properties}
};
2 changes: 1 addition & 1 deletion languages/cpp/templates/types/property.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
${if.optional}std::optional<${end.if.optional}${title}${if.optional}>${end.if.optional} ${property};
${if.optional}std::optional<${end.if.optional}${title}${if.optional}>${end.if.optional} ${property};

0 comments on commit be64365

Please sign in to comment.