Changed some more code from C to C++

This commit is contained in:
Leon Styhre 2020-12-17 20:43:52 +01:00
parent b86e8ad6e2
commit bddc87bbcc
4 changed files with 19 additions and 14 deletions

View file

@ -289,7 +289,7 @@ bool SystemData::loadConfig()
std::vector<std::string> platformStrs = readList(platformList);
std::vector<PlatformIds::PlatformId> platformIds;
for (auto it = platformStrs.cbegin(); it != platformStrs.cend(); it++) {
std::string str = it->c_str();
std::string str = *it;
PlatformIds::PlatformId platformId = PlatformIds::getPlatformId(str);
if (platformId == PlatformIds::PLATFORM_IGNORE) {

View file

@ -95,7 +95,6 @@ void CECInput::deinit()
CECInput::CECInput() : mlibCEC(nullptr)
{
#if defined(HAVE_LIBCEC)
#if defined(_RPI_)
// Restart vchi tv and CEC in case we just came back from another app using CEC (like Kodi).

View file

@ -76,16 +76,20 @@ std::string DateTimeComponent::getDisplayString() const
Utils::Time::DateTime now(Utils::Time::now());
Utils::Time::Duration dur(now.getTime() - mTime.getTime());
char buf[64];
std::string buf;
if (dur.getDays() > 0)
sprintf(buf, "%d day%s ago", dur.getDays(), (dur.getDays() > 1) ? "s" : "");
buf = std::to_string(dur.getDays()) + " day" +
(dur.getDays() > 1 ? "s" : "") + " ago";
else if (dur.getHours() > 0)
sprintf(buf, "%d hour%s ago", dur.getHours(), (dur.getHours() > 1) ? "s" : "");
buf = std::to_string(dur.getHours()) + " hour" +
(dur.getHours() > 1 ? "s" : "") + " ago";
else if (dur.getMinutes() > 0)
sprintf(buf, "%d minute%s ago", dur.getMinutes(), (dur.getMinutes() > 1) ? "s" : "");
buf = std::to_string(dur.getMinutes()) + " minute" +
(dur.getMinutes() > 1 ? "s" : "") + " ago";
else
sprintf(buf, "%d second%s ago", dur.getSeconds(), (dur.getSeconds() > 1) ? "s" : "");
buf = std::to_string(dur.getSeconds()) + " second" +
(dur.getSeconds() > 1 || dur.getSeconds() == 0 ? "s" : "") + " ago";
return std::string(buf);
}

View file

@ -231,18 +231,20 @@ std::string DateTimeEditComponent::getDisplayString(DisplayMode mode) const
Utils::Time::DateTime now(Utils::Time::now());
Utils::Time::Duration dur(now.getTime() - mTime.getTime());
char buf[64];
std::string buf;
if (dur.getDays() > 0)
sprintf(buf, "%d day%s ago", dur.getDays(), (dur.getDays() > 1) ? "s" : "");
buf = std::to_string(dur.getDays()) + " day" +
(dur.getDays() > 1 ? "s" : "") + " ago";
else if (dur.getHours() > 0)
sprintf(buf, "%d hour%s ago", dur.getHours(), (dur.getHours() > 1) ? "s" : "");
buf = std::to_string(dur.getHours()) + " hour" +
(dur.getHours() > 1 ? "s" : "") + " ago";
else if (dur.getMinutes() > 0)
sprintf(buf, "%d minute%s ago", dur.getMinutes(),
(dur.getMinutes() > 1) ? "s" : "");
buf = std::to_string(dur.getMinutes()) + " minute" +
(dur.getMinutes() > 1 ? "s" : "") + " ago";
else
sprintf(buf, "%d second%s ago", dur.getSeconds(),
(dur.getSeconds() > 1) ? "s" : "");
buf = std::to_string(dur.getSeconds()) + " second" +
(dur.getSeconds() > 1 || dur.getSeconds() == 0 ? "s" : "") + " ago";
return std::string(buf);
}