////////////////////////////////////////////////////////////////////////// ParseObjectList //////////////////////////////////////////////////////////////////////////
| 1007 | // ParseObjectList |
| 1008 | /////////////////////////////////////////////////////////////////////////////// |
| 1009 | void cTWUtil::ParseObjectList(cTWUtil::GenreObjList& listOut, const cTWUtil::ObjList& listIn) |
| 1010 | { |
| 1011 | |
| 1012 | cGenre::Genre curGenre = cGenreSwitcher::GetInstance()->GetDefaultGenre(); |
| 1013 | |
| 1014 | ASSERT(listIn.size() > 0); |
| 1015 | listOut.clear(); |
| 1016 | GenreObjList::iterator curIter = listOut.end(); |
| 1017 | cGenre::Genre iterGenre = cGenre::GENRE_INVALID; |
| 1018 | |
| 1019 | // iterate over all of the input... |
| 1020 | // |
| 1021 | for (ObjList::const_iterator i = listIn.begin(); i != listIn.end(); ++i) |
| 1022 | { |
| 1023 | // first, try to interperate the current string as a genre name... |
| 1024 | // 17 Mar 99 mdb -- we now only do this if the string ends in a ':' |
| 1025 | // |
| 1026 | cGenre::Genre g = cGenre::GENRE_INVALID; |
| 1027 | |
| 1028 | if (i->at(i->length() - 1) == _T(':')) |
| 1029 | { |
| 1030 | TSTRING genreStr; |
| 1031 | genreStr.assign(i->begin(), i->end() - 1); |
| 1032 | g = cGenreSwitcher::GetInstance()->StringToGenre(genreStr.c_str()); |
| 1033 | |
| 1034 | // |
| 1035 | // if it is not a valid genre name, then test to see if it could |
| 1036 | // be an fconame. If it is not, then it is a badly formed genre. |
| 1037 | // |
| 1038 | if (g == cGenre::GENRE_INVALID) |
| 1039 | { |
| 1040 | TW_UNIQUE_PTR<iParserGenreUtil> pParseUtil(iTWFactory::GetInstance()->CreateParserGenreUtil()); |
| 1041 | if (!pParseUtil->IsAbsolutePath(*i)) |
| 1042 | throw eTWUnknownSectionName(*i); |
| 1043 | } |
| 1044 | } |
| 1045 | if (g == cGenre::GENRE_INVALID) |
| 1046 | { |
| 1047 | // assume that we are in the correct genre; this is a fully qualified object name |
| 1048 | // TODO -- throw here if cGenreParserHelper says it isn't a fully qualified name. |
| 1049 | // |
| 1050 | if (iterGenre != curGenre) |
| 1051 | { |
| 1052 | // seek to right list; create it if it is not there... |
| 1053 | // |
| 1054 | for (curIter = listOut.begin(); curIter != listOut.end(); ++curIter) |
| 1055 | { |
| 1056 | if (curIter->first == curGenre) |
| 1057 | break; |
| 1058 | } |
| 1059 | if (curIter == listOut.end()) |
| 1060 | { |
| 1061 | // it doesn't exist; we will have to create a new one. |
| 1062 | // |
| 1063 | listOut.push_back(GenreObjs()); |
| 1064 | listOut.back().first = curGenre; |
| 1065 | curIter = listOut.end() - 1; |
| 1066 | } |
nothing calls this directly
no test coverage detected