Skip to content

Commit 7eb96cd

Browse files
Removed using namespace std from all files (project-chip#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
1 parent c988fd6 commit 7eb96cd

File tree

46 files changed

+100
-137
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+100
-137
lines changed

examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <app/util/config.h>
22
#include <static-supported-modes-manager.h>
33

4-
using namespace std;
54
using namespace chip;
65
using namespace chip::app::Clusters;
76
using namespace chip::app::Clusters::ModeSelect;

examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <app/util/config.h>
2020
#include <static-supported-temperature-levels.h>
2121

22-
using namespace std;
2322
using namespace chip;
2423
using namespace chip::app::Clusters;
2524
using namespace chip::app::Clusters::TemperatureControl;

examples/chef/common/clusters/audio-output/AudioOutputManager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#ifdef MATTER_DM_PLUGIN_AUDIO_OUTPUT_SERVER
2121
#include "AudioOutputManager.h"
2222

23-
using namespace std;
2423
using namespace chip::app;
2524
using namespace chip::app::Clusters::AudioOutput;
2625
using chip::app::AttributeValueEncoder;

examples/chef/common/clusters/media-input/MediaInputManager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#ifdef MATTER_DM_PLUGIN_MEDIA_INPUT_SERVER
2323
#include "MediaInputManager.h"
2424

25-
using namespace std;
2625
using namespace chip;
2726
using namespace chip::app::Clusters::MediaInput;
2827
using Protocols::InteractionModel::Status;

examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#ifdef MATTER_DM_PLUGIN_MEDIA_PLAYBACK_SERVER
2323
#include "MediaPlaybackManager.h"
2424

25-
using namespace std;
2625
using namespace chip;
2726
using namespace chip::app;
2827
using namespace chip::app::DataModel;

examples/chef/common/clusters/target-navigator/TargetNavigatorManager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <list>
2424
#include <string>
2525

26-
using namespace std;
2726
using namespace chip::app;
2827
using namespace chip::app::Clusters::TargetNavigator;
2928

examples/placeholder/linux/static-supported-modes-manager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <app/util/config.h>
22
#include <static-supported-modes-manager.h>
33

4-
using namespace std;
54
using namespace chip;
65
using namespace chip::app::Clusters;
76
using namespace chip::app::Clusters::ModeSelect;

examples/placeholder/linux/static-supported-temperature-levels.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <app/util/config.h>
2020
#include <static-supported-temperature-levels.h>
2121

22-
using namespace std;
2322
using namespace chip;
2423
using namespace chip::app::Clusters;
2524
using namespace chip::app::Clusters::TemperatureControl;

examples/refrigerator-app/refrigerator-common/src/static-supported-temperature-levels.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <app/util/config.h>
2020
#include <static-supported-temperature-levels.h>
2121

22-
using namespace std;
2322
using namespace chip;
2423
using namespace chip::app::Clusters;
2524
using namespace chip::app::Clusters::TemperatureControl;

examples/tv-app/android/include/account-login/AccountLoginManager.cpp

+9-10
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,19 @@
2323
#include <json/json.h>
2424
#include <lib/core/DataModelTypes.h>
2525

26-
using namespace std;
2726
using namespace chip::app::Clusters;
2827
using namespace chip::app::Clusters::AccountLogin;
2928
using Status = chip::Protocols::InteractionModel::Status;
3029

3130
namespace {
3231

3332
const auto loginTempAccountIdentifierFieldId =
34-
to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kTempAccountIdentifier));
35-
const auto loginSetupPINFieldId = to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kSetupPIN));
36-
const auto loginNodeFieldId = to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kNode));
37-
const auto logoutNodeFieldId = to_string(chip::to_underlying(AccountLogin::Commands::Logout::Fields::kNode));
33+
std::to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kTempAccountIdentifier));
34+
const auto loginSetupPINFieldId = std::to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kSetupPIN));
35+
const auto loginNodeFieldId = std::to_string(chip::to_underlying(AccountLogin::Commands::Login::Fields::kNode));
36+
const auto logoutNodeFieldId = std::to_string(chip::to_underlying(AccountLogin::Commands::Logout::Fields::kNode));
3837

39-
string charSpanToString(const CharSpan & charSpan)
38+
std::string charSpanToString(const CharSpan & charSpan)
4039
{
4140
return { charSpan.data(), charSpan.size() };
4241
}
@@ -45,12 +44,12 @@ std::string serializeLoginCommand(AccountLogin::Commands::Login::Type cmd)
4544
{
4645
return R"({")" + loginTempAccountIdentifierFieldId + R"(":")" + charSpanToString(cmd.tempAccountIdentifier) + R"(",)" + R"(")" +
4746
loginSetupPINFieldId + R"(":")" + charSpanToString(cmd.setupPIN) + R"(",)" + R"(")" + loginNodeFieldId + R"(":")" +
48-
to_string(cmd.node.Value()) + R"("})";
47+
std::to_string(cmd.node.Value()) + R"("})";
4948
}
5049

5150
std::string serializeLogoutCommand(AccountLogin::Commands::Logout::Type cmd)
5251
{
53-
return R"({")" + logoutNodeFieldId + R"(":")" + to_string(cmd.node.Value()) + R"("})";
52+
return R"({")" + logoutNodeFieldId + R"(":")" + std::to_string(cmd.node.Value()) + R"("})";
5453
}
5554

5655
} // namespace
@@ -128,7 +127,7 @@ bool AccountLoginManager::HandleLogout(const chip::Optional<chip::NodeId> & node
128127
void AccountLoginManager::HandleGetSetupPin(CommandResponseHelper<GetSetupPINResponse> & helper,
129128
const CharSpan & tempAccountIdentifier)
130129
{
131-
string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
130+
std::string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
132131

133132
GetSetupPINResponse response;
134133
ChipLogProgress(Zcl, "temporary account id: %s returning pin: %s", tempAccountIdentifierString.c_str(), mSetupPin);
@@ -144,7 +143,7 @@ void AccountLoginManager::GetSetupPin(char * setupPin, size_t setupPinSize, cons
144143
// Other methods in this class do not need to be changed beecause those will get routed to java layer
145144
// upstream.
146145
ChipLogProgress(DeviceLayer, "AccountLoginManager::GetSetupPin called for endpoint %d", mEndpointId);
147-
string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
146+
std::string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
148147
if (mCommandDelegate == nullptr)
149148
{
150149
// For the dummy content apps to work.

examples/tv-app/android/include/application-basic/ApplicationBasicManager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include "ApplicationBasicManager.h"
2020

21-
using namespace std;
2221
using namespace chip::app;
2322
using namespace chip::app::Clusters::ApplicationBasic;
2423

examples/tv-app/android/include/audio-output/AudioOutputManager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include "AudioOutputManager.h"
2020

21-
using namespace std;
2221
using namespace chip::app;
2322
using namespace chip::app::Clusters::AudioOutput;
2423

examples/tv-app/android/include/content-app-observer/ContentAppObserver.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <app-common/zap-generated/attributes/Accessors.h>
2121
#include <app/util/config.h>
2222

23-
using namespace std;
2423
using namespace chip;
2524
using namespace chip::app::Clusters::ContentAppObserver;
2625

examples/tv-app/android/include/content-control/ContentController.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <app-common/zap-generated/attributes/Accessors.h>
2020
#include <app/util/config.h>
2121

22-
using namespace std;
2322
using namespace chip::app;
2423
using namespace chip::app::Clusters;
2524
using namespace chip::app::DataModel;

examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
#include <list>
2525
#include <string>
2626

27-
using namespace std;
2827
using namespace chip::app;
2928
using namespace chip::app::Clusters;
3029
using namespace chip::app::DataModel;
3130
using namespace chip::app::Clusters::ContentLauncher;
3231
using ContentAppAttributeDelegate = chip::AppPlatform::ContentAppAttributeDelegate;
3332

3433
AppContentLauncherManager::AppContentLauncherManager(ContentAppAttributeDelegate * attributeDelegate,
35-
list<std::string> acceptHeaderList, uint32_t supportedStreamingProtocols) :
34+
std::list<std::string> acceptHeaderList,
35+
uint32_t supportedStreamingProtocols) :
3636
mAttributeDelegate(attributeDelegate)
3737
{
3838
mAcceptHeaderList = acceptHeaderList;
@@ -46,7 +46,7 @@ void AppContentLauncherManager::HandleLaunchContent(CommandResponseHelper<Launch
4646
bool useCurrentContext)
4747
{
4848
ChipLogProgress(Zcl, "AppContentLauncherManager::HandleLaunchContent for endpoint %d", mEndpointId);
49-
string dataString(data.data(), data.size());
49+
std::string dataString(data.data(), data.size());
5050

5151
ChipLogProgress(Zcl, " AutoPlay=%s", (autoplay ? "true" : "false"));
5252

@@ -76,8 +76,8 @@ void AppContentLauncherManager::HandleLaunchUrl(CommandResponseHelper<LaunchResp
7676
{
7777
ChipLogProgress(Zcl, "AppContentLauncherManager::HandleLaunchUrl");
7878

79-
string contentUrlString(contentUrl.data(), contentUrl.size());
80-
string displayStringString(displayString.data(), displayString.size());
79+
std::string contentUrlString(contentUrl.data(), contentUrl.size());
80+
std::string displayStringString(displayString.data(), displayString.size());
8181

8282
// TODO: Insert code here
8383
LaunchResponseType response;
@@ -100,7 +100,7 @@ CHIP_ERROR AppContentLauncherManager::HandleGetAcceptHeaderList(AttributeValueEn
100100
Json::Value value;
101101
if (reader.parse(resStr, value))
102102
{
103-
std::string attrId = to_string(chip::app::Clusters::ContentLauncher::Attributes::AcceptHeader::Id);
103+
std::string attrId = std::to_string(chip::app::Clusters::ContentLauncher::Attributes::AcceptHeader::Id);
104104
ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetAcceptHeaderList response parsing done. reading attr %s",
105105
attrId.c_str());
106106
if (value[attrId].isArray())
@@ -146,7 +146,7 @@ uint32_t AppContentLauncherManager::HandleGetSupportedStreamingProtocols()
146146
{
147147
return mSupportedStreamingProtocols;
148148
}
149-
std::string attrId = to_string(chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::Id);
149+
std::string attrId = std::to_string(chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::Id);
150150
ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetSupportedStreamingProtocols response parsing done. reading attr %s",
151151
attrId.c_str());
152152
if (!value[attrId].empty() && value[attrId].isInt())

examples/tv-app/android/include/media-playback/AppMediaPlaybackManager.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
#include <string>
3030

31-
using namespace std;
3231
using namespace chip;
3332
using namespace chip::app;
3433
using namespace chip::app::DataModel;
@@ -204,7 +203,7 @@ uint64_t AppMediaPlaybackManager::HandleMediaRequestGetAttribute(chip::Attribute
204203
Json::Value value;
205204
if (reader.parse(resStr, value))
206205
{
207-
std::string attrId = to_string(attributeId);
206+
std::string attrId = std::to_string(attributeId);
208207
ChipLogProgress(Zcl, "AppMediaPlaybackManager::HandleMediaRequestGetAttribute response parsing done. reading attr %s",
209208
attrId.c_str());
210209
if (!value[attrId].empty() && value[attrId].isUInt())
@@ -250,14 +249,14 @@ CHIP_ERROR AppMediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncod
250249
Json::Value value;
251250
if (reader.parse(resStr, value))
252251
{
253-
std::string attrId = to_string(chip::app::Clusters::MediaPlayback::Attributes::SampledPosition::Id);
252+
std::string attrId = std::to_string(chip::app::Clusters::MediaPlayback::Attributes::SampledPosition::Id);
254253
ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetSampledPosition response parsing done. reading attr %s",
255254
attrId.c_str());
256255
if (!value[attrId].empty() && value[attrId].isObject())
257256
{
258-
std::string updatedAt = to_string(
257+
std::string updatedAt = std::to_string(
259258
static_cast<uint32_t>(chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Fields::kUpdatedAt));
260-
std::string position = to_string(
259+
std::string position = std::to_string(
261260
static_cast<uint32_t>(chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Fields::kPosition));
262261
if (!value[attrId][updatedAt].empty() && !value[attrId][position].empty() && value[attrId][updatedAt].isUInt() &&
263262
value[attrId][position].isUInt())

examples/tv-app/android/include/messages/MessagesManager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "MessagesManager.h"
1919

20-
using namespace std;
2120
using namespace chip::app;
2221
using namespace chip::app::Clusters::Messages;
2322

examples/tv-app/android/include/target-navigator/TargetNavigatorManager.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <list>
2424
#include <string>
2525

26-
using namespace std;
2726
using namespace chip::app;
2827
using namespace chip::app::Clusters::TargetNavigator;
2928
using ContentAppAttributeDelegate = chip::AppPlatform::ContentAppAttributeDelegate;
@@ -53,16 +52,16 @@ CHIP_ERROR TargetNavigatorManager::HandleGetTargetList(AttributeValueEncoder & a
5352
Json::Value value;
5453
if (reader.parse(resStr, value))
5554
{
56-
std::string attrId = to_string(chip::app::Clusters::TargetNavigator::Attributes::TargetList::Id);
55+
std::string attrId = std::to_string(chip::app::Clusters::TargetNavigator::Attributes::TargetList::Id);
5756
ChipLogProgress(Zcl, "TargetNavigatorManager::HandleNavigateTarget response parsing done. reading attr %s",
5857
attrId.c_str());
5958
if (value[attrId].isArray())
6059
{
6160
return aEncoder.EncodeList([&](const auto & encoder) -> CHIP_ERROR {
6261
int i = 0;
63-
std::string targetId = to_string(static_cast<uint32_t>(
62+
std::string targetId = std::to_string(static_cast<uint32_t>(
6463
chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Fields::kIdentifier));
65-
std::string targetName = to_string(
64+
std::string targetName = std::to_string(
6665
static_cast<uint32_t>(chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Fields::kName));
6766
for (Json::Value & entry : value[attrId])
6867
{
@@ -118,7 +117,7 @@ uint8_t TargetNavigatorManager::HandleGetCurrentTarget()
118117
Json::Value value;
119118
if (reader.parse(resStr, value))
120119
{
121-
std::string attrId = to_string(chip::app::Clusters::TargetNavigator::Attributes::CurrentTarget::Id);
120+
std::string attrId = std::to_string(chip::app::Clusters::TargetNavigator::Attributes::CurrentTarget::Id);
122121
ChipLogProgress(Zcl, "TargetNavigatorManager::HandleGetCurrentTarget response parsing done. reading attr %s",
123122
attrId.c_str());
124123
if (value[attrId].isUInt() && value[attrId].asUInt() < 256)

examples/tv-app/android/java/ContentLauncherManager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <lib/support/JniReferences.h>
2828
#include <lib/support/JniTypeWrappers.h>
2929

30-
using namespace std;
3130
using namespace chip;
3231
using namespace chip::app::DataModel;
3332
using namespace chip::app::Clusters::ContentLauncher;

examples/tv-app/android/java/application-launcher/ApplicationLauncherManager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <lib/support/JniReferences.h>
2828
#include <lib/support/JniTypeWrappers.h>
2929

30-
using namespace std;
3130
using namespace chip::app;
3231
using namespace chip::app::Clusters;
3332
using namespace chip::app::Clusters::ApplicationLauncher;

examples/tv-app/tv-common/clusters/account-login/AccountLoginManager.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <app/CommandHandler.h>
2222
#include <app/util/config.h>
2323

24-
using namespace std;
2524
using namespace chip::app::Clusters::AccountLogin;
2625

2726
AccountLoginManager::AccountLoginManager(const char * setupPin)
@@ -32,8 +31,8 @@ AccountLoginManager::AccountLoginManager(const char * setupPin)
3231
bool AccountLoginManager::HandleLogin(const CharSpan & tempAccountIdentifier, const CharSpan & setupPin,
3332
const chip::Optional<chip::NodeId> & nodeId)
3433
{
35-
string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
36-
string setupPinString(setupPin.data(), setupPin.size());
34+
std::string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
35+
std::string setupPinString(setupPin.data(), setupPin.size());
3736
ChipLogProgress(Zcl, "temporary account id: %s", tempAccountIdentifierString.c_str());
3837
ChipLogProgress(Zcl, "setup pin %s", setupPinString.c_str());
3938

@@ -57,7 +56,7 @@ bool AccountLoginManager::HandleLogout(const chip::Optional<chip::NodeId> & node
5756
void AccountLoginManager::HandleGetSetupPin(CommandResponseHelper<GetSetupPINResponse> & helper,
5857
const CharSpan & tempAccountIdentifier)
5958
{
60-
string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
59+
std::string tempAccountIdentifierString(tempAccountIdentifier.data(), tempAccountIdentifier.size());
6160

6261
GetSetupPINResponse response;
6362
ChipLogProgress(Zcl, "temporary account id: %s returning pin: %s", tempAccountIdentifierString.c_str(), mSetupPin);

examples/tv-app/tv-common/clusters/application-basic/ApplicationBasicManager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include "ApplicationBasicManager.h"
2020

21-
using namespace std;
2221
using namespace chip::app;
2322
using namespace chip::app::Clusters::ApplicationBasic;
2423

examples/tv-app/tv-common/clusters/application-launcher/ApplicationLauncherManager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include "ApplicationLauncherManager.h"
2020

21-
using namespace std;
2221
using namespace chip::app;
2322
using namespace chip::app::Clusters;
2423
using namespace chip::app::Clusters::ApplicationLauncher;

examples/tv-app/tv-common/clusters/audio-output/AudioOutputManager.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include "AudioOutputManager.h"
2020

21-
using namespace std;
2221
using namespace chip::app;
2322
using namespace chip::app::Clusters::AudioOutput;
2423

examples/tv-app/tv-common/clusters/content-app-observer/ContentAppObserver.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <app-common/zap-generated/attributes/Accessors.h>
2121
#include <app/util/config.h>
2222

23-
using namespace std;
2423
using namespace chip;
2524
using namespace chip::app::Clusters::ContentAppObserver;
2625

examples/tv-app/tv-common/clusters/content-control/ContentController.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <app-common/zap-generated/attributes/Accessors.h>
2020
#include <app/util/config.h>
2121

22-
using namespace std;
2322
using namespace chip::app;
2423
using namespace chip::app::Clusters;
2524
using namespace chip::app::DataModel;

0 commit comments

Comments
 (0)