本文整理汇总了C++中SongList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ SongList::push_back方法的具体用法?C++ SongList::push_back怎么用?C++ SongList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SongList
的用法示例。
在下文中一共展示了SongList::push_back方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: instream
/**
* @brief builds a vector of all the diffrent kinds of songs given
* @param songDataFile - the name of the song data file
* @return a vector of the songs
*/
std::vector<RankableSong*> Parser::buildSongDataBase(const std::string &songDataFile)
{
std::ifstream instream(songDataFile.c_str());
std::string line = "";
int lastSong = 0;
SongList songList;
while (instream.good() && !lastSong)
{
if (line.compare(SEPARATOR) != 0)
{
getline(instream, line);
// Expect a line of "="
if (END_OF_SONGS.compare(line) == 0)
{
lastSong = 1;
break;
}
}
getline(instream, line);
// Expect a line of "title: ..."
size_t pos = TITLE.size() + 2;
std::string title = line.substr(pos);
getline(instream, line);
// Expect a line of "tags: {...}"
std::string tags = _getWordList(line);
std::string lyrics = "";
std::string lyricsBy = "";
std::string instruments = "";
std::string performedBy = "";
std::string bpmStr = "0";
getline(instream, line);
// Expect either lyrics or instruments.
if (line.substr(0, LYRICS.size()).compare(LYRICS) == 0)
{
// Then we have a lyric song
// Lets get the lyrics:
lyrics = _getWordList(line);
// Lets get the lyricsBy:
getline(instream, line);
pos = LYRICS_BY.size() + 2;
lyricsBy = line.substr(pos);
// insert to dataBase
songList.push_back(new RankableLyricSong(title, tags, lyrics, lyricsBy));
}
else
{
// Then we have an instrumental song
// Lets get the instruments:
instruments = _getWordList(line);
// Lets get the performedBy:
getline(instream, line);
pos = PERFORMED_BY.size() + 2;
performedBy = line.substr(pos);
// Lets see if we have bpm:
if (!instream.good())
{
break;
}
getline(instream, line);
if (END_OF_SONGS.compare(line) == 0)
{
lastSong = 1;
}
if (line.substr(0, BPM.size()).compare(BPM) == 0)
{
pos = BPM.size() + 2;
bpmStr = line.substr(pos);
}
else
{
assert((line.compare(SEPARATOR) == 0) || (line.compare(END_OF_SONGS) == 0));
}
songList.push_back(new RankableInstrumentalSong(title, tags, instruments, performedBy, bpmStr));
}
}
instream.close();
return songList;
//.........这里部分代码省略.........