#include #include #include #include #include #include #include #include namespace book_store::product { using namespace consumer; auto book::title() const noexcept -> std::string_view { return this->_title; } auto book::authors() const noexcept -> std::vector { return this->_authors; } auto book::publisher() const noexcept -> std::string_view { return this->_publisher; } auto book::isbn() const noexcept -> std::string_view { return this->_isbn; } auto book::price_usd() const noexcept -> price::usd { return this->_price_usd; } auto book::copies() const noexcept -> book::size_type { return this->_copies; } auto book::title(std::string_view title) noexcept -> book & { this->_title = title; return *this; } auto book::authors(std::vector authors) -> book & { this->_authors = std::move(authors); return *this; } auto book::author(const class person &author) -> book & { while (this->_authors.size() < 4) { this->_authors.emplace_back(author); break; } return *this; } auto book::remove_author_by_id(std::size_t author_id) -> book & { this->_authors.erase( this->_authors.begin() + static_cast::difference_type>(author_id)); return *this; } auto book::publisher(std::string_view publisher) noexcept -> book & { this->_publisher = publisher; return *this; } auto book::isbn(std::string_view isbn) noexcept -> book & { this->_isbn = isbn; return *this; } auto book::price_usd(price::usd price) noexcept -> book & { this->_price_usd = price; return *this; } auto book::copies(book::size_type copies) noexcept -> book & { this->_copies = copies; return *this; } auto operator<<(std::ostream &output_stream, const book &book) -> std::ostream & { output_stream << "Title: " << book._title << '\n'; output_stream << "Authors: "; for (const auto &author : book._authors) { output_stream << author.full_name() << ((&author == &book._authors.back()) ? "" : ", "); } output_stream << '\n'; output_stream << "Publisher: " << book._publisher << '\n'; output_stream << "ISBN: " << book._isbn << '\n'; output_stream << "Price: $" << book._price_usd << '\n'; output_stream << "Copies: " << book._copies << '\n'; return output_stream; } } // namespace book_store::product