-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CPPSDK: provider support added (#156)
- Loading branch information
1 parent
e679004
commit f31b5d7
Showing
48 changed files
with
418 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,5 @@ | |
#include <unordered_map> | ||
#include <vector> | ||
#include <optional> | ||
#include <memory> | ||
|
2 changes: 1 addition & 1 deletion
2
languages/cpp/templates/callback-context-instantiation/sub-property/property.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response.${Property.dependency}${Property};${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} | ||
${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response.${Property.dependency}${Property};${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
${if.namespace.notsame}${info.Title}::${end.if.namespace.notsame}${title} response = proxyResponse->Value(); | ||
${property} = proxyResponse->Value(); |
2 changes: 1 addition & 1 deletion
2
languages/cpp/templates/callback-result-instantiation/sub-property/array.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
static void ProviderInvokeSession(std::string& methodName, JsonObject& jsonParameters, Firebolt::Error *err = nullptr) | ||
{ | ||
Firebolt::Error status = Firebolt::Error::NotConnected; | ||
FireboltSDK::Transport<WPEFramework::Core::JSON::IElement>* transport = FireboltSDK::Accessor::Instance().GetTransport(); | ||
if (transport != nullptr) { | ||
|
||
JsonObject jsonResult; | ||
status = transport->Invoke(methodName, jsonParameters, jsonResult); | ||
if (status == Firebolt::Error::None) { | ||
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "%s is successfully invoked", methodName.c_str()); | ||
} | ||
|
||
} else { | ||
FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "Error in getting Transport err = %d", status); | ||
} | ||
if (err != nullptr) { | ||
*err = status; | ||
} | ||
} | ||
static void ProviderFocusSession(std::string methodName, std::string& correlationId, Firebolt::Error *err = nullptr) | ||
{ | ||
JsonObject jsonParameters; | ||
WPEFramework::Core::JSON::Variant CorrelationId(correlationId); | ||
jsonParameters.Set(_T("correlationId"), CorrelationId); | ||
|
||
ProviderInvokeSession(methodName, jsonParameters, err); | ||
} | ||
static void ProviderResultSession(std::string methodName, std::string& correlationId, ${provider.xresponse.name} result, Firebolt::Error *err = nullptr) | ||
{ | ||
JsonObject jsonParameters; | ||
WPEFramework::Core::JSON::Variant CorrelationId(correlationId); | ||
jsonParameters.Set(_T("correlationId"), CorrelationId); | ||
|
||
${provider.xresponse.serialization} | ||
ProviderInvokeSession(methodName, jsonParameters, err); | ||
} | ||
static void ProviderErrorSession(std::string methodName, std::string& correlationId, ${provider.xerror.name} result, Firebolt::Error *err = nullptr) | ||
{ | ||
JsonObject jsonParameters; | ||
WPEFramework::Core::JSON::Variant CorrelationId(correlationId); | ||
jsonParameters.Set(_T("correlationId"), CorrelationId); | ||
|
||
${provider.xerror.serialization} | ||
ProviderInvokeSession(methodName, jsonParameters, err); | ||
} | ||
|
||
${methods} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
struct I${info.Title}Session : virtual public IFocussableProviderSession { | ||
virtual ~I${info.Title}Session() override = default; | ||
|
||
virtual void error( ${provider.xerror.name} error, Firebolt::Error *err = nullptr ) = 0; | ||
virtual void result( ${provider.xresponse.name} result, Firebolt::Error *err = nullptr ) = 0; | ||
}; | ||
|
||
struct I${info.Title}Provider { | ||
virtual ~I${info.Title}Provider() = default; | ||
|
||
${methods} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
${subscribe} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
${interface} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
${interface} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
eventName = _T("${info.title.lowercase}.onRequest${method.Name}"); | ||
status = FireboltSDK::Event::Instance().Subscribe<${event.result.json.type}>(eventName, jsonParameters, ${info.Title}${method.Name}SessionInnerCallback, reinterpret_cast<void*>(&provider), nullptr); | ||
if (status != Firebolt::Error::None) { | ||
FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "Error in %s subscribe = %d", eventName.c_str(), status); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
void provide( I${info.Title}Provider& provider ) override; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
virtual void provide( I${info.Title}Provider& provider ) = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class ${info.Title}${method.Name}Session : virtual public IProviderSession { | ||
public: | ||
std::string correlationId () const override | ||
{ | ||
return _correlationId; | ||
} | ||
|
||
public: | ||
std::string _correlationId; | ||
}; | ||
static void ${info.Title}${method.Name}SessionInnerCallback( void* provider, const void* userData, void* jsonResponse ) | ||
{ | ||
//TODO: code to convert jsonResponse to ${method.name} session | ||
I${info.Title}Provider& ${info.title.lowercase}Provider = *(reinterpret_cast<I${info.Title}Provider*>(provider)); | ||
${info.title.lowercase}Provider.${method.name}( parameters, session ); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
virtual void ${method.name}( ${method.signature.params}, IProviderSession& session ) = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class ${info.Title}${method.Name}Session : virtual public I${info.Title}Session { | ||
public: | ||
${info.Title}${method.Name}Session( const std::string& correlationId ) | ||
: _correlationId(correlationId) | ||
{ | ||
} | ||
|
||
std::string correlationId() const override | ||
{ | ||
return _correlationId; | ||
} | ||
void focus( Firebolt::Error *err = nullptr ) override | ||
{ | ||
ProviderFocusSession("${info.title.lowercase}.${method.name}Focus", _correlationId, err); | ||
} | ||
void result( ${provider.xresponse.name} response, Firebolt::Error *err = nullptr ) override | ||
{ | ||
ProviderResultSession("${info.title.lowercase}.${method.name}Response", _correlationId, response, err); | ||
} | ||
void error( ${provider.xerror.name} error, Firebolt::Error *err = nullptr ) override | ||
{ | ||
ProviderErrorSession("${info.title.lowercase}.${method.name}Error", _correlationId, error, err); | ||
} | ||
|
||
public: | ||
std::string _correlationId; | ||
}; | ||
static void ${info.Title}${method.Name}SessionInnerCallback( void* provider, const void* userData, void* jsonResponse ) | ||
{ | ||
${event.callback.serialization} | ||
ASSERT(proxyResponse.IsValid() == true); | ||
|
||
if (proxyResponse.IsValid() == true) { | ||
${event.callback.initialization} | ||
|
||
${event.callback.instantiation} | ||
proxyResponse.Release(); | ||
|
||
std::unique_ptr<I${info.Title}Session> ${info.title.lowercase}${method.Name}Session = std::make_unique<${info.Title}${method.Name}Session>(${method.result.name}.correlationId); | ||
I${info.Title}Provider& ${info.title.lowercase}Provider = *(reinterpret_cast<I${info.Title}Provider*>(provider)); | ||
${info.title.lowercase}Provider.${method.name}(${method.result.name}.parameters, std::move(${info.title.lowercase}${method.Name}Session)); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
virtual void ${method.name}( ${method.signature.params}, std::unique_ptr<I${info.Title}Session> session ) = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
WPEFramework::Core::JSON::DecSInt32 | ||
WPEFramework::Core::JSON::DecSInt32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
void ${info.Title}Impl::provide( I${info.Title}Provider& provider ) | ||
{ | ||
string eventName; | ||
Firebolt::Error status = Firebolt::Error::None; | ||
JsonObject jsonParameters; | ||
|
||
/* ${PROVIDERS_SUBSCRIBE} */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
languages/cpp/templates/parameter-serialization/additionalProperties.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}${title} map = ${property}${if.impl.optional}.value()${end.if.impl.optional}; | ||
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}${title} map; | ||
${if.impl.optional}if (${property}.has_value()) { | ||
map = ${property}.value(); | ||
}${end.if.impl.optional}${if.impl.non.optional}map = ${property};${end.if.impl.non.optional} | ||
WPEFramework::Core::JSON::Variant ${property}Variant; | ||
for (auto element: map) { | ||
WPEFramework::Core::JSON::Variant jsonElement = element.second; | ||
WPEFramework::Core::JSON::VariantContainer jsonContainer; | ||
jsonContainer.Set(element.first.c_str(), jsonElement); | ||
${property}Variant = jsonContainer; | ||
} | ||
jsonParameters.Set(_T("${property}"), ${property}Variant); | ||
jsonParameters.Set(_T("${property}"), ${property}Variant); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.object}${items.with.indent}${end.if.object}${if.non.object} ${property}Array.Add() = element;${end.if.non.object} | ||
} | ||
${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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} jsonValue = ${property}${if.optional}.value()${end.if.optional}; | ||
${if.optional}if (${property}.has_value()) { | ||
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} jsonValue = ${property}.value(); | ||
WPEFramework::Core::JSON::Variant ${property}Variant(jsonValue.Data()); | ||
jsonParameters.Set(_T("${property}"), ${property}Variant); | ||
}${end.if.optional}${if.non.optional}${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} jsonValue = ${property}; | ||
WPEFramework::Core::JSON::Variant ${property}Variant(jsonValue.Data()); | ||
jsonParameters.Set(_T("${property}"), ${property}Variant); | ||
jsonParameters.Set(_T("${property}"), ${property}Variant);${end.if.non.optional} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
WPEFramework::Core::JSON::Variant ${property}Variant(${property}${if.optional}.value()${end.if.optional}); | ||
jsonParameters.Set(_T("${property}"), ${property}Variant); | ||
${if.optional}if (${property}.has_value()) { | ||
WPEFramework::Core::JSON::Variant ${property}Variant(${property}.value()); | ||
jsonParameters.Set(_T("${property}"), ${property}Variant); | ||
}${end.if.optional}${if.non.optional}WPEFramework::Core::JSON::Variant ${property}Variant(${property}); | ||
jsonParameters.Set(_T("${property}"), ${property}Variant);${end.if.non.optional} |
4 changes: 3 additions & 1 deletion
4
languages/cpp/templates/parameter-serialization/object-array.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} ${property}Container; | ||
{ | ||
${properties} | ||
} | ||
string ${property}Str; | ||
${property}Container.ToString(${property}Str); | ||
WPEFramework::Core::JSON::VariantContainer ${property}VariantContainer(${property}Str); | ||
WPEFramework::Core::JSON::Variant ${property}Variant = ${property}VariantContainer; | ||
${property}Array.Add() = ${property}Variant; | ||
${property}Array.Add() = ${property}Variant; |
7 changes: 5 additions & 2 deletions
7
languages/cpp/templates/parameter-serialization/object-empty-property.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
WPEFramework::Core::JSON::Variant ${property}Variant(${property}${if.optional}.value()${end.if.optional}); | ||
jsonParameters.Set(_T("${property}"), ${property}Variant); | ||
${if.optional}if (${property}.has_value()) { | ||
WPEFramework::Core::JSON::Variant ${property}Variant(${property}.value()); | ||
jsonParameters.Set(_T("${property}"), ${property}Variant); | ||
}${end.if.optional}${if.non.optional}WPEFramework::Core::JSON::Variant ${property}Variant(${property}); | ||
jsonParameters.Set(_T("${property}"), ${property}Variant);${end.if.non.optional} |
15 changes: 13 additions & 2 deletions
15
languages/cpp/templates/parameter-serialization/object.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
auto element = ${property}${if.impl.optional}.value()${end.if.impl.optional}; | ||
${if.impl.optional}if (${property}.has_value()) { | ||
auto element = ${property}.value(); | ||
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} ${property}Container; | ||
${properties} | ||
string ${property}Str; | ||
${property}Container.ToString(${property}Str); | ||
WPEFramework::Core::JSON::VariantContainer ${property}VariantContainer(${property}Str); | ||
WPEFramework::Core::JSON::Variant ${property}Variant = ${property}VariantContainer; | ||
jsonParameters.Set(_T("${property}"), ${property}Variant); | ||
}${end.if.impl.optional}${if.impl.non.optional}auto element = ${property}; | ||
${if.namespace.notsame}Firebolt::${info.Title}::${end.if.namespace.notsame}JsonData_${title} ${property}Container; | ||
{ | ||
${properties} | ||
} | ||
string ${property}Str; | ||
${property}Container.ToString(${property}Str); | ||
WPEFramework::Core::JSON::VariantContainer ${property}VariantContainer(${property}Str); | ||
WPEFramework::Core::JSON::Variant ${property}Variant = ${property}VariantContainer; | ||
jsonParameters.Set(_T("${property}"), ${property}Variant); | ||
jsonParameters.Set(_T("${property}"), ${property}Variant);${end.if.impl.non.optional} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${base.title}Container.${Property} = element.${property}${if.optional}.value()${end.if.optional};${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} | ||
${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${if.optional}if (element.${property}.has_value()) { | ||
${base.title}Container.${Property} = element.${property}.value(); | ||
}${end.if.optional}${if.non.optional}${base.title}Container.${Property} = element.${property};${end.if.non.optional}${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} |
4 changes: 3 additions & 1 deletion
4
languages/cpp/templates/parameter-serialization/sub-property/anyOfSchemaShape.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
${base.title}Container.${Property.dependency}${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}${if.optional}.value()${end.if.optional}; | ||
${if.optional}if (element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.has_value()) { | ||
${base.title}Container.${Property.dependency}${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.value(); | ||
}${end.if.optional}${if.non.optional}${base.title}Container.${Property.dependency}${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property};${end.if.non.optional} |
19 changes: 13 additions & 6 deletions
19
languages/cpp/templates/parameter-serialization/sub-property/array.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
WPEFramework::Core::JSON::ArrayType<${json.type}> ${property}Array; | ||
${type} ${property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}${if.impl.array.optional}.value()${end.if.impl.array.optional}; | ||
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); | ||
${if.impl.array.optional}if (element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.has_value()) { | ||
WPEFramework::Core::JSON::ArrayType<${json.type}> ${property}Array; | ||
${type} ${property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.value(); | ||
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.optional}${if.impl.array.non.optional}WPEFramework::Core::JSON::ArrayType<${json.type}> ${property}Array; | ||
${type} ${property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}; | ||
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} |
Oops, something went wrong.