libsaria: Save tracks using for_each_item()
It's simpler than custom writing my own for each loop... Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
bd8cdee041
commit
065feedee2
|
@ -52,7 +52,7 @@ namespace libsaria
|
|||
Track(ifstream &, library::Path *, unsigned int);
|
||||
~Track();
|
||||
|
||||
void save(ofstream &);
|
||||
void save(ofstream *);
|
||||
void load_unlisted(bool);
|
||||
void load(bool);
|
||||
void add_playlist(libsaria::Playlist *);
|
||||
|
|
|
@ -23,6 +23,11 @@ static string id_to_filename(unsigned int id)
|
|||
return s.str();
|
||||
}
|
||||
|
||||
static void save_track(libsaria::Track &track, void *data)
|
||||
{
|
||||
track.save((ofstream *)data);
|
||||
}
|
||||
|
||||
static void do_save_path(ofstream &stream, void *data)
|
||||
{
|
||||
libsaria::library::Path *path = (libsaria::library::Path *)data;
|
||||
|
@ -34,8 +39,7 @@ static void do_save_path(ofstream &stream, void *data)
|
|||
stream << path->id << " " << path->visible << " ";
|
||||
stream << path->next_track << " " << path->_tracks.size() << "\n";
|
||||
|
||||
for (it = path->tracks.begin(); it != path->tracks.end(); it++)
|
||||
(*it).save(stream);
|
||||
path->_tracks.for_each_item(save_track, &stream);
|
||||
}
|
||||
|
||||
void libsaria::library::save_path(libsaria::library::Path *path)
|
||||
|
|
|
@ -197,27 +197,27 @@ namespace libsaria
|
|||
return cur;
|
||||
}
|
||||
|
||||
void Track::save(ofstream &out)
|
||||
void Track::save(ofstream *out)
|
||||
{
|
||||
out << filepath << "\n";
|
||||
out << title << "\n";
|
||||
out << artist << "\n";
|
||||
out << album << "\n";
|
||||
out << comment << "\n";
|
||||
out << genre << "\n";
|
||||
out << lenstr << "\n";
|
||||
out << id << " ";
|
||||
out << year << " ";
|
||||
out << track << " ";
|
||||
out << count << " ";
|
||||
out << last_day << " ";
|
||||
out << last_month << " ";
|
||||
out << last_year << " ";
|
||||
out << length << " ";
|
||||
out << bitrate << " ";
|
||||
out << sample << " ";
|
||||
out << channels << " ";
|
||||
out << banned << "\n";
|
||||
*out << filepath << "\n";
|
||||
*out << title << "\n";
|
||||
*out << artist << "\n";
|
||||
*out << album << "\n";
|
||||
*out << comment << "\n";
|
||||
*out << genre << "\n";
|
||||
*out << lenstr << "\n";
|
||||
*out << id << " ";
|
||||
*out << year << " ";
|
||||
*out << track << " ";
|
||||
*out << count << " ";
|
||||
*out << last_day << " ";
|
||||
*out << last_month << " ";
|
||||
*out << last_year << " ";
|
||||
*out << length << " ";
|
||||
*out << bitrate << " ";
|
||||
*out << sample << " ";
|
||||
*out << channels << " ";
|
||||
*out << banned << "\n";
|
||||
}
|
||||
|
||||
void Track::add_playlist(Playlist *plist)
|
||||
|
|
Loading…
Reference in New Issue