Removed using namespace std from all files (#35741)
* Removed using namespace std from all files
* Fix compilation
* Found some more files were using namespace std
* Fix TV app
* Use std::to_underlying with c++23 and later
* Addressed review comments
diff --git a/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp b/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp
index 9434560..59bccf1 100644
--- a/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp
+++ b/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp
@@ -1,7 +1,6 @@
#include <app/util/config.h>
#include <static-supported-modes-manager.h>
-using namespace std;
using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ModeSelect;
diff --git a/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp b/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp
index 6019006..5ed8a0c 100644
--- a/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp
+++ b/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp
@@ -19,7 +19,6 @@
#include <app/util/config.h>
#include <static-supported-temperature-levels.h>
-using namespace std;
using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::TemperatureControl;
diff --git a/examples/chef/common/clusters/audio-output/AudioOutputManager.cpp b/examples/chef/common/clusters/audio-output/AudioOutputManager.cpp
index 06a123a..65df8db 100644
--- a/examples/chef/common/clusters/audio-output/AudioOutputManager.cpp
+++ b/examples/chef/common/clusters/audio-output/AudioOutputManager.cpp
@@ -20,7 +20,6 @@
#ifdef MATTER_DM_PLUGIN_AUDIO_OUTPUT_SERVER
#include "AudioOutputManager.h"
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters::AudioOutput;
using chip::app::AttributeValueEncoder;
diff --git a/examples/chef/common/clusters/media-input/MediaInputManager.cpp b/examples/chef/common/clusters/media-input/MediaInputManager.cpp
index 53cc22c..4d11d99 100644
--- a/examples/chef/common/clusters/media-input/MediaInputManager.cpp
+++ b/examples/chef/common/clusters/media-input/MediaInputManager.cpp
@@ -22,7 +22,6 @@
#ifdef MATTER_DM_PLUGIN_MEDIA_INPUT_SERVER
#include "MediaInputManager.h"
-using namespace std;
using namespace chip;
using namespace chip::app::Clusters::MediaInput;
using Protocols::InteractionModel::Status;
diff --git a/examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp b/examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp
index db3af11..cf8bcda 100644
--- a/examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp
+++ b/examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp
@@ -22,7 +22,6 @@
#ifdef MATTER_DM_PLUGIN_MEDIA_PLAYBACK_SERVER
#include "MediaPlaybackManager.h"
-using namespace std;
using namespace chip;
using namespace chip::app;
using namespace chip::app::DataModel;
diff --git a/examples/chef/common/clusters/target-navigator/TargetNavigatorManager.cpp b/examples/chef/common/clusters/target-navigator/TargetNavigatorManager.cpp
index be20f92..1f2dcde 100644
--- a/examples/chef/common/clusters/target-navigator/TargetNavigatorManager.cpp
+++ b/examples/chef/common/clusters/target-navigator/TargetNavigatorManager.cpp
@@ -23,7 +23,6 @@
#include <list>
#include <string>
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters::TargetNavigator;
diff --git a/examples/placeholder/linux/static-supported-modes-manager.cpp b/examples/placeholder/linux/static-supported-modes-manager.cpp
index 9434560..59bccf1 100644
--- a/examples/placeholder/linux/static-supported-modes-manager.cpp
+++ b/examples/placeholder/linux/static-supported-modes-manager.cpp
@@ -1,7 +1,6 @@
#include <app/util/config.h>
#include <static-supported-modes-manager.h>
-using namespace std;
using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ModeSelect;
diff --git a/examples/placeholder/linux/static-supported-temperature-levels.cpp b/examples/placeholder/linux/static-supported-temperature-levels.cpp
index de8933f..4b65317 100644
--- a/examples/placeholder/linux/static-supported-temperature-levels.cpp
+++ b/examples/placeholder/linux/static-supported-temperature-levels.cpp
@@ -19,7 +19,6 @@
#include <app/util/config.h>
#include <static-supported-temperature-levels.h>
-using namespace std;
using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::TemperatureControl;
diff --git a/examples/refrigerator-app/refrigerator-common/src/static-supported-temperature-levels.cpp b/examples/refrigerator-app/refrigerator-common/src/static-supported-temperature-levels.cpp
index 8678e5f..a7198c0 100644
--- a/examples/refrigerator-app/refrigerator-common/src/static-supported-temperature-levels.cpp
+++ b/examples/refrigerator-app/refrigerator-common/src/static-supported-temperature-levels.cpp
@@ -19,7 +19,6 @@
#include <app/util/config.h>
#include <static-supported-temperature-levels.h>
-using namespace std;
using namespace chip;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::TemperatureControl;
diff --git a/examples/tv-app/android/include/account-login/AccountLoginManager.cpp b/examples/tv-app/android/include/account-login/AccountLoginManager.cpp
index 2aa0b31..a7e9c9f 100644
--- a/examples/tv-app/android/include/account-login/AccountLoginManager.cpp
+++ b/examples/tv-app/android/include/account-login/AccountLoginManager.cpp
@@ -23,7 +23,6 @@
#include <json/json.h>
#include <lib/core/DataModelTypes.h>
-using namespace std;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::AccountLogin;
using Status = chip::Protocols::InteractionModel::Status;
@@ -31,12 +30,12 @@
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)
+std::string charSpanToString(const CharSpan & charSpan)
{
return { charSpan.data(), charSpan.size() };
}
@@ -45,12 +44,12 @@
{
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
@@ -128,7 +127,7 @@
void AccountLoginManager::HandleGetSetupPin(CommandResponseHelper<GetSetupPINResponse> & helper,
const CharSpan & tempAccountIdentifier)
{
- string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
+ std::string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
GetSetupPINResponse response;
ChipLogProgress(Zcl, "temporary account id: %s returning pin: %s", tempAccountIdentifierString.c_str(), mSetupPin);
@@ -144,7 +143,7 @@
// Other methods in this class do not need to be changed beecause those will get routed to java layer
// upstream.
ChipLogProgress(DeviceLayer, "AccountLoginManager::GetSetupPin called for endpoint %d", mEndpointId);
- string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
+ std::string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
if (mCommandDelegate == nullptr)
{
// For the dummy content apps to work.
diff --git a/examples/tv-app/android/include/application-basic/ApplicationBasicManager.cpp b/examples/tv-app/android/include/application-basic/ApplicationBasicManager.cpp
index d941771..80e1146 100644
--- a/examples/tv-app/android/include/application-basic/ApplicationBasicManager.cpp
+++ b/examples/tv-app/android/include/application-basic/ApplicationBasicManager.cpp
@@ -18,7 +18,6 @@
#include "ApplicationBasicManager.h"
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters::ApplicationBasic;
diff --git a/examples/tv-app/android/include/audio-output/AudioOutputManager.cpp b/examples/tv-app/android/include/audio-output/AudioOutputManager.cpp
index 1b8a6a3..77a1e21 100644
--- a/examples/tv-app/android/include/audio-output/AudioOutputManager.cpp
+++ b/examples/tv-app/android/include/audio-output/AudioOutputManager.cpp
@@ -18,7 +18,6 @@
#include "AudioOutputManager.h"
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters::AudioOutput;
diff --git a/examples/tv-app/android/include/content-app-observer/ContentAppObserver.cpp b/examples/tv-app/android/include/content-app-observer/ContentAppObserver.cpp
index 7145ba2..158da86 100644
--- a/examples/tv-app/android/include/content-app-observer/ContentAppObserver.cpp
+++ b/examples/tv-app/android/include/content-app-observer/ContentAppObserver.cpp
@@ -20,7 +20,6 @@
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/util/config.h>
-using namespace std;
using namespace chip;
using namespace chip::app::Clusters::ContentAppObserver;
diff --git a/examples/tv-app/android/include/content-control/ContentController.cpp b/examples/tv-app/android/include/content-control/ContentController.cpp
index edf2550..4883d4f 100644
--- a/examples/tv-app/android/include/content-control/ContentController.cpp
+++ b/examples/tv-app/android/include/content-control/ContentController.cpp
@@ -19,7 +19,6 @@
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/util/config.h>
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::DataModel;
diff --git a/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp b/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp
index 671daab..ab98213 100644
--- a/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp
+++ b/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp
@@ -24,7 +24,6 @@
#include <list>
#include <string>
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::DataModel;
@@ -32,7 +31,8 @@
using ContentAppAttributeDelegate = chip::AppPlatform::ContentAppAttributeDelegate;
AppContentLauncherManager::AppContentLauncherManager(ContentAppAttributeDelegate * attributeDelegate,
- list<std::string> acceptHeaderList, uint32_t supportedStreamingProtocols) :
+ std::list<std::string> acceptHeaderList,
+ uint32_t supportedStreamingProtocols) :
mAttributeDelegate(attributeDelegate)
{
mAcceptHeaderList = acceptHeaderList;
@@ -46,7 +46,7 @@
bool useCurrentContext)
{
ChipLogProgress(Zcl, "AppContentLauncherManager::HandleLaunchContent for endpoint %d", mEndpointId);
- string dataString(data.data(), data.size());
+ std::string dataString(data.data(), data.size());
ChipLogProgress(Zcl, " AutoPlay=%s", (autoplay ? "true" : "false"));
@@ -76,8 +76,8 @@
{
ChipLogProgress(Zcl, "AppContentLauncherManager::HandleLaunchUrl");
- string contentUrlString(contentUrl.data(), contentUrl.size());
- string displayStringString(displayString.data(), displayString.size());
+ std::string contentUrlString(contentUrl.data(), contentUrl.size());
+ std::string displayStringString(displayString.data(), displayString.size());
// TODO: Insert code here
LaunchResponseType response;
@@ -100,7 +100,7 @@
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())
@@ -146,7 +146,7 @@
{
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 9f5c2e5..e58d6ee 100644
--- a/examples/tv-app/android/include/media-playback/AppMediaPlaybackManager.cpp
+++ b/examples/tv-app/android/include/media-playback/AppMediaPlaybackManager.cpp
@@ -28,7 +28,6 @@
#include <string>
-using namespace std;
using namespace chip;
using namespace chip::app;
using namespace chip::app::DataModel;
@@ -204,7 +203,7 @@
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())
@@ -250,14 +249,14 @@
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<uint32_t>(chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Fields::kUpdatedAt));
- std::string position = to_string(
+ std::string position = std::to_string(
static_cast<uint32_t>(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/messages/MessagesManager.cpp b/examples/tv-app/android/include/messages/MessagesManager.cpp
index 00848c6..a4fdaa5 100644
--- a/examples/tv-app/android/include/messages/MessagesManager.cpp
+++ b/examples/tv-app/android/include/messages/MessagesManager.cpp
@@ -17,7 +17,6 @@
#include "MessagesManager.h"
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters::Messages;
diff --git a/examples/tv-app/android/include/target-navigator/TargetNavigatorManager.cpp b/examples/tv-app/android/include/target-navigator/TargetNavigatorManager.cpp
index fe78842..3b84a05 100644
--- a/examples/tv-app/android/include/target-navigator/TargetNavigatorManager.cpp
+++ b/examples/tv-app/android/include/target-navigator/TargetNavigatorManager.cpp
@@ -23,7 +23,6 @@
#include <list>
#include <string>
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters::TargetNavigator;
using ContentAppAttributeDelegate = chip::AppPlatform::ContentAppAttributeDelegate;
@@ -53,16 +52,16 @@
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<uint32_t>(
+ std::string targetId = std::to_string(static_cast<uint32_t>(
chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Fields::kIdentifier));
- std::string targetName = to_string(
+ std::string targetName = std::to_string(
static_cast<uint32_t>(chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Fields::kName));
for (Json::Value & entry : value[attrId])
{
@@ -118,7 +117,7 @@
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/examples/tv-app/android/java/ContentLauncherManager.cpp b/examples/tv-app/android/java/ContentLauncherManager.cpp
index 9aacc2d..b1c3a8c 100644
--- a/examples/tv-app/android/java/ContentLauncherManager.cpp
+++ b/examples/tv-app/android/java/ContentLauncherManager.cpp
@@ -27,7 +27,6 @@
#include <lib/support/JniReferences.h>
#include <lib/support/JniTypeWrappers.h>
-using namespace std;
using namespace chip;
using namespace chip::app::DataModel;
using namespace chip::app::Clusters::ContentLauncher;
diff --git a/examples/tv-app/android/java/application-launcher/ApplicationLauncherManager.cpp b/examples/tv-app/android/java/application-launcher/ApplicationLauncherManager.cpp
index 8ee9129..9267a08 100644
--- a/examples/tv-app/android/java/application-launcher/ApplicationLauncherManager.cpp
+++ b/examples/tv-app/android/java/application-launcher/ApplicationLauncherManager.cpp
@@ -27,7 +27,6 @@
#include <lib/support/JniReferences.h>
#include <lib/support/JniTypeWrappers.h>
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ApplicationLauncher;
diff --git a/examples/tv-app/tv-common/clusters/account-login/AccountLoginManager.cpp b/examples/tv-app/tv-common/clusters/account-login/AccountLoginManager.cpp
index 9264553..21c9625 100644
--- a/examples/tv-app/tv-common/clusters/account-login/AccountLoginManager.cpp
+++ b/examples/tv-app/tv-common/clusters/account-login/AccountLoginManager.cpp
@@ -21,7 +21,6 @@
#include <app/CommandHandler.h>
#include <app/util/config.h>
-using namespace std;
using namespace chip::app::Clusters::AccountLogin;
AccountLoginManager::AccountLoginManager(const char * setupPin)
@@ -32,8 +31,8 @@
bool AccountLoginManager::HandleLogin(const CharSpan & tempAccountIdentifier, const CharSpan & setupPin,
const chip::Optional<chip::NodeId> & nodeId)
{
- string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
- string setupPinString(setupPin.data(), setupPin.size());
+ std::string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
+ std::string setupPinString(setupPin.data(), setupPin.size());
ChipLogProgress(Zcl, "temporary account id: %s", tempAccountIdentifierString.c_str());
ChipLogProgress(Zcl, "setup pin %s", setupPinString.c_str());
@@ -57,7 +56,7 @@
void AccountLoginManager::HandleGetSetupPin(CommandResponseHelper<GetSetupPINResponse> & helper,
const CharSpan & tempAccountIdentifier)
{
- string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
+ std::string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
GetSetupPINResponse response;
ChipLogProgress(Zcl, "temporary account id: %s returning pin: %s", tempAccountIdentifierString.c_str(), mSetupPin);
diff --git a/examples/tv-app/tv-common/clusters/application-basic/ApplicationBasicManager.cpp b/examples/tv-app/tv-common/clusters/application-basic/ApplicationBasicManager.cpp
index d941771..80e1146 100644
--- a/examples/tv-app/tv-common/clusters/application-basic/ApplicationBasicManager.cpp
+++ b/examples/tv-app/tv-common/clusters/application-basic/ApplicationBasicManager.cpp
@@ -18,7 +18,6 @@
#include "ApplicationBasicManager.h"
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters::ApplicationBasic;
diff --git a/examples/tv-app/tv-common/clusters/application-launcher/ApplicationLauncherManager.cpp b/examples/tv-app/tv-common/clusters/application-launcher/ApplicationLauncherManager.cpp
index c915856..3a49609 100644
--- a/examples/tv-app/tv-common/clusters/application-launcher/ApplicationLauncherManager.cpp
+++ b/examples/tv-app/tv-common/clusters/application-launcher/ApplicationLauncherManager.cpp
@@ -18,7 +18,6 @@
#include "ApplicationLauncherManager.h"
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ApplicationLauncher;
diff --git a/examples/tv-app/tv-common/clusters/audio-output/AudioOutputManager.cpp b/examples/tv-app/tv-common/clusters/audio-output/AudioOutputManager.cpp
index 1b8a6a3..77a1e21 100644
--- a/examples/tv-app/tv-common/clusters/audio-output/AudioOutputManager.cpp
+++ b/examples/tv-app/tv-common/clusters/audio-output/AudioOutputManager.cpp
@@ -18,7 +18,6 @@
#include "AudioOutputManager.h"
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters::AudioOutput;
diff --git a/examples/tv-app/tv-common/clusters/content-app-observer/ContentAppObserver.cpp b/examples/tv-app/tv-common/clusters/content-app-observer/ContentAppObserver.cpp
index a6010a5..9c42fe3 100644
--- a/examples/tv-app/tv-common/clusters/content-app-observer/ContentAppObserver.cpp
+++ b/examples/tv-app/tv-common/clusters/content-app-observer/ContentAppObserver.cpp
@@ -20,7 +20,6 @@
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/util/config.h>
-using namespace std;
using namespace chip;
using namespace chip::app::Clusters::ContentAppObserver;
diff --git a/examples/tv-app/tv-common/clusters/content-control/ContentController.cpp b/examples/tv-app/tv-common/clusters/content-control/ContentController.cpp
index 19317a7..352b204 100644
--- a/examples/tv-app/tv-common/clusters/content-control/ContentController.cpp
+++ b/examples/tv-app/tv-common/clusters/content-control/ContentController.cpp
@@ -19,7 +19,6 @@
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/util/config.h>
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::DataModel;
diff --git a/examples/tv-app/tv-common/clusters/content-launcher/ContentLauncherManager.cpp b/examples/tv-app/tv-common/clusters/content-launcher/ContentLauncherManager.cpp
index f051961..74dd6de 100644
--- a/examples/tv-app/tv-common/clusters/content-launcher/ContentLauncherManager.cpp
+++ b/examples/tv-app/tv-common/clusters/content-launcher/ContentLauncherManager.cpp
@@ -23,13 +23,12 @@
#include <list>
#include <string>
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::DataModel;
using namespace chip::app::Clusters::ContentLauncher;
-ContentLauncherManager::ContentLauncherManager(list<std::string> acceptHeaderList, uint32_t supportedStreamingProtocols)
+ContentLauncherManager::ContentLauncherManager(std::list<std::string> acceptHeaderList, uint32_t supportedStreamingProtocols)
{
mAcceptHeaderList = acceptHeaderList;
mSupportedStreamingProtocols = supportedStreamingProtocols;
@@ -103,7 +102,7 @@
bool useCurrentContext)
{
ChipLogProgress(Zcl, "ContentLauncherManager::HandleLaunchContent");
- string dataString(data.data(), data.size());
+ std::string dataString(data.data(), data.size());
ChipLogProgress(Zcl, "ContentLauncherManager::HandleLaunchContent TEST CASE autoplay=%d data=%s ", (autoplay ? 1 : 0),
dataString.c_str());
@@ -122,8 +121,8 @@
{
if (parameter.type == parameterType.type)
{
- string val1(parameter.value.data(), parameter.value.size());
- string val2(parameterType.value.data(), parameterType.value.size());
+ std::string val1(parameter.value.data(), parameter.value.size());
+ std::string val2(parameterType.value.data(), parameterType.value.size());
if (strcmp(val1.c_str(), val2.c_str()) == 0)
{
ChipLogProgress(Zcl, " TEST CASE found match=%s type=%d", contentEntry.mName.c_str(),
@@ -152,9 +151,9 @@
{
ChipLogProgress(Zcl, "ContentLauncherManager::HandleLaunchUrl");
- string contentUrlString(contentUrl.data(), contentUrl.size());
- string displayStringString(displayString.data(), displayString.size());
- string providerNameString(brandingInformation.providerName.data(), brandingInformation.providerName.size());
+ std::string contentUrlString(contentUrl.data(), contentUrl.size());
+ std::string displayStringString(displayString.data(), displayString.size());
+ std::string providerNameString(brandingInformation.providerName.data(), brandingInformation.providerName.size());
ChipLogProgress(
Zcl, "ContentLauncherManager::HandleLaunchUrl TEST CASE ContentURL=%s DisplayString=%s BrandingInformation.ProviderName=%s",
diff --git a/examples/tv-app/tv-common/clusters/media-input/MediaInputManager.cpp b/examples/tv-app/tv-common/clusters/media-input/MediaInputManager.cpp
index bd5582e..0c1dac4 100644
--- a/examples/tv-app/tv-common/clusters/media-input/MediaInputManager.cpp
+++ b/examples/tv-app/tv-common/clusters/media-input/MediaInputManager.cpp
@@ -19,7 +19,6 @@
#include <string>
-using namespace std;
using namespace chip;
using namespace chip::app::Clusters::MediaInput;
@@ -76,8 +75,8 @@
ChipLogProgress(Zcl, " MediaInputManager::HandleShowInputStatus()");
for (auto const & inputInfo : this->mInputs)
{
- string name(inputInfo.name.data(), inputInfo.name.size());
- string desc(inputInfo.description.data(), inputInfo.description.size());
+ std::string name(inputInfo.name.data(), inputInfo.name.size());
+ std::string desc(inputInfo.description.data(), inputInfo.description.size());
ChipLogProgress(Zcl, " [%d] type=%d selected=%d name=%s desc=%s", inputInfo.index,
static_cast<uint16_t>(inputInfo.inputType), (mCurrentInput == inputInfo.index ? 1 : 0), name.c_str(),
desc.c_str());
diff --git a/examples/tv-app/tv-common/clusters/media-playback/MediaPlaybackManager.cpp b/examples/tv-app/tv-common/clusters/media-playback/MediaPlaybackManager.cpp
index 0e79c6b..9115902 100644
--- a/examples/tv-app/tv-common/clusters/media-playback/MediaPlaybackManager.cpp
+++ b/examples/tv-app/tv-common/clusters/media-playback/MediaPlaybackManager.cpp
@@ -21,7 +21,6 @@
#include <string>
-using namespace std;
using namespace chip::app::DataModel;
using namespace chip::app::Clusters::MediaPlayback;
using namespace chip::Uint8;
diff --git a/examples/tv-app/tv-common/clusters/messages/MessagesManager.cpp b/examples/tv-app/tv-common/clusters/messages/MessagesManager.cpp
index 681cd56..181c37ca 100644
--- a/examples/tv-app/tv-common/clusters/messages/MessagesManager.cpp
+++ b/examples/tv-app/tv-common/clusters/messages/MessagesManager.cpp
@@ -21,7 +21,6 @@
#include <string>
#include <vector>
-using namespace std;
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters::Messages;
diff --git a/examples/tv-app/tv-common/clusters/target-navigator/TargetNavigatorManager.cpp b/examples/tv-app/tv-common/clusters/target-navigator/TargetNavigatorManager.cpp
index dced037..0393252 100644
--- a/examples/tv-app/tv-common/clusters/target-navigator/TargetNavigatorManager.cpp
+++ b/examples/tv-app/tv-common/clusters/target-navigator/TargetNavigatorManager.cpp
@@ -21,7 +21,6 @@
#include <string>
-using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters::TargetNavigator;
diff --git a/examples/tv-casting-app/tv-casting-common/clusters/content-app-observer/ContentAppObserver.cpp b/examples/tv-casting-app/tv-casting-common/clusters/content-app-observer/ContentAppObserver.cpp
index a6010a5..5be511a 100644
--- a/examples/tv-casting-app/tv-casting-common/clusters/content-app-observer/ContentAppObserver.cpp
+++ b/examples/tv-casting-app/tv-casting-common/clusters/content-app-observer/ContentAppObserver.cpp
@@ -20,7 +20,6 @@
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/util/config.h>
-using namespace std;
using namespace chip;
using namespace chip::app::Clusters::ContentAppObserver;
@@ -35,8 +34,8 @@
{
ChipLogProgress(Zcl, "ContentAppObserverManager::HandleContentAppMessage");
- string dataString(data.HasValue() ? data.Value().data() : "", data.HasValue() ? data.Value().size() : 0);
- string encodingHintString(encodingHint.data(), encodingHint.size());
+ std::string dataString(data.HasValue() ? data.Value().data() : "", data.HasValue() ? data.Value().size() : 0);
+ std::string encodingHintString(encodingHint.data(), encodingHint.size());
ChipLogProgress(Zcl, "ContentAppObserverManager::HandleContentAppMessage TEST CASE hint=%s data=%s ",
encodingHintString.c_str(), dataString.c_str());
diff --git a/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp b/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp
index 81d1f78..4dee355 100644
--- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp
+++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp
@@ -25,7 +25,6 @@
using namespace chip::System;
using namespace chip::Controller;
using namespace chip::Dnssd;
-using namespace std;
CastingPlayerDiscovery * CastingPlayerDiscovery::_castingPlayerDiscovery = nullptr;
diff --git a/src/app/clusters/dishwasher-alarm-server/dishwasher-alarm-server.cpp b/src/app/clusters/dishwasher-alarm-server/dishwasher-alarm-server.cpp
index b3c9b8e..672df0a 100644
--- a/src/app/clusters/dishwasher-alarm-server/dishwasher-alarm-server.cpp
+++ b/src/app/clusters/dishwasher-alarm-server/dishwasher-alarm-server.cpp
@@ -33,7 +33,6 @@
using namespace chip::app::Clusters::DishwasherAlarm::Attributes;
using namespace chip::DeviceLayer;
using chip::Protocols::InteractionModel::Status;
-using namespace std;
static constexpr size_t kDishwasherAlarmDelegateTableSize =
MATTER_DM_DISHWASHER_ALARM_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT;
diff --git a/src/app/clusters/mode-select-server/mode-select-server.cpp b/src/app/clusters/mode-select-server/mode-select-server.cpp
index 5f247bb..813d16d 100644
--- a/src/app/clusters/mode-select-server/mode-select-server.cpp
+++ b/src/app/clusters/mode-select-server/mode-select-server.cpp
@@ -37,7 +37,6 @@
#include <app/clusters/on-off-server/on-off-server.h>
#endif // MATTER_DM_PLUGIN_ON_OFF
-using namespace std;
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
diff --git a/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.cpp b/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.cpp
index 620e113..751bd76 100644
--- a/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.cpp
+++ b/src/app/clusters/refrigerator-alarm-server/refrigerator-alarm-server.cpp
@@ -32,7 +32,6 @@
using namespace chip::DeviceLayer;
using chip::Protocols::InteractionModel::Status;
-using namespace std;
RefrigeratorAlarmServer RefrigeratorAlarmServer::instance;
RefrigeratorAlarmServer & RefrigeratorAlarmServer::Instance()
diff --git a/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp b/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp
index b8d8855..6c581ff 100644
--- a/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp
+++ b/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp
@@ -34,8 +34,6 @@
#include <lib/support/TypeTraits.h>
#include <protocols/interaction_model/StatusCode.h>
-// using namespace std;
-using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ResourceMonitoring;
diff --git a/src/lib/dnssd/minimal_mdns/tests/FuzzPacketParsingPW.cpp b/src/lib/dnssd/minimal_mdns/tests/FuzzPacketParsingPW.cpp
index aec550b..0ea5de5 100644
--- a/src/lib/dnssd/minimal_mdns/tests/FuzzPacketParsingPW.cpp
+++ b/src/lib/dnssd/minimal_mdns/tests/FuzzPacketParsingPW.cpp
@@ -10,7 +10,6 @@
namespace {
using namespace fuzztest;
-using namespace std;
using namespace chip;
using namespace mdns::Minimal;
@@ -65,16 +64,16 @@
mdns::Minimal::ParsePacket(packet, &delegate);
}
-FUZZ_TEST(MinimalmDNS, PacketParserFuzz).WithDomains(Arbitrary<vector<uint8_t>>());
+FUZZ_TEST(MinimalmDNS, PacketParserFuzz).WithDomains(Arbitrary<std::vector<uint8_t>>());
class TxtRecordAccumulator : public TxtRecordDelegate
{
public:
- using DataType = vector<pair<string, string>>;
+ using DataType = std::vector<std::pair<std::string, std::string>>;
void OnRecord(const BytesRange & name, const BytesRange & value) override
{
- mData.push_back(make_pair(AsString(name), AsString(value)));
+ mData.push_back(std::make_pair(AsString(name), AsString(value)));
}
DataType & Data() { return mData; }
@@ -83,9 +82,9 @@
private:
DataType mData;
- static string AsString(const BytesRange & range)
+ static std::string AsString(const BytesRange & range)
{
- return string(reinterpret_cast<const char *>(range.Start()), reinterpret_cast<const char *>(range.End()));
+ return std::string(reinterpret_cast<const char *>(range.Start()), reinterpret_cast<const char *>(range.End()));
}
};
diff --git a/src/lib/dnssd/minimal_mdns/tests/TestAdvertiser.cpp b/src/lib/dnssd/minimal_mdns/tests/TestAdvertiser.cpp
index ea85f74..6b626be 100644
--- a/src/lib/dnssd/minimal_mdns/tests/TestAdvertiser.cpp
+++ b/src/lib/dnssd/minimal_mdns/tests/TestAdvertiser.cpp
@@ -38,7 +38,6 @@
namespace {
-using namespace std;
using namespace chip;
using namespace chip::Dnssd;
using namespace mdns::Minimal;
diff --git a/src/lib/dnssd/minimal_mdns/tests/TestRecordData.cpp b/src/lib/dnssd/minimal_mdns/tests/TestRecordData.cpp
index dcd4895..ae9e37e 100644
--- a/src/lib/dnssd/minimal_mdns/tests/TestRecordData.cpp
+++ b/src/lib/dnssd/minimal_mdns/tests/TestRecordData.cpp
@@ -26,7 +26,6 @@
namespace {
-using namespace std;
using namespace chip;
using namespace mdns::Minimal;
@@ -205,11 +204,11 @@
class TxtRecordAccumulator : public TxtRecordDelegate
{
public:
- using DataType = vector<pair<string, string>>;
+ using DataType = std::vector<std::pair<std::string, std::string>>;
void OnRecord(const BytesRange & name, const BytesRange & value) override
{
- mData.push_back(make_pair(AsString(name), AsString(value)));
+ mData.push_back(std::make_pair(AsString(name), AsString(value)));
}
DataType & Data() { return mData; }
@@ -218,9 +217,9 @@
private:
DataType mData;
- static string AsString(const BytesRange & range)
+ static std::string AsString(const BytesRange & range)
{
- return string(reinterpret_cast<const char *>(range.Start()), reinterpret_cast<const char *>(range.End()));
+ return std::string(reinterpret_cast<const char *>(range.Start()), reinterpret_cast<const char *>(range.End()));
}
};
@@ -237,9 +236,9 @@
EXPECT_TRUE(ParseTxtRecord(BytesRange(record, record + sizeof(record)), &accumulator));
EXPECT_EQ(accumulator.Data().size(), 4u);
- EXPECT_EQ(accumulator.Data()[0], (make_pair<std::string, std::string>("some", "")));
- EXPECT_EQ(accumulator.Data()[1], (make_pair<std::string, std::string>("foo", "bar")));
- EXPECT_EQ(accumulator.Data()[2], (make_pair<std::string, std::string>("x", "y=z")));
- EXPECT_EQ(accumulator.Data()[3], (make_pair<std::string, std::string>("a", "")));
+ EXPECT_EQ(accumulator.Data()[0], (std::make_pair<std::string, std::string>("some", "")));
+ EXPECT_EQ(accumulator.Data()[1], (std::make_pair<std::string, std::string>("foo", "bar")));
+ EXPECT_EQ(accumulator.Data()[2], (std::make_pair<std::string, std::string>("x", "y=z")));
+ EXPECT_EQ(accumulator.Data()[3], (std::make_pair<std::string, std::string>("a", "")));
}
} // namespace
diff --git a/src/lib/dnssd/minimal_mdns/tests/TestResponseSender.cpp b/src/lib/dnssd/minimal_mdns/tests/TestResponseSender.cpp
index abfceb5..c08b6c8 100644
--- a/src/lib/dnssd/minimal_mdns/tests/TestResponseSender.cpp
+++ b/src/lib/dnssd/minimal_mdns/tests/TestResponseSender.cpp
@@ -34,7 +34,6 @@
namespace {
-using namespace std;
using namespace chip;
using namespace mdns::Minimal;
using namespace mdns::Minimal::test;
diff --git a/src/lib/support/TypeTraits.h b/src/lib/support/TypeTraits.h
index e8718a2..4d32602 100644
--- a/src/lib/support/TypeTraits.h
+++ b/src/lib/support/TypeTraits.h
@@ -26,8 +26,17 @@
#include <type_traits>
+#if __has_include(<utility>) // For C++23 and later, include <utility> if available
+#include <utility> // Contains std::to_underlying
+#endif
+
namespace chip {
+#if __cplusplus >= 202300L
+
+using to_underlying = std::to_underlying;
+
+#else
/**
* @brief Implemented std::to_underlying introduced in C++23.
*/
@@ -37,6 +46,7 @@
static_assert(std::is_enum<T>::value, "to_underlying called to non-enum values.");
return static_cast<std::underlying_type_t<T>>(e);
}
+#endif
/**
* @brief This template is not designed to be used directly. A common pattern to check the presence of a member of a class is:
diff --git a/src/platform/Tizen/SystemInfo.cpp b/src/platform/Tizen/SystemInfo.cpp
index e9ac7d7..dd4f9f8 100644
--- a/src/platform/Tizen/SystemInfo.cpp
+++ b/src/platform/Tizen/SystemInfo.cpp
@@ -26,8 +26,6 @@
#include "ErrorUtils.h"
-using namespace std;
-
namespace chip {
namespace DeviceLayer {
namespace Internal {
diff --git a/src/platform/stm32/CHIPMem-Platform.cpp b/src/platform/stm32/CHIPMem-Platform.cpp
index b9bf90f..cbf52cf 100644
--- a/src/platform/stm32/CHIPMem-Platform.cpp
+++ b/src/platform/stm32/CHIPMem-Platform.cpp
@@ -67,8 +67,6 @@
#define USE_FREERTOS
-using namespace std;
-
// Define the new operator for C++ to use the freeRTOS memory management
// functions.
//
diff --git a/src/setup_payload/tests/TestQRCode.cpp b/src/setup_payload/tests/TestQRCode.cpp
index e5d6822..ce50484 100644
--- a/src/setup_payload/tests/TestQRCode.cpp
+++ b/src/setup_payload/tests/TestQRCode.cpp
@@ -32,7 +32,6 @@
#include <lib/support/Span.h>
using namespace chip;
-using namespace std;
namespace {
@@ -121,7 +120,7 @@
{
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));
}
@@ -130,7 +129,7 @@
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);
@@ -241,10 +240,10 @@
base38Encode(ByteSpan((uint8_t *) "Hello World!", sizeof("Hello World!") - 1), encodedSpan);
EXPECT_STREQ(encodedBuf, "KKHF3W2S013OPM3EJX11");
- vector<uint8_t> decoded = vector<uint8_t>();
+ std::vector<uint8_t> decoded = std::vector<uint8_t>();
EXPECT_EQ(base38Decode("KKHF3W2S013OPM3EJX11", decoded), CHIP_NO_ERROR);
- string hello_world;
+ std::string hello_world;
for (uint8_t b : decoded)
{
hello_world += static_cast<char>(b);
@@ -347,8 +346,8 @@
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;
@@ -360,7 +359,7 @@
TEST(TestQRCode, TestInvalidQRCodePayload_WrongLength)
{
- string invalidString = kDefaultPayloadQRCode;
+ std::string invalidString = kDefaultPayloadQRCode;
invalidString.pop_back();
QRCodeSetupPayloadParser parser = QRCodeSetupPayloadParser(invalidString);
@@ -395,7 +394,7 @@
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);
@@ -422,7 +421,7 @@
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);
@@ -441,7 +440,7 @@
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);
@@ -452,23 +451,23 @@
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 7ea2b97..3cada5c 100644
--- a/src/setup_payload/tests/TestQRCodeTLV.cpp
+++ b/src/setup_payload/tests/TestQRCodeTLV.cpp
@@ -24,7 +24,6 @@
#include <lib/support/ScopedBuffer.h>
using namespace chip;
-using namespace std;
namespace {
@@ -38,7 +37,7 @@
TEST_F(TestQRCodeTLV, TestOptionalDataAddRemove)
{
SetupPayload payload = GetDefaultPayload();
- vector<OptionalQRCodeInfo> optionalData;
+ std::vector<OptionalQRCodeInfo> optionalData;
CHIP_ERROR err;
optionalData = payload.getAllOptionalVendorData();
@@ -86,11 +85,11 @@
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);
@@ -103,7 +102,7 @@
SetupPayload outPayload;
QRCodeSetupPayloadGenerator generator(inPayload);
- string result;
+ std::string result;
CHIP_ERROR err = generator.payloadBase38Representation(result);
EXPECT_EQ(err, CHIP_NO_ERROR);
@@ -139,7 +138,7 @@
{
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);
@@ -149,7 +148,7 @@
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);
@@ -164,7 +163,7 @@
EXPECT_EQ(err, CHIP_NO_ERROR);
QRCodeSetupPayloadGenerator generator(inPayload);
- string result;
+ std::string result;
err = generator.payloadBase38Representation(result);
EXPECT_NE(err, CHIP_NO_ERROR);
@@ -172,7 +171,7 @@
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);
@@ -184,12 +183,12 @@
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);
@@ -235,7 +234,7 @@
SetupPayload inPayload = GetDefaultPayloadWithOptionalDefaults();
QRCodeSetupPayloadGenerator generator(inPayload);
- string result;
+ std::string result;
CHIP_ERROR err = generator.payloadBase38Representation(result);
EXPECT_NE(err, CHIP_NO_ERROR);
}
@@ -245,7 +244,7 @@
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);