Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 21, 2015, 7:05:53 PM (10 years ago)
Author:
muemart
Message:

Run clang-modernize -loop-convert

  • Again, not all possible loops were converted
  • It can do pretty cool transformations, but I had to fix a few compile errors, so there might be some runtime errors lurking around too
Location:
code/branches/cpp11_v2/src/libraries/core/config
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/core/config/ConfigFile.cc

    r10817 r10821  
    234234        }
    235235
    236         for (std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
    237         {
    238             file << (*it)->getFileEntry() << endl;
    239 
    240             for (std::list<ConfigFileEntry*>::const_iterator it_entries = (*it)->getEntriesBegin(); it_entries != (*it)->getEntriesEnd(); ++it_entries)
     236        for (const auto & elem : this->sections_)
     237        {
     238            file << (elem)->getFileEntry() << endl;
     239
     240            for (std::list<ConfigFileEntry*>::const_iterator it_entries = (elem)->getEntriesBegin(); it_entries != (elem)->getEntriesEnd(); ++it_entries)
    241241                file << (*it_entries)->getFileEntry() << endl;
    242242
     
    280280    ConfigFileSection* ConfigFile::getSection(const std::string& section) const
    281281    {
    282         for (std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
    283             if ((*it)->getName() == section)
    284                 return (*it);
     282        for (const auto & elem : this->sections_)
     283            if ((elem)->getName() == section)
     284                return (elem);
    285285        return nullptr;
    286286    }
     
    291291    ConfigFileSection* ConfigFile::getOrCreateSection(const std::string& section)
    292292    {
    293         for (std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
    294             if ((*it)->getName() == section)
    295                 return (*it);
     293        for (auto & elem : this->sections_)
     294            if ((elem)->getName() == section)
     295                return (elem);
    296296
    297297        this->bUpdated_ = true;
     
    307307        bool sectionsUpdated = false;
    308308
    309         for (std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
    310         {
    311             if ((*it)->bUpdated_)
     309        for (auto & elem : this->sections_)
     310        {
     311            if ((elem)->bUpdated_)
    312312            {
    313313                sectionsUpdated = true;
    314                 (*it)->bUpdated_ = false;
     314                (elem)->bUpdated_ = false;
    315315            }
    316316        }
  • code/branches/cpp11_v2/src/libraries/core/config/ConfigFileManager.cc

    r10776 r10821  
    5353    ConfigFileManager::~ConfigFileManager()
    5454    {
    55         for (std::array<ConfigFile*, 3>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
    56             if (*it)
    57                 delete (*it);
     55        for (const auto & elem : this->configFiles_)
     56            if (elem)
     57                delete (elem);
    5858    }
    5959
  • code/branches/cpp11_v2/src/libraries/core/config/ConfigFileSection.cc

    r10765 r10821  
    8080    {
    8181        unsigned int size = 0;
    82         for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
    83             if ((*it)->getName() == name)
    84                 if ((*it)->getIndex() >= size)
    85                     size = (*it)->getIndex() + 1;
     82        for (const auto & elem : this->entries_)
     83            if ((elem)->getName() == name)
     84                if ((elem)->getIndex() >= size)
     85                    size = (elem)->getIndex() + 1;
    8686        return size;
    8787    }
     
    105105    ConfigFileEntry* ConfigFileSection::getEntry(const std::string& name) const
    106106    {
    107         for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
     107        for (const auto & elem : this->entries_)
    108108        {
    109             if ((*it)->getName() == name)
    110                 return *it;
     109            if ((elem)->getName() == name)
     110                return elem;
    111111        }
    112112        return nullptr;
     
    121121    ConfigFileEntry* ConfigFileSection::getEntry(const std::string& name, unsigned int index) const
    122122    {
    123         for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
     123        for (const auto & elem : this->entries_)
    124124        {
    125             if (((*it)->getName() == name) && ((*it)->getIndex() == index))
    126                 return *it;
     125            if (((elem)->getName() == name) && ((elem)->getIndex() == index))
     126                return elem;
    127127        }
    128128        return nullptr;
  • code/branches/cpp11_v2/src/libraries/core/config/ConfigValueContainer.h

    r10817 r10821  
    130130
    131131                this->value_ = V();
    132                 for (unsigned int i = 0; i < defvalue.size(); i++)
    133                     this->valueVector_.push_back(MultiType(defvalue[i]));
     132                for (auto & elem : defvalue)
     133                    this->valueVector_.push_back(MultiType(elem));
    134134
    135135                this->initVector();
     
    183183                    std::vector<T> temp = *value;
    184184                    value->clear();
    185                     for (unsigned int i = 0; i < this->valueVector_.size(); ++i)
    186                         value->push_back(this->valueVector_[i]);
     185                    for (auto & elem : this->valueVector_)
     186                        value->push_back(elem);
    187187
    188188                    if (value->size() != temp.size())
     
    211211                {
    212212                    value->clear();
    213                     for (unsigned int i = 0; i < this->valueVector_.size(); ++i)
    214                         value->push_back(this->valueVector_[i]);
     213                    for (auto & elem : this->valueVector_)
     214                        value->push_back(elem);
    215215                }
    216216                return *this;
Note: See TracChangeset for help on using the changeset viewer.