Skip to content

Commit

Permalink
Found some more files were using namespace std
Browse files Browse the repository at this point in the history
  • Loading branch information
jadhavrohit924 committed Sep 24, 2024
1 parent e9ac903 commit e1fa3be
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() };
}
Expand Down Expand Up @@ -127,10 +127,10 @@ bool AccountLoginManager::HandleLogout(const chip::Optional<chip::NodeId> & node
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);
ChipLogProgress(Zcl, "temporary account id: %s returning pin: %s", tempAccountIdentifierString.std::c_str(), mSetupPin);

response.setupPIN = CharSpan::fromCharString(mSetupPin);
helper.Success(response);
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using namespace chip::app::Clusters::ContentLauncher;
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;
Expand All @@ -45,7 +45,7 @@ void AppContentLauncherManager::HandleLaunchContent(CommandResponseHelper<Launch
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"));

Expand Down Expand Up @@ -75,8 +75,8 @@ void AppContentLauncherManager::HandleLaunchUrl(CommandResponseHelper<LaunchResp
{
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;
Expand All @@ -91,7 +91,7 @@ CHIP_ERROR AppContentLauncherManager::HandleGetAcceptHeaderList(AttributeValueEn
chip::app::ConcreteReadAttributePath aPath(mEndpointId, chip::app::Clusters::ContentLauncher::Id,
chip::app::Clusters::ContentLauncher::Attributes::AcceptHeader::Id);
std::string resStr = mAttributeDelegate->Read(aPath);
ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetAcceptHeaderList response %s", resStr.c_str());
ChipLogProgress(Zcl, "AppContentLauncherManager::HandleGetAcceptHeaderList response %s", resStr.std::c_str());

if (resStr.length() != 0)
{
Expand All @@ -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();
Expand Down Expand Up @@ -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)
{
Expand All @@ -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<uint32_t>(value[attrId].asInt());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint64_t>::max();
if (resStr.length() != 0)
Expand All @@ -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<uint64_t>(value[attrId].asUInt());
Expand Down Expand Up @@ -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)
{
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
{
Expand All @@ -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<uint8_t>(value[attrId].asUInt());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include <string>

using namespace std;
using namespace chip;
using namespace chip::app::Clusters::MediaInput;

Expand Down Expand Up @@ -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<uint16_t>(inputInfo.inputType), (mCurrentInput == inputInfo.index ? 1 : 0), name.c_str(),
desc.c_str());
desc.std::c_str());
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include <string>

using namespace std;
using namespace chip::app::DataModel;
using namespace chip::app::Clusters::MediaPlayback;
using namespace chip::Uint8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <string>
#include <vector>

using namespace std;
using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters::Messages;
Expand All @@ -34,7 +33,7 @@ CHIP_ERROR MessagesManager::HandlePresentMessagesRequest(
const DataModel::Nullable<uint32_t> & startTime, const DataModel::Nullable<uint64_t> & duration, const CharSpan & messageText,
const Optional<DataModel::DecodableList<MessageResponseOption>> & 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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include <string>

using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters::TargetNavigator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <lib/support/TypeTraits.h>
#include <protocols/interaction_model/StatusCode.h>

// using namespace std;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ResourceMonitoring;
Expand Down
38 changes: 18 additions & 20 deletions src/lib/support/SafeInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ namespace chip {
template <typename T, typename U, std::enable_if_t<std::is_integral<T>::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<U>::type V; // V for "value"
static_assert(is_integral<V>::value, "Must be assigning from an integral type");
typedef typename std::remove_reference<U>::type V; // V for "value"
static_assert(std::is_integral<V>::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
Expand All @@ -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<T>::is_signed && numeric_limits<V>::is_signed)
if (std::numeric_limits<T>::is_signed && std::numeric_limits<V>::is_signed)
{
if (static_cast<intmax_t>(numeric_limits<V>::max()) <= static_cast<intmax_t>(numeric_limits<T>::max()) &&
static_cast<intmax_t>(numeric_limits<V>::min()) >= static_cast<intmax_t>(numeric_limits<T>::min()))
if (static_cast<intmax_t>(std::numeric_limits<V>::max()) <= static_cast<intmax_t>(std::numeric_limits<T>::max()) &&
static_cast<intmax_t>(std::numeric_limits<V>::min()) >= static_cast<intmax_t>(std::numeric_limits<T>::min()))
{
// Any checks on arg would be trivially true; don't even do them, to
// avoid warnings.
return true;
}

return static_cast<intmax_t>(numeric_limits<T>::min()) <= static_cast<intmax_t>(arg) &&
static_cast<intmax_t>(arg) <= static_cast<intmax_t>(numeric_limits<T>::max());
return static_cast<intmax_t>(std::numeric_limits<T>::min()) <= static_cast<intmax_t>(arg) &&
static_cast<intmax_t>(arg) <= static_cast<intmax_t>(std::numeric_limits<T>::max());
}

if (!numeric_limits<T>::is_signed && !numeric_limits<V>::is_signed)
if (!std::numeric_limits<T>::is_signed && !std::numeric_limits<V>::is_signed)
{
if (static_cast<uintmax_t>(numeric_limits<V>::max()) <= static_cast<uintmax_t>(numeric_limits<T>::max()))
if (static_cast<uintmax_t>(std::numeric_limits<V>::max()) <= static_cast<uintmax_t>(std::numeric_limits<T>::max()))
{
// Any checks on arg would be trivially true; don't even do them, to
// avoid warnings.
return true;
}

return static_cast<uintmax_t>(arg) <= static_cast<uintmax_t>(numeric_limits<T>::max());
return static_cast<uintmax_t>(arg) <= static_cast<uintmax_t>(std::numeric_limits<T>::max());
}

if (numeric_limits<T>::is_signed)
if (std::numeric_limits<T>::is_signed)
{
static_assert(numeric_limits<T>::max() >= 0, "What weird type is this?");
if (static_cast<uintmax_t>(numeric_limits<V>::max()) <= static_cast<uintmax_t>(numeric_limits<T>::max()))
static_assert(std::numeric_limits<T>::max() >= 0, "What weird type is this?");
if (static_cast<uintmax_t>(std::numeric_limits<V>::max()) <= static_cast<uintmax_t>(std::numeric_limits<T>::max()))
{
return true;
}

return static_cast<uintmax_t>(arg) <= static_cast<uintmax_t>(numeric_limits<T>::max());
return static_cast<uintmax_t>(arg) <= static_cast<uintmax_t>(std::numeric_limits<T>::max());
}

return 0 <= arg && static_cast<uintmax_t>(arg) <= static_cast<uintmax_t>(numeric_limits<T>::max());
return 0 <= arg && static_cast<uintmax_t>(arg) <= static_cast<uintmax_t>(std::numeric_limits<T>::max());
}

template <typename T, typename U, std::enable_if_t<std::is_enum<T>::value, int> = 0>
Expand All @@ -127,10 +126,9 @@ bool CanCastTo(U arg)
template <typename T>
typename std::enable_if<std::is_unsigned<T>::value, typename std::make_signed<T>::type>::type CastToSigned(T arg)
{
using namespace std;
typedef typename make_signed<T>::type signed_type;
typedef typename std::make_signed<T>::type signed_type;

if (arg <= static_cast<T>(numeric_limits<signed_type>::max()))
if (arg <= static_cast<T>(std::numeric_limits<signed_type>::max()))
{
return static_cast<signed_type>(arg);
}
Expand All @@ -142,7 +140,7 @@ typename std::enable_if<std::is_unsigned<T>::value, typename std::make_signed<T>
//
// then noting that both (numeric_limits<T>::max() - arg) and its negation
// are guaranteed to fit in signed_type.
signed_type diff = static_cast<signed_type>(numeric_limits<T>::max() - arg);
signed_type diff = static_cast<signed_type>(std::numeric_limits<T>::max() - arg);
return static_cast<signed_type>(-diff - 1);
}

Expand Down

0 comments on commit e1fa3be

Please sign in to comment.