diff --git a/examples/tv-app/android/include/account-login/AccountLoginManager.cpp b/examples/tv-app/android/include/account-login/AccountLoginManager.cpp index 73ebb9fc8e5723..0d791265873c29 100644 --- a/examples/tv-app/android/include/account-login/AccountLoginManager.cpp +++ b/examples/tv-app/android/include/account-login/AccountLoginManager.cpp @@ -35,7 +35,7 @@ const auto loginSetupPINFieldId = std::to_string(chip::to_underlying(AccountLogi 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() }; } @@ -127,10 +127,10 @@ bool AccountLoginManager::HandleLogout(const chip::Optional & node void AccountLoginManager::HandleGetSetupPin(CommandResponseHelper & 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); + ChipLogProgress(Zcl, "temporary account id: %s returning pin: %s", tempAccountIdentifierString.std::c_str(), mSetupPin); response.setupPIN = CharSpan::fromCharString(mSetupPin); helper.Success(response); @@ -143,7 +143,7 @@ void AccountLoginManager::GetSetupPin(char * setupPin, size_t setupPinSize, cons // 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/content-launcher/AppContentLauncherManager.cpp b/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp index d4bb85088e6abd..f10cb35990c4e8 100644 --- a/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp +++ b/examples/tv-app/android/include/content-launcher/AppContentLauncherManager.cpp @@ -31,7 +31,7 @@ using namespace chip::app::Clusters::ContentLauncher; using ContentAppAttributeDelegate = chip::AppPlatform::ContentAppAttributeDelegate; AppContentLauncherManager::AppContentLauncherManager(ContentAppAttributeDelegate * attributeDelegate, - list acceptHeaderList, uint32_t supportedStreamingProtocols) : + std::list acceptHeaderList, uint32_t supportedStreamingProtocols) : mAttributeDelegate(attributeDelegate) { mAcceptHeaderList = acceptHeaderList; @@ -45,7 +45,7 @@ void AppContentLauncherManager::HandleLaunchContent(CommandResponseHelperRead(aPath); - ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetAcceptHeaderList response %s", resStr.c_str()); + ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetAcceptHeaderList response %s", resStr.std::c_str()); if (resStr.length() != 0) { @@ -101,7 +101,7 @@ CHIP_ERROR AppContentLauncherManager::HandleGetAcceptHeaderList(AttributeValueEn { 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()); + attrId.std::c_str()); if (value[attrId].isArray()) { mAcceptHeaderList.clear(); @@ -132,7 +132,7 @@ uint32_t AppContentLauncherManager::HandleGetSupportedStreamingProtocols() chip::app::ConcreteReadAttributePath aPath(mEndpointId, chip::app::Clusters::ContentLauncher::Id, chip::app::Clusters::ContentLauncher::Attributes::SupportedStreamingProtocols::Id); std::string resStr = mAttributeDelegate->Read(aPath); - ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetSupportedStreamingProtocols response %s", resStr.c_str()); + ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetSupportedStreamingProtocols response %s", resStr.std::c_str()); if (resStr.length() == 0) { @@ -147,7 +147,7 @@ uint32_t AppContentLauncherManager::HandleGetSupportedStreamingProtocols() } 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()); + attrId.std::c_str()); if (!value[attrId].empty() && value[attrId].isInt()) { uint32_t supportedStreamingProtocols = static_cast(value[attrId].asInt()); diff --git a/examples/tv-app/android/include/media-playback/AppMediaPlaybackManager.cpp b/examples/tv-app/android/include/media-playback/AppMediaPlaybackManager.cpp index e58d6eebb52462..2cac80594bf101 100644 --- a/examples/tv-app/android/include/media-playback/AppMediaPlaybackManager.cpp +++ b/examples/tv-app/android/include/media-playback/AppMediaPlaybackManager.cpp @@ -194,7 +194,7 @@ uint64_t AppMediaPlaybackManager::HandleMediaRequestGetAttribute(chip::Attribute ChipLogProgress(Zcl, "Received AppMediaPlaybackManager::HandleMediaRequestGetAttribute:%d", attributeId); chip::app::ConcreteReadAttributePath aPath(mEndpointId, chip::app::Clusters::MediaPlayback::Id, attributeId); std::string resStr = mAttributeDelegate->Read(aPath); - ChipLogProgress(Zcl, "AppMediaPlaybackManager::HandleMediaRequestGetAttribute response %s", resStr.c_str()); + ChipLogProgress(Zcl, "AppMediaPlaybackManager::HandleMediaRequestGetAttribute response %s", resStr.std::c_str()); uint64_t ret = std::numeric_limits::max(); if (resStr.length() != 0) @@ -205,7 +205,7 @@ uint64_t AppMediaPlaybackManager::HandleMediaRequestGetAttribute(chip::Attribute { std::string attrId = std::to_string(attributeId); ChipLogProgress(Zcl, "AppMediaPlaybackManager::HandleMediaRequestGetAttribute response parsing done. reading attr %s", - attrId.c_str()); + attrId.std::c_str()); if (!value[attrId].empty() && value[attrId].isUInt()) { ret = static_cast(value[attrId].asUInt()); @@ -241,7 +241,7 @@ CHIP_ERROR AppMediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncod chip::app::ConcreteReadAttributePath aPath(mEndpointId, chip::app::Clusters::MediaPlayback::Id, chip::app::Clusters::MediaPlayback::Attributes::SampledPosition::Id); std::string resStr = mAttributeDelegate->Read(aPath); - ChipLogProgress(Zcl, "AppMediaPlaybackManager::HandleGetSampledPosition response %s", resStr.c_str()); + ChipLogProgress(Zcl, "AppMediaPlaybackManager::HandleGetSampledPosition response %s", resStr.std::c_str()); if (resStr.length() != 0) { @@ -251,7 +251,7 @@ CHIP_ERROR AppMediaPlaybackManager::HandleGetSampledPosition(AttributeValueEncod { 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()); + attrId.std::c_str()); if (!value[attrId].empty() && value[attrId].isObject()) { std::string updatedAt = std::to_string( diff --git a/examples/tv-app/android/include/target-navigator/TargetNavigatorManager.cpp b/examples/tv-app/android/include/target-navigator/TargetNavigatorManager.cpp index 3b84a050d3e51a..20d1b3aca1ab7c 100644 --- a/examples/tv-app/android/include/target-navigator/TargetNavigatorManager.cpp +++ b/examples/tv-app/android/include/target-navigator/TargetNavigatorManager.cpp @@ -54,7 +54,7 @@ CHIP_ERROR TargetNavigatorManager::HandleGetTargetList(AttributeValueEncoder & a { 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()); + attrId.std::c_str()); if (value[attrId].isArray()) { return aEncoder.EncodeList([&](const auto & encoder) -> CHIP_ERROR { @@ -109,7 +109,7 @@ uint8_t TargetNavigatorManager::HandleGetCurrentTarget() chip::app::ConcreteReadAttributePath aPath(mEndpointId, chip::app::Clusters::TargetNavigator::Id, chip::app::Clusters::TargetNavigator::Attributes::TargetList::Id); std::string resStr = mAttributeDelegate->Read(aPath); - ChipLogProgress(Zcl, "TargetNavigatorManager::HandleGetCurrentTarget response %s", resStr.c_str()); + ChipLogProgress(Zcl, "TargetNavigatorManager::HandleGetCurrentTarget response %s", resStr.std::c_str()); if (resStr.length() != 0) { @@ -119,7 +119,7 @@ uint8_t TargetNavigatorManager::HandleGetCurrentTarget() { 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()); + attrId.std::c_str()); if (value[attrId].isUInt() && value[attrId].asUInt() < 256) { return static_cast(value[attrId].asUInt()); 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 bd5582efcf0c27..7c0dc950de1f4f 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 -using namespace std; using namespace chip; using namespace chip::app::Clusters::MediaInput; @@ -76,11 +75,11 @@ bool MediaInputManager::HandleShowInputStatus() 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(inputInfo.inputType), (mCurrentInput == inputInfo.index ? 1 : 0), name.c_str(), - desc.c_str()); + desc.std::c_str()); } return true; } 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 0e79c6b2a3e9a3..91159021842e75 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 -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 681cd56d6647fa..e0fbddbc170f9a 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 #include -using namespace std; using namespace chip; using namespace chip::app; using namespace chip::app::Clusters::Messages; @@ -34,7 +33,7 @@ CHIP_ERROR MessagesManager::HandlePresentMessagesRequest( const DataModel::Nullable & startTime, const DataModel::Nullable & duration, const CharSpan & messageText, const Optional> & responses) { - ChipLogProgress(Zcl, "HandlePresentMessagesRequest message:%s", std::string(messageText.data(), messageText.size()).c_str()); + ChipLogProgress(Zcl, "HandlePresentMessagesRequest message:%s", std::string(messageText.data(), messageText.size()).std::c_str()); auto cachedMessage = CachedMessage(messageId, priority, messageControl, startTime, duration, std::string(messageText.data(), messageText.size())); 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 dced0371fb9f39..03932528e57b0d 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 -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 a6010a54b0a0f5..8717354f22ff59 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 #include -using namespace std; using namespace chip; using namespace chip::app::Clusters::ContentAppObserver; @@ -35,11 +34,11 @@ void ContentAppObserverManager::HandleContentAppMessage(chip::app::CommandRespon { 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()); + encodingHintString.std::c_str(), dataString.std::c_str()); ContentAppMessageResponse response; // TODO: Insert code here 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 81d1f78fe1b33a..4dee3550f3e0bb 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 @@ namespace core { 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/resource-monitoring-server/resource-monitoring-server.cpp b/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp index 4447ad1cc0f210..6c581ff72a9e19 100644 --- a/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp +++ b/src/app/clusters/resource-monitoring-server/resource-monitoring-server.cpp @@ -34,7 +34,6 @@ #include #include -// using namespace std; using namespace chip::app; using namespace chip::app::Clusters; using namespace chip::app::Clusters::ResourceMonitoring; diff --git a/src/lib/support/SafeInt.h b/src/lib/support/SafeInt.h index ecf6d8721dcb1d..2835ef05534155 100644 --- a/src/lib/support/SafeInt.h +++ b/src/lib/support/SafeInt.h @@ -37,11 +37,10 @@ namespace chip { template ::value, int> = 0> bool CanCastTo(U arg) { - using namespace std; // U might be a reference to an integer type, if we're assigning from // something passed by reference. - typedef typename remove_reference::type V; // V for "value" - static_assert(is_integral::value, "Must be assigning from an integral type"); + typedef typename std::remove_reference::type V; // V for "value" + static_assert(std::is_integral::value, "Must be assigning from an integral type"); // We want to check that "arg" can fit inside T but without doing any tests // that are always true or always false due to the types involved, which @@ -64,44 +63,44 @@ bool CanCastTo(U arg) // of T and V is signed and the other is unsigned: there might not be a // single integer type that can represent _both_ the value of arg and the // minimal/maximal value. - if (numeric_limits::is_signed && numeric_limits::is_signed) + if (std::numeric_limits::is_signed && std::numeric_limits::is_signed) { - if (static_cast(numeric_limits::max()) <= static_cast(numeric_limits::max()) && - static_cast(numeric_limits::min()) >= static_cast(numeric_limits::min())) + if (static_cast(std::numeric_limits::max()) <= static_cast(std::numeric_limits::max()) && + static_cast(std::numeric_limits::min()) >= static_cast(std::numeric_limits::min())) { // Any checks on arg would be trivially true; don't even do them, to // avoid warnings. return true; } - return static_cast(numeric_limits::min()) <= static_cast(arg) && - static_cast(arg) <= static_cast(numeric_limits::max()); + return static_cast(std::numeric_limits::min()) <= static_cast(arg) && + static_cast(arg) <= static_cast(std::numeric_limits::max()); } - if (!numeric_limits::is_signed && !numeric_limits::is_signed) + if (!std::numeric_limits::is_signed && !std::numeric_limits::is_signed) { - if (static_cast(numeric_limits::max()) <= static_cast(numeric_limits::max())) + if (static_cast(std::numeric_limits::max()) <= static_cast(std::numeric_limits::max())) { // Any checks on arg would be trivially true; don't even do them, to // avoid warnings. return true; } - return static_cast(arg) <= static_cast(numeric_limits::max()); + return static_cast(arg) <= static_cast(std::numeric_limits::max()); } - if (numeric_limits::is_signed) + if (std::numeric_limits::is_signed) { - static_assert(numeric_limits::max() >= 0, "What weird type is this?"); - if (static_cast(numeric_limits::max()) <= static_cast(numeric_limits::max())) + static_assert(std::numeric_limits::max() >= 0, "What weird type is this?"); + if (static_cast(std::numeric_limits::max()) <= static_cast(std::numeric_limits::max())) { return true; } - return static_cast(arg) <= static_cast(numeric_limits::max()); + return static_cast(arg) <= static_cast(std::numeric_limits::max()); } - return 0 <= arg && static_cast(arg) <= static_cast(numeric_limits::max()); + return 0 <= arg && static_cast(arg) <= static_cast(std::numeric_limits::max()); } template ::value, int> = 0> @@ -127,10 +126,9 @@ bool CanCastTo(U arg) template typename std::enable_if::value, typename std::make_signed::type>::type CastToSigned(T arg) { - using namespace std; - typedef typename make_signed::type signed_type; + typedef typename std::make_signed::type signed_type; - if (arg <= static_cast(numeric_limits::max())) + if (arg <= static_cast(std::numeric_limits::max())) { return static_cast(arg); } @@ -142,7 +140,7 @@ typename std::enable_if::value, typename std::make_signed // // then noting that both (numeric_limits::max() - arg) and its negation // are guaranteed to fit in signed_type. - signed_type diff = static_cast(numeric_limits::max() - arg); + signed_type diff = static_cast(std::numeric_limits::max() - arg); return static_cast(-diff - 1); }