Skip to content

Commit

Permalink
TagBoundEncoder -> ListEncodeHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing committed Nov 22, 2021
1 parent 86d3966 commit cee770f
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CHIP_ERROR ApplicationLauncherManager::Init()

CHIP_ERROR ApplicationLauncherManager::proxyGetApplicationList(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
ReturnErrorOnFailure(encoder.Encode(123u));
ReturnErrorOnFailure(encoder.Encode(456u));
return CHIP_NO_ERROR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CHIP_ERROR AudioOutputManager::Init()

CHIP_ERROR AudioOutputManager::proxyGetListOfAudioOutputInfo(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
// TODO: Insert code here
int maximumVectorSize = 3;
char name[] = "exampleName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ CHIP_ERROR ContentLauncherManager::Init()

CHIP_ERROR ContentLauncherManager::proxyGetAcceptsHeader(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
// TODO: Insert code here
char headerExample[] = "exampleHeader";
int maximumVectorSize = 1;
Expand All @@ -68,7 +68,7 @@ CHIP_ERROR ContentLauncherManager::proxyGetAcceptsHeader(chip::app::AttributeVal

CHIP_ERROR ContentLauncherManager::proxyGetSupportedStreamingTypes(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
// TODO: Insert code here
ReturnErrorOnFailure(encoder.Encode(EMBER_ZCL_CONTENT_LAUNCH_STREAMING_TYPE_DASH));
ReturnErrorOnFailure(encoder.Encode(EMBER_ZCL_CONTENT_LAUNCH_STREAMING_TYPE_HLS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CHIP_ERROR MediaInputManager::Init()

CHIP_ERROR MediaInputManager::proxyGetInputList(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
// TODO: Insert code here
int maximumVectorSize = 2;
char description[] = "exampleDescription";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ CHIP_ERROR TargetNavigatorManager::Init()

CHIP_ERROR TargetNavigatorManager::proxyGetTargetInfoList(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
// TODO: Insert code here
int maximumVectorSize = 2;
char name[] = "exampleName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ CHIP_ERROR TvChannelManager::Init()

CHIP_ERROR TvChannelManager::proxyGetTvChannelList(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
// TODO: Insert code here
int maximumVectorSize = 2;
char affiliateCallSign[] = "exampleASign";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CHIP_ERROR ApplicationLauncherManager::Init()

CHIP_ERROR ApplicationLauncherManager::proxyGetApplicationList(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
ReturnErrorOnFailure(encoder.Encode(123u));
ReturnErrorOnFailure(encoder.Encode(456u));
return CHIP_NO_ERROR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CHIP_ERROR AudioOutputManager::Init()

CHIP_ERROR AudioOutputManager::proxyGetListOfAudioOutputInfo(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
// TODO: Insert code here
int maximumVectorSize = 3;
char name[] = "exampleName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ CHIP_ERROR ContentLauncherManager::Init()

CHIP_ERROR ContentLauncherManager::proxyGetAcceptsHeader(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
// TODO: Insert code here
char headerExample[] = "exampleHeader";
int maximumVectorSize = 1;
Expand All @@ -68,7 +68,7 @@ CHIP_ERROR ContentLauncherManager::proxyGetAcceptsHeader(chip::app::AttributeVal

CHIP_ERROR ContentLauncherManager::proxyGetSupportedStreamingTypes(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
// TODO: Insert code here
ReturnErrorOnFailure(encoder.Encode(EMBER_ZCL_CONTENT_LAUNCH_STREAMING_TYPE_DASH));
ReturnErrorOnFailure(encoder.Encode(EMBER_ZCL_CONTENT_LAUNCH_STREAMING_TYPE_HLS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CHIP_ERROR MediaInputManager::Init()

CHIP_ERROR MediaInputManager::proxyGetInputList(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
// TODO: Insert code here
int maximumVectorSize = 2;
char description[] = "exampleDescription";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ CHIP_ERROR TargetNavigatorManager::Init()

CHIP_ERROR TargetNavigatorManager::proxyGetTargetInfoList(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
// TODO: Insert code here
int maximumVectorSize = 2;
char name[] = "exampleName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ CHIP_ERROR TvChannelManager::Init()

CHIP_ERROR TvChannelManager::proxyGetTvChannelList(chip::app::AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const chip::app::TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const chip::app::AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
// TODO: Insert code here
int maximumVectorSize = 2;
char affiliateCallSign[] = "exampleASign";
Expand Down
23 changes: 12 additions & 11 deletions src/app/clusters/descriptor/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ CHIP_ERROR DescriptorAttrAccess::ReadPartsAttribute(EndpointId endpoint, Attribu

if (endpoint == 0x00)
{
err = aEncoder.EncodeList([](const TagBoundEncoder & encoder) -> CHIP_ERROR {
err = aEncoder.EncodeList([](const AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
for (uint16_t index = 0; index < emberAfEndpointCount(); index++)
{
if (emberAfEndpointIndexIsEnabled(index))
Expand All @@ -85,7 +85,7 @@ CHIP_ERROR DescriptorAttrAccess::ReadPartsAttribute(EndpointId endpoint, Attribu

CHIP_ERROR DescriptorAttrAccess::ReadDeviceAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder)
{
CHIP_ERROR err = aEncoder.EncodeList([&endpoint](const TagBoundEncoder & encoder) -> CHIP_ERROR {
CHIP_ERROR err = aEncoder.EncodeList([&endpoint](const AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
Descriptor::Structs::DeviceType::Type deviceStruct;
uint16_t index = emberAfIndexFromEndpoint(endpoint);

Expand All @@ -99,17 +99,18 @@ CHIP_ERROR DescriptorAttrAccess::ReadDeviceAttribute(EndpointId endpoint, Attrib

CHIP_ERROR DescriptorAttrAccess::ReadClientServerAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder, bool server)
{
CHIP_ERROR err = aEncoder.EncodeList([&endpoint, server](const TagBoundEncoder & encoder) -> CHIP_ERROR {
uint16_t clusterCount = emberAfClusterCount(endpoint, server);
CHIP_ERROR err =
aEncoder.EncodeList([&endpoint, server](const AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
uint16_t clusterCount = emberAfClusterCount(endpoint, server);

for (uint8_t clusterIndex = 0; clusterIndex < clusterCount; clusterIndex++)
{
EmberAfCluster * cluster = emberAfGetNthCluster(endpoint, clusterIndex, server);
ReturnErrorOnFailure(encoder.Encode(cluster->clusterId));
}
for (uint8_t clusterIndex = 0; clusterIndex < clusterCount; clusterIndex++)
{
EmberAfCluster * cluster = emberAfGetNthCluster(endpoint, clusterIndex, server);
ReturnErrorOnFailure(encoder.Encode(cluster->clusterId));
}

return CHIP_NO_ERROR;
});
return CHIP_NO_ERROR;
});

return err;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ CHIP_ERROR GeneralDiagosticsAttrAccess::ReadNetworkInterfaces(AttributeValueEnco

if (ConnectivityMgr().GetNetworkInterfaces(&netifs) == CHIP_NO_ERROR)
{
err = aEncoder.EncodeList([&netifs](const TagBoundEncoder & encoder) -> CHIP_ERROR {
err = aEncoder.EncodeList([&netifs](const AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
for (DeviceLayer::NetworkInterface * ifp = netifs; ifp != nullptr; ifp = ifp->Next)
{
ReturnErrorOnFailure(encoder.Encode(*ifp));
Expand Down
2 changes: 1 addition & 1 deletion src/app/clusters/mode-select-server/mode-select-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ CHIP_ERROR ModeSelectAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
return CHIP_NO_ERROR;
}
CHIP_ERROR err;
err = aEncoder.EncodeList([modeOptionsProvider](const TagBoundEncoder & encoder) -> CHIP_ERROR {
err = aEncoder.EncodeList([modeOptionsProvider](const AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
const auto * end = modeOptionsProvider.end();
for (auto * it = modeOptionsProvider.begin(); it != end; ++it)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ CHIP_ERROR OperationalCredentialsAttrAccess::ReadCommissionedFabrics(EndpointId

CHIP_ERROR OperationalCredentialsAttrAccess::ReadFabricsList(EndpointId endpoint, AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
for (auto & fabricInfo : Server::GetInstance().GetFabricTable())
{
if (!fabricInfo.IsInitialized())
Expand All @@ -114,7 +114,7 @@ CHIP_ERROR OperationalCredentialsAttrAccess::ReadFabricsList(EndpointId endpoint

CHIP_ERROR OperationalCredentialsAttrAccess::ReadRootCertificates(EndpointId endpoint, AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
for (auto & fabricInfo : Server::GetInstance().GetFabricTable())
{
ByteSpan cert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ CHIP_ERROR SoftwareDiagosticsAttrAccess::ReadThreadMetrics(AttributeValueEncoder

if (DeviceLayer::PlatformMgr().GetThreadMetrics(&threadMetrics) == CHIP_NO_ERROR)
{
err = aEncoder.EncodeList([&threadMetrics](const TagBoundEncoder & encoder) -> CHIP_ERROR {
err = aEncoder.EncodeList([&threadMetrics](const AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
for (DeviceLayer::ThreadMetrics * thread = threadMetrics; thread != nullptr; thread = thread->Next)
{
ReturnErrorOnFailure(encoder.Encode(*thread));
Expand Down
8 changes: 4 additions & 4 deletions src/app/clusters/test-cluster-server/test-cluster-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ CHIP_ERROR TestAttrAccess::Write(const ConcreteDataAttributePath & aPath, Attrib

CHIP_ERROR TestAttrAccess::ReadListInt8uAttribute(AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
for (uint8_t index = 0; index < kAttributeListLength; index++)
{
ReturnErrorOnFailure(encoder.Encode(gListUint8Data[index]));
Expand Down Expand Up @@ -166,7 +166,7 @@ CHIP_ERROR TestAttrAccess::WriteListInt8uAttribute(AttributeValueDecoder & aDeco

CHIP_ERROR TestAttrAccess::ReadListOctetStringAttribute(AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
for (uint8_t index = 0; index < kAttributeListLength; index++)
{
ByteSpan span(gListOctetStringData[index].Data(), gListOctetStringData[index].Length());
Expand Down Expand Up @@ -200,7 +200,7 @@ CHIP_ERROR TestAttrAccess::WriteListOctetStringAttribute(AttributeValueDecoder &

CHIP_ERROR TestAttrAccess::ReadListStructOctetStringAttribute(AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
for (uint8_t index = 0; index < kAttributeListLength; index++)
{
Structs::TestListStructOctet::Type structOctet;
Expand Down Expand Up @@ -246,7 +246,7 @@ CHIP_ERROR TestAttrAccess::WriteListStructOctetStringAttribute(AttributeValueDec

CHIP_ERROR TestAttrAccess::ReadListNullablesAndOptionalsStructAttribute(AttributeValueEncoder & aEncoder)
{
return aEncoder.EncodeList([](const TagBoundEncoder & encoder) -> CHIP_ERROR {
return aEncoder.EncodeList([](const AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
// Just encode a single default-initialized
// entry for now.
Structs::NullablesAndOptionalsStruct::Type entry;
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestAttributeValueEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void TestEncodeListOfBools2(nlTestSuite * aSuite, void * aContext)
{
TestSetup test(aSuite);
bool list[] = { true, false };
CHIP_ERROR err = test.encoder.EncodeList([&list](const TagBoundEncoder & encoder) -> CHIP_ERROR {
CHIP_ERROR err = test.encoder.EncodeList([&list](const AttributeValueEncoder::ListEncodeHelper & encoder) -> CHIP_ERROR {
for (auto & item : list)
{
ReturnErrorOnFailure(encoder.Encode(item));
Expand Down

0 comments on commit cee770f

Please sign in to comment.