From ac676d4d3cd4865989d246caaa35d8fc9dcd1327 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 21 May 2016 23:43:01 +0300 Subject: [PATCH] MD5: Use C++11 range-based for loop --- code/MD5Parser.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/code/MD5Parser.cpp b/code/MD5Parser.cpp index cf8d5a9f5..8badb84cc 100644 --- a/code/MD5Parser.cpp +++ b/code/MD5Parser.cpp @@ -193,13 +193,13 @@ bool MD5Parser::ParseSection(Section& out) // skip all spaces ... handle EOL correctly #define AI_MD5_SKIP_SPACES() if(!SkipSpaces(&sz)) \ - MD5Parser::ReportWarning("Unexpected end of line",(*eit).iLineNumber); + MD5Parser::ReportWarning("Unexpected end of line",elem.iLineNumber); // read a triple float in brackets: (1.0 1.0 1.0) #define AI_MD5_READ_TRIPLE(vec) \ AI_MD5_SKIP_SPACES(); \ if ('(' != *sz++) \ - MD5Parser::ReportWarning("Unexpected token: ( was expected",(*eit).iLineNumber); \ + MD5Parser::ReportWarning("Unexpected token: ( was expected",elem.iLineNumber); \ AI_MD5_SKIP_SPACES(); \ sz = fast_atoreal_move(sz,(float&)vec.x); \ AI_MD5_SKIP_SPACES(); \ @@ -208,7 +208,7 @@ bool MD5Parser::ParseSection(Section& out) sz = fast_atoreal_move(sz,(float&)vec.z); \ AI_MD5_SKIP_SPACES(); \ if (')' != *sz++) \ - MD5Parser::ReportWarning("Unexpected token: ) was expected",(*eit).iLineNumber); + MD5Parser::ReportWarning("Unexpected token: ) was expected",elem.iLineNumber); // parse a string, enclosed in quotation marks or not #define AI_MD5_PARSE_STRING(out) \ @@ -220,7 +220,7 @@ bool MD5Parser::ParseSection(Section& out) szStart++; \ if ('\"' != *(szEnd-=1)) { \ MD5Parser::ReportWarning("Expected closing quotation marks in string", \ - (*eit).iLineNumber); \ + elem.iLineNumber); \ continue; \ } \ } \ @@ -244,11 +244,11 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections) } else if ((*iter).mName == "joints") { // "origin" -1 ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000000 0.707107 ) - for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end();eit != eitEnd; ++eit){ + for (const auto & elem : (*iter).mElements){ mJoints.push_back(BoneDesc()); BoneDesc& desc = mJoints.back(); - const char* sz = (*eit).szStart; + const char* sz = elem.szStart; AI_MD5_PARSE_STRING(desc.mName); AI_MD5_SKIP_SPACES(); @@ -263,8 +263,8 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections) mMeshes.push_back(MeshDesc()); MeshDesc& desc = mMeshes.back(); - for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end();eit != eitEnd; ++eit){ - const char* sz = (*eit).szStart; + for (const auto & elem : (*iter).mElements){ + const char* sz = elem.szStart; // shader attribute if (TokenMatch(sz,"shader",6)) { @@ -297,14 +297,14 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections) VertexDesc& vert = desc.mVertices[idx]; if ('(' != *sz++) - MD5Parser::ReportWarning("Unexpected token: ( was expected",(*eit).iLineNumber); + MD5Parser::ReportWarning("Unexpected token: ( was expected",elem.iLineNumber); AI_MD5_SKIP_SPACES(); sz = fast_atoreal_move(sz,(float&)vert.mUV.x); AI_MD5_SKIP_SPACES(); sz = fast_atoreal_move(sz,(float&)vert.mUV.y); AI_MD5_SKIP_SPACES(); if (')' != *sz++) - MD5Parser::ReportWarning("Unexpected token: ) was expected",(*eit).iLineNumber); + MD5Parser::ReportWarning("Unexpected token: ) was expected",elem.iLineNumber); AI_MD5_SKIP_SPACES(); vert.mFirstWeight = ::strtoul10(sz,&sz); AI_MD5_SKIP_SPACES(); @@ -357,11 +357,11 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections) for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end();iter != iterEnd;++iter) { if ((*iter).mName == "hierarchy") { // "sheath" 0 63 6 - for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end();eit != eitEnd; ++eit) { + for (const auto & elem : (*iter).mElements) { mAnimatedBones.push_back ( AnimBoneDesc () ); AnimBoneDesc& desc = mAnimatedBones.back(); - const char* sz = (*eit).szStart; + const char* sz = elem.szStart; AI_MD5_PARSE_STRING(desc.mName); AI_MD5_SKIP_SPACES(); @@ -371,7 +371,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections) // flags (highest is 2^6-1) AI_MD5_SKIP_SPACES(); if(63 < (desc.iFlags = ::strtoul10(sz,&sz))){ - MD5Parser::ReportWarning("Invalid flag combination in hierarchy section",(*eit).iLineNumber); + MD5Parser::ReportWarning("Invalid flag combination in hierarchy section",elem.iLineNumber); } AI_MD5_SKIP_SPACES(); @@ -381,8 +381,8 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections) } else if((*iter).mName == "baseframe") { // ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000242 0.707107 ) - for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit) { - const char* sz = (*eit).szStart; + for (const auto & elem : (*iter).mElements) { + const char* sz = elem.szStart; mBaseFrames.push_back ( BaseFrameDesc () ); BaseFrameDesc& desc = mBaseFrames.back(); @@ -407,8 +407,8 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections) } // now read all elements (continuous list of floats) - for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit){ - const char* sz = (*eit).szStart; + for (const auto & elem : (*iter).mElements){ + const char* sz = elem.szStart; while (SkipSpacesAndLineEnd(&sz)) { float f;sz = fast_atoreal_move(sz,f); desc.mValues.push_back(f); @@ -455,13 +455,13 @@ MD5CameraParser::MD5CameraParser(SectionList& mSections) cuts.reserve(strtoul10((*iter).mGlobalValue.c_str())); } else if ((*iter).mName == "cuts") { - for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit){ - cuts.push_back(strtoul10((*eit).szStart)+1); + for (const auto & elem : (*iter).mElements){ + cuts.push_back(strtoul10(elem.szStart)+1); } } else if ((*iter).mName == "camera") { - for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit){ - const char* sz = (*eit).szStart; + for (const auto & elem : (*iter).mElements){ + const char* sz = elem.szStart; frames.push_back(CameraAnimFrameDesc()); CameraAnimFrameDesc& cur = frames.back();