Represents a hierarchical tree structure to store songs by artist, album, disc number, and track number.
More...
|
void | addSong (const Song &song) |
| Adds a song to the tree.
|
|
void | display () const |
| Displays all songs in the tree hierarchically.
|
|
void | printAllArtists () const |
| Prints all the artists in the song tree.
|
|
void | printSongs (const std::vector< Song > &songs) |
| Prints the songs by album.
|
|
auto | getSongsByArtist (const std::string &artist) |
| Retrieves all songs by a specific artist.
|
|
auto | getSongsByAlbum (const std::string &artist, const std::string &album) const |
| Retrieves all songs from a specific album by a given artist.
|
|
void | getSongsByGenreAndPrint () const |
| Groups and prints songs by genre.
|
|
auto | returnSongMap () const |
| Returns the internal song map.
|
|
template<class Archive> |
void | serialize (Archive &ar) |
| Serializes the SongTree object.
|
|
void | saveToFile (const std::string &filename) const |
| Saves the SongTree to a file.
|
|
void | loadFromFile (const std::string &filename) |
| Loads a SongTree from a file.
|
|
void | printSongInfo (const std::string &input) |
| Prints metadata and additional properties of a song.
|
|
Represents a hierarchical tree structure to store songs by artist, album, disc number, and track number.
The SongTree
class organizes songs in a nested map structure, allowing for efficient storage and retrieval of songs based on artist, album, disc, and track numbers. It supports the addition, display, and serialization of songs, and provides methods for querying songs by specific criteria such as artist, album, and genre.
Songs are added to the tree via the addSong
method, and the tree can be serialized and deserialized to a file using the Cereal library.
void SongTree::display |
( |
| ) |
const |
|
inline |
Displays all songs in the tree hierarchically.
This method prints the entire song tree to the console, organized by artist, album, disc number, and track number. It also provides a summary of the library, including the total number of artists, albums, discs, songs, and unique genres.
void SongTree::printSongInfo |
( |
const std::string & | input | ) |
|
|
inline |
Prints metadata and additional properties of a song.
This function retrieves a song based on either a file path or a song name and prints all relevant metadata, including title, artist, album, genre, track number, disc number, and inode.
- Parameters
-
input | The file path or song name to search for. |