From e9ac903a32b1c5f64ed7b5a002a0ce4faa39e881 Mon Sep 17 00:00:00 2001 From: Rohit Jadhav Date: Tue, 24 Sep 2024 16:01:19 +0530 Subject: [PATCH] Fix compilation --- .../account-login/AccountLoginManager.cpp | 12 ++--- .../AppContentLauncherManager.cpp | 4 +- .../AppMediaPlaybackManager.cpp | 8 +-- .../TargetNavigatorManager.cpp | 8 +-- src/setup_payload/tests/TestQRCode.cpp | 54 +++++++++---------- src/setup_payload/tests/TestQRCodeTLV.cpp | 24 ++++----- 6 files changed, 55 insertions(+), 55 deletions(-) diff --git a/examples/tv-app/android/include/account-login/AccountLoginManager.cpp b/examples/tv-app/android/include/account-login/AccountLoginManager.cpp index 48d443eb496ffb..73ebb9fc8e5723 100644 --- a/examples/tv-app/android/include/account-login/AccountLoginManager.cpp +++ b/examples/tv-app/android/include/account-login/AccountLoginManager.cpp @@ -30,10 +30,10 @@ using Status = chip::Protocols::InteractionModel::Status; namespace { const auto loginTempAccountIdentifierFieldId = - to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kTempAccountIdentifier)); -const auto loginSetupPINFieldId = to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kSetupPIN)); -const auto loginNodeFieldId = to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kNode)); -const auto logoutNodeFieldId = to_string(chip::to_underlying(AccountLogin::Commands::Logout::Fields::kNode)); + std::to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kTempAccountIdentifier)); +const auto loginSetupPINFieldId = std::to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kSetupPIN)); +const auto loginNodeFieldId = std::to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kNode)); +const auto logoutNodeFieldId = std::to_string(chip::to_underlying(AccountLogin::Commands::Logout::Fields::kNode)); string charSpanToString(const CharSpan & charSpan) { @@ -44,12 +44,12 @@ std::string serializeLoginCommand(AccountLogin::Commands::Login::Type cmd) { return R"({")" + loginTempAccountIdentifierFieldId + R"(":")" + charSpanToString(cmd.tempAccountIdentifier) + R"(",)" + R"(")" + loginSetupPINFieldId + R"(":")" + charSpanToString(cmd.setupPIN) + R"(",)" + R"(")" + loginNodeFieldId + R"(":")" + - to_string(cmd.node.Value()) + R"("})"; + std::to_string(cmd.node.Value()) + R"("})"; } std::string serializeLogoutCommand(AccountLogin::Commands::Logout::Type cmd) { - return R"({")" + logoutNodeFieldId + R"(":")" + to_string(cmd.node.Value()) + R"("})"; + return R"({")" + logoutNodeFieldId + R"(":")" + std::to_string(cmd.node.Value()) + R"("})"; } } // namespace diff --git a/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp b/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp index adc156eeb19b84..d4bb85088e6abd 100644 --- a/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp +++ b/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp @@ -99,7 +99,7 @@ CHIP_ERROR AppContentLauncherManager::HandleGetAcceptHeaderList(AttributeValueEn Json::Value value; if (reader.parse(resStr, value)) { - std::string attrId = to_string(chip::app::Clusters::ContentLauncher::Attributes::AcceptHeader::Id); + std::string attrId = std::to_string(chip::app::Clusters::ContentLauncher::Attributes::AcceptHeader::Id); ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetAcceptHeaderList response parsing done. reading attr %s", attrId.c_str()); if (value[attrId].isArray()) @@ -145,7 +145,7 @@ uint32_t AppContentLauncherManager::HandleGetSupportedStreamingProtocols() { return mSupportedStreamingProtocols; } - std::string attrId = to_string(chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::Id); + std::string attrId = std::to_string(chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::Id); ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetSupportedStreamingProtocols response parsing done. reading attr %s", attrId.c_str()); if (!value[attrId].empty() && value[attrId].isInt()) diff --git a/examples/tv-app/android/include/media-playback/AppMediaPlaybackManager.cpp b/examples/tv-app/android/include/media-playback/AppMediaPlaybackManager.cpp index 9e07e348e0fe3b..e58d6eebb52462 100644 --- a/examples/tv-app/android/include/media-playback/AppMediaPlaybackManager.cpp +++ b/examples/tv-app/android/include/media-playback/AppMediaPlaybackManager.cpp @@ -203,7 +203,7 @@ uint64_t AppMediaPlaybackManager::HandleMediaRequestGetAttribute(chip::Attribute Json::Value value; if (reader.parse(resStr, value)) { - std::string attrId = to_string(attributeId); + std::string attrId = std::to_string(attributeId); ChipLogProgress(Zcl, "AppMediaPlaybackManager::HandleMediaRequestGetAttribute response parsing done. reading attr %s", attrId.c_str()); if (!value[attrId].empty() && value[attrId].isUInt()) @@ -249,14 +249,14 @@ CHIP_ERROR AppMediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncod Json::Value value; if (reader.parse(resStr, value)) { - std::string attrId = to_string(chip::app::Clusters::MediaPlayback::Attributes::SampledPosition::Id); + std::string attrId = std::to_string(chip::app::Clusters::MediaPlayback::Attributes::SampledPosition::Id); ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetSampledPosition response parsing done. reading attr %s", attrId.c_str()); if (!value[attrId].empty() && value[attrId].isObject()) { - std::string updatedAt = to_string( + std::string updatedAt = std::to_string( static_cast(chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Fields::kUpdatedAt)); - std::string position = to_string( + std::string position = std::to_string( static_cast(chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Fields::kPosition)); if (!value[attrId][updatedAt].empty() && !value[attrId][position].empty() && value[attrId][updatedAt].isUInt() && value[attrId][position].isUInt()) diff --git a/examples/tv-app/android/include/target-navigator/TargetNavigatorManager.cpp b/examples/tv-app/android/include/target-navigator/TargetNavigatorManager.cpp index 31ae5daedb215d..3b84a050d3e51a 100644 --- a/examples/tv-app/android/include/target-navigator/TargetNavigatorManager.cpp +++ b/examples/tv-app/android/include/target-navigator/TargetNavigatorManager.cpp @@ -52,16 +52,16 @@ CHIP_ERROR TargetNavigatorManager::HandleGetTargetList(AttributeValueEncoder & a Json::Value value; if (reader.parse(resStr, value)) { - std::string attrId = to_string(chip::app::Clusters::TargetNavigator::Attributes::TargetList::Id); + std::string attrId = std::to_string(chip::app::Clusters::TargetNavigator::Attributes::TargetList::Id); ChipLogProgress(Zcl, "TargetNavigatorManager::HandleNavigateTarget response parsing done. reading attr %s", attrId.c_str()); if (value[attrId].isArray()) { return aEncoder.EncodeList([&](const auto & encoder) -> CHIP_ERROR { int i = 0; - std::string targetId = to_string(static_cast( + std::string targetId = std::to_string(static_cast( chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Fields::kIdentifier)); - std::string targetName = to_string( + std::string targetName = std::to_string( static_cast(chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Fields::kName)); for (Json::Value & entry : value[attrId]) { @@ -117,7 +117,7 @@ uint8_t TargetNavigatorManager::HandleGetCurrentTarget() Json::Value value; if (reader.parse(resStr, value)) { - std::string attrId = to_string(chip::app::Clusters::TargetNavigator::Attributes::CurrentTarget::Id); + std::string attrId = std::to_string(chip::app::Clusters::TargetNavigator::Attributes::CurrentTarget::Id); ChipLogProgress(Zcl, "TargetNavigatorManager::HandleGetCurrentTarget response parsing done. reading attr %s", attrId.c_str()); if (value[attrId].isUInt() && value[attrId].asUInt() < 256) diff --git a/src/setup_payload/tests/TestQRCode.cpp b/src/setup_payload/tests/TestQRCode.cpp index 25cb4cea8089f7..ce5048489113e6 100644 --- a/src/setup_payload/tests/TestQRCode.cpp +++ b/src/setup_payload/tests/TestQRCode.cpp @@ -120,7 +120,7 @@ TEST(TestQRCode, TestPayloadByteArrayRep) { SetupPayload payload = GetDefaultPayload(); - string expected = " 0000 000000000000000100000000000 000010000000 00000001 00 0000000000000001 0000000000001100 000"; + std::string expected = " 0000 000000000000000100000000000 000010000000 00000001 00 0000000000000001 0000000000001100 000"; EXPECT_TRUE(CompareBinary(payload, expected)); } @@ -129,7 +129,7 @@ TEST(TestQRCode, TestPayloadBase38Rep) SetupPayload payload = GetDefaultPayload(); QRCodeSetupPayloadGenerator generator(payload); - string result; + std::string result; CHIP_ERROR err = generator.payloadBase38Representation(result); bool didSucceed = err == CHIP_NO_ERROR; EXPECT_EQ(didSucceed, true); @@ -240,10 +240,10 @@ TEST(TestQRCode, TestBase38) base38Encode(ByteSpan((uint8_t *) "Hello World!", sizeof("Hello World!") - 1), encodedSpan); EXPECT_STREQ(encodedBuf, "KKHF3W2S013OPM3EJX11"); - vector decoded = vector(); + std::vector decoded = std::vector(); EXPECT_EQ(base38Decode("KKHF3W2S013OPM3EJX11", decoded), CHIP_NO_ERROR); - string hello_world; + std::string hello_world; for (uint8_t b : decoded) { hello_world += static_cast(b); @@ -346,8 +346,8 @@ TEST(TestQRCode, TestSetupPayloadVerify) TEST(TestQRCode, TestInvalidQRCodePayload_WrongCharacterSet) { - string invalidString = kDefaultPayloadQRCode; - invalidString.back() = ' '; // space is not contained in the base38 alphabet + std::string invalidString = kDefaultPayloadQRCode; + invalidString.back() = ' '; // space is not contained in the base38 alphabet QRCodeSetupPayloadParser parser = QRCodeSetupPayloadParser(invalidString); SetupPayload payload; @@ -359,7 +359,7 @@ TEST(TestQRCode, TestInvalidQRCodePayload_WrongCharacterSet) TEST(TestQRCode, TestInvalidQRCodePayload_WrongLength) { - string invalidString = kDefaultPayloadQRCode; + std::string invalidString = kDefaultPayloadQRCode; invalidString.pop_back(); QRCodeSetupPayloadParser parser = QRCodeSetupPayloadParser(invalidString); @@ -394,7 +394,7 @@ TEST(TestQRCode, TestQRCodeToPayloadGeneration) SetupPayload payload = GetDefaultPayload(); QRCodeSetupPayloadGenerator generator(payload); - string base38Rep; + std::string base38Rep; CHIP_ERROR err = generator.payloadBase38Representation(base38Rep); bool didSucceed = err == CHIP_NO_ERROR; EXPECT_EQ(didSucceed, true); @@ -421,7 +421,7 @@ TEST(TestQRCode, TestGenerateWithShortDiscriminatorInvalid) EXPECT_FALSE(payload.isValidQRCodePayload()); // QRCodeSetupPayloadGenerator should therefore return an error - string base38Rep; + std::string base38Rep; QRCodeSetupPayloadGenerator generator(payload); EXPECT_EQ(generator.payloadBase38Representation(base38Rep), CHIP_ERROR_INVALID_ARGUMENT); @@ -440,7 +440,7 @@ TEST(TestQRCode, TestGenerateWithoutRendezvousInformation) EXPECT_FALSE(payload.isValidQRCodePayload()); // QRCodeSetupPayloadGenerator should therefore return an error - string base38Rep; + std::string base38Rep; QRCodeSetupPayloadGenerator generator(payload); EXPECT_EQ(generator.payloadBase38Representation(base38Rep), CHIP_ERROR_INVALID_ARGUMENT); @@ -451,23 +451,23 @@ TEST(TestQRCode, TestGenerateWithoutRendezvousInformation) TEST(TestQRCode, TestExtractPayload) { - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("MT:ABC")), string("ABC")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("MT:")), string("")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("H:")), string("")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("ASMT:")), string("")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("Z%MT:ABC%")), string("ABC")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("Z%MT:ABC")), string("ABC")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("%Z%MT:ABC")), string("ABC")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("%Z%MT:ABC%")), string("ABC")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("%Z%MT:ABC%DDD")), string("ABC")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("MT:ABC%DDD")), string("ABC")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("MT:ABC%")), string("ABC")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("%MT:")), string("")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("%MT:%")), string("")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("A%")), string("")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("MT:%")), string("")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("%MT:ABC")), string("ABC")); - EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(string("ABC")), string("")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("MT:ABC")), std::string("ABC")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("MT:")), std::string("")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("H:")), std::string("")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("ASMT:")), std::string("")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("Z%MT:ABC%")), std::string("ABC")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("Z%MT:ABC")), std::string("ABC")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("%Z%MT:ABC")), std::string("ABC")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("%Z%MT:ABC%")), std::string("ABC")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("%Z%MT:ABC%DDD")), std::string("ABC")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("MT:ABC%DDD")), std::string("ABC")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("MT:ABC%")), std::string("ABC")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("%MT:")), std::string("")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("%MT:%")), std::string("")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("A%")), std::string("")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("MT:%")), std::string("")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("%MT:ABC")), std::string("ABC")); + EXPECT_EQ(QRCodeSetupPayloadParser::ExtractPayload(std::string("ABC")), std::string("")); } } // namespace diff --git a/src/setup_payload/tests/TestQRCodeTLV.cpp b/src/setup_payload/tests/TestQRCodeTLV.cpp index 27e7027101ae18..3cada5cb505264 100644 --- a/src/setup_payload/tests/TestQRCodeTLV.cpp +++ b/src/setup_payload/tests/TestQRCodeTLV.cpp @@ -37,7 +37,7 @@ class TestQRCodeTLV : public ::testing::Test TEST_F(TestQRCodeTLV, TestOptionalDataAddRemove) { SetupPayload payload = GetDefaultPayload(); - vector optionalData; + std::vector optionalData; CHIP_ERROR err; optionalData = payload.getAllOptionalVendorData(); @@ -85,11 +85,11 @@ TEST_F(TestQRCodeTLV, TestSimpleWrite) SetupPayload inPayload = GetDefaultPayload(); QRCodeSetupPayloadGenerator generator(inPayload); - string result; + std::string result; CHIP_ERROR err = generator.payloadBase38Representation(result); EXPECT_EQ(err, CHIP_NO_ERROR); - string result2; + std::string result2; err = generator.payloadBase38RepresentationWithAutoTLVBuffer(result2); EXPECT_EQ(err, CHIP_NO_ERROR); @@ -102,7 +102,7 @@ TEST_F(TestQRCodeTLV, TestSimpleRead) SetupPayload outPayload; QRCodeSetupPayloadGenerator generator(inPayload); - string result; + std::string result; CHIP_ERROR err = generator.payloadBase38Representation(result); EXPECT_EQ(err, CHIP_NO_ERROR); @@ -138,7 +138,7 @@ TEST_F(TestQRCodeTLV, TestSerialNumberAddRemove) { SetupPayload inPayload = GetDefaultPayload(); - string sn; + std::string sn; EXPECT_EQ(inPayload.getSerialNumber(sn), CHIP_ERROR_KEY_NOT_FOUND); EXPECT_EQ(inPayload.removeSerialNumber(), CHIP_ERROR_KEY_NOT_FOUND); @@ -148,7 +148,7 @@ TEST_F(TestQRCodeTLV, TestSerialNumberAddRemove) EXPECT_EQ(inPayload.addSerialNumber(kSerialNumberDefaultUInt32Value), CHIP_NO_ERROR); EXPECT_EQ(inPayload.getSerialNumber(sn), CHIP_NO_ERROR); - EXPECT_EQ(sn, to_string(kSerialNumberDefaultUInt32Value)); + EXPECT_EQ(sn, std::to_string(kSerialNumberDefaultUInt32Value)); EXPECT_EQ(inPayload.removeSerialNumber(), CHIP_NO_ERROR); EXPECT_EQ(inPayload.getSerialNumber(sn), CHIP_ERROR_KEY_NOT_FOUND); @@ -163,7 +163,7 @@ TEST_F(TestQRCodeTLV, TestOptionalDataWriteSerial) EXPECT_EQ(err, CHIP_NO_ERROR); QRCodeSetupPayloadGenerator generator(inPayload); - string result; + std::string result; err = generator.payloadBase38Representation(result); EXPECT_NE(err, CHIP_NO_ERROR); @@ -171,7 +171,7 @@ TEST_F(TestQRCodeTLV, TestOptionalDataWriteSerial) err = generator.payloadBase38Representation(result, optionalInfo, sizeof(optionalInfo)); EXPECT_EQ(err, CHIP_NO_ERROR); - string result2; + std::string result2; err = generator.payloadBase38RepresentationWithAutoTLVBuffer(result2); EXPECT_EQ(err, CHIP_NO_ERROR); @@ -183,12 +183,12 @@ TEST_F(TestQRCodeTLV, TestOptionalDataWrite) SetupPayload inPayload = GetDefaultPayloadWithOptionalDefaults(); QRCodeSetupPayloadGenerator generator(inPayload); - string result; + std::string result; uint8_t optionalInfo[kDefaultBufferSizeInBytes]; CHIP_ERROR err = generator.payloadBase38Representation(result, optionalInfo, sizeof(optionalInfo)); EXPECT_EQ(err, CHIP_NO_ERROR); - string result2; + std::string result2; err = generator.payloadBase38RepresentationWithAutoTLVBuffer(result2); EXPECT_EQ(err, CHIP_NO_ERROR); @@ -234,7 +234,7 @@ TEST_F(TestQRCodeTLV, TestOptionalDataWriteNoBuffer) SetupPayload inPayload = GetDefaultPayloadWithOptionalDefaults(); QRCodeSetupPayloadGenerator generator(inPayload); - string result; + std::string result; CHIP_ERROR err = generator.payloadBase38Representation(result); EXPECT_NE(err, CHIP_NO_ERROR); } @@ -244,7 +244,7 @@ TEST_F(TestQRCodeTLV, TestOptionalDataWriteSmallBuffer) SetupPayload inPayload = GetDefaultPayloadWithOptionalDefaults(); QRCodeSetupPayloadGenerator generator(inPayload); - string result; + std::string result; uint8_t optionalInfo[kSmallBufferSizeInBytes]; CHIP_ERROR err = generator.payloadBase38Representation(result, optionalInfo, sizeof(optionalInfo)); EXPECT_NE(err, CHIP_NO_ERROR);