Library::getBooksCategories()

Note: no unit test added
This commit is contained in:
Veloman Yunkan 2021-04-17 00:32:04 +04:00
parent 3c3cf08a1a
commit b259afa408
2 changed files with 23 additions and 1 deletions

View File

@ -233,12 +233,19 @@ class Library
unsigned int getBookCount(const bool localBooks, const bool remoteBooks) const; unsigned int getBookCount(const bool localBooks, const bool remoteBooks) const;
/** /**
* Get all langagues of the books in the library. * Get all languagues of the books in the library.
* *
* @return A list of languages. * @return A list of languages.
*/ */
std::vector<std::string> getBooksLanguages() const; std::vector<std::string> getBooksLanguages() const;
/**
* Get all categories of the books in the library.
*
* @return A list of categories.
*/
std::vector<std::string> getBooksCategories() const;
/** /**
* Get all book creators of the books in the library. * Get all book creators of the books in the library.
* *

View File

@ -201,6 +201,21 @@ std::vector<std::string> Library::getBooksLanguages() const
return booksLanguages; return booksLanguages;
} }
std::vector<std::string> Library::getBooksCategories() const
{
std::set<std::string> categories;
for (const auto& pair: m_books) {
const auto& book = pair.second;
const auto& c = book.getCategory();
if ( !c.empty() ) {
categories.insert(c);
}
}
return std::vector<std::string>(categories.begin(), categories.end());
}
std::vector<std::string> Library::getBooksCreators() const std::vector<std::string> Library::getBooksCreators() const
{ {
std::vector<std::string> booksCreators; std::vector<std::string> booksCreators;