eitd: use check empty() instead of size() or length()

This commit is contained in:
Jacek Jendrzej
2015-01-01 19:02:41 +01:00
parent c89e35cbe1
commit 8e4af0b619
5 changed files with 23 additions and 23 deletions

View File

@@ -85,7 +85,7 @@ unsigned int getCountryIndex(const std::string &country)
{
unsigned int ix = 0;
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(countryMutex);
if (!countryVector.size()) {
if (countryVector.empty()) {
countryVector.push_back("DEU"); // 0
countryVector.push_back("FRA"); // 1
countryVector.push_back("ITA"); // 2
@@ -105,7 +105,7 @@ static std::map<std::string,unsigned int> componentMap;
void SIcomponent::setComponent(const std::string &component_description)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(componentMutex);
if (!componentVector.size()) {
if (componentVector.empty()) {
componentMap[""] = 0;
componentVector.push_back("");
}
@@ -483,7 +483,7 @@ char SIevent::getFSK() const
std::string SIevent::getName() const
{
if (CSectionsdClient::LANGUAGE_MODE_OFF == SIlanguage::getMode()) {
if (langData.size())
if (!langData.empty())
return langData.begin()->text[SILangData::langName];
return "";
} else {
@@ -521,7 +521,7 @@ void SIevent::setName(unsigned int lang, const std::string &name)
std::string SIevent::getText() const
{
if (CSectionsdClient::LANGUAGE_MODE_OFF == SIlanguage::getMode()) {
if (langData.size())
if (!langData.empty())
return langData.begin()->text[SILangData::langText];
return "";
}
@@ -555,7 +555,7 @@ void SIevent::setText(unsigned int lang, const std::string &text)
std::string SIevent::getExtendedText() const
{
if (CSectionsdClient::LANGUAGE_MODE_OFF == SIlanguage::getMode()) {
if (langData.size())
if (!langData.empty())
return langData.begin()->text[SILangData::langExtendedText];
return "";
}
@@ -618,33 +618,33 @@ int SIevent::saveXML0(FILE *file) const
int SIevent::saveXML2(FILE *file) const
{
for (std::list<SILangData>::const_iterator i = langData.begin(); i != langData.end(); ++i) {
if (i->text[SILangData::langName].length()) {
if (!i->text[SILangData::langName].empty()) {
fprintf(file, "\t\t\t<name lang=\"%s\" string=\"", langIndex[i->lang].c_str());
saveStringToXMLfile(file, i->text[SILangData::langName].c_str());
fprintf(file, "\"/>\n");
}
}
for (std::list<SILangData>::const_iterator i = langData.begin(); i != langData.end(); ++i) {
if (i->text[SILangData::langText].length()) {
if (!i->text[SILangData::langText].empty()) {
fprintf(file, "\t\t\t<text lang=\"%s\" string=\"", langIndex[i->lang].c_str());
saveStringToXMLfile(file, i->text[SILangData::langText].c_str());
fprintf(file, "\"/>\n");
}
}
#ifdef USE_ITEM_DESCRIPTION
if(item.length()) {
if(!item.empty()) {
fprintf(file, "\t\t\t<item string=\"");
saveStringToXMLfile(file, item.c_str());
fprintf(file, "\"/>\n");
}
if(itemDescription.length()) {
if(!itemDescription.empty()) {
fprintf(file, "\t\t\t<item_description string=\"");
saveStringToXMLfile(file, itemDescription.c_str());
fprintf(file, "\"/>\n");
}
#endif
for (std::list<SILangData>::const_iterator i = langData.begin(); i != langData.end(); ++i) {
if (i->text[SILangData::langExtendedText].length()) {
if (!i->text[SILangData::langExtendedText].empty()) {
fprintf(file, "\t\t\t<extended_text lang=\"%s\" string=\"", langIndex[i->lang].c_str());
saveStringToXMLfile(file, i->text[SILangData::langExtendedText].c_str());
fprintf(file, "\"/>\n");
@@ -674,9 +674,9 @@ void SIevent::dump(void) const
printf("Service-ID: %hu\n", service_id);
printf("Event-ID: %hu\n", eventID);
#ifdef USE_ITEM_DESCRIPTION
if(item.length())
if(!item.empty())
printf("Item: %s\n", item.c_str());
if(itemDescription.length())
if(!itemDescription.empty())
printf("Item-Description: %s\n", itemDescription.c_str());
#endif
for (std::list<SILangData>::const_iterator it = langData.begin(); it != langData.end(); ++it) {
@@ -687,13 +687,13 @@ void SIevent::dump(void) const
std::string contentClassification, userClassification;
classifications.get(contentClassification, userClassification);
if(contentClassification.length()) {
if(!contentClassification.empty()) {
printf("Content classification:");
for(unsigned i=0; i<contentClassification.length(); i++)
printf(" 0x%02hhx", contentClassification[i]);
printf("\n");
}
if(userClassification.length()) {
if(!userClassification.empty()) {
printf("User classification:");
for(unsigned i=0; i<userClassification.length(); i++)
printf(" 0x%02hhx", userClassification[i]);

View File

@@ -52,7 +52,7 @@ unsigned int getLangIndex(const std::string &lang)
{
unsigned int ix = 0;
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(langIndexMutex);
if (!langIndex.size())
if (langIndex.empty())
langIndex.push_back(languageOFF);
for (std::vector<std::string>::iterator it = langIndex.begin(); it != langIndex.end(); ++it, ++ix)
if (*it == lang)
@@ -101,7 +101,7 @@ void SIlanguage::filter(const std::list<SILangData>& s, SILangData::SILangDataIn
}
}
if (retval.length() == 0) {
if (retval.empty()) {
// return all available languages
if (s.begin() != s.end()) {
for (std::list<SILangData>::const_iterator it = s.begin() ;

View File

@@ -140,9 +140,9 @@ public:
printf("Service-ID: %hu\n", service_id);
printf("Service-Typ: %hhu\n", serviceTyp);
#if 0 // unused
if(providerName.length())
if(!providerName.empty())
printf("Provider-Name: %s\n", providerName.c_str());
if(serviceName.length())
if(!serviceName.empty())
printf("Service-Name: %s\n", serviceName.c_str());
#endif
for_each(nvods.begin(), nvods.end(), printSInvodReference());

View File

@@ -352,12 +352,12 @@ xprintf("addEvent: ch %012" PRIx64 " running %d (%s) got_CN %d\n", evt.get_chann
si->second->item = evt.item;
#endif
//si->second->vps = evt.vps;
if ((evt.getExtendedText().length() > 0) && !evt.times.empty() &&
if ((!evt.getExtendedText().empty()) && !evt.times.empty() &&
(evt.times.begin()->startzeit < zeit + secondsExtendedTextCache))
si->second->setExtendedText(0 /*"OFF"*/,evt.getExtendedText());
if (evt.getText().length() > 0)
if (!evt.getText().empty())
si->second->setText(0 /*"OFF"*/,evt.getText());
if (evt.getName().length() > 0)
if (!evt.getName().empty())
si->second->setName(0 /*"OFF"*/,evt.getName());
}
else {
@@ -2293,7 +2293,7 @@ void CEitManager::getEventsServiceKey(t_channel_id serviceUniqueKey, CChannelEve
// service Found
readLockEvents();
int serviceIDfound = 0;
if (search_text.length())
if (!search_text.empty())
std::transform(search_text.begin(), search_text.end(), search_text.begin(), tolower);
for (MySIeventsOrderServiceUniqueKeyFirstStartTimeEventUniqueKey::iterator e = mySIeventsOrderServiceUniqueKeyFirstStartTimeEventUniqueKey.begin(); e != mySIeventsOrderServiceUniqueKeyFirstStartTimeEventUniqueKey.end(); ++e)

View File

@@ -426,7 +426,7 @@ void *insertEventsfromFile(void * data)
node = node->xmlNextNode;
}
if (contentClassification.size()) {
if (!contentClassification.empty()) {
ssize_t off = e.classifications.reserve(2 * contentClassification.size());
if (off > -1)
for (unsigned i = 0; i < contentClassification.size(); i++)