From b2e70a6faa58407a3a48fbe71631fb51ca0e01b9 Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 24 May 2021 13:00:03 +0200 Subject: [PATCH] Mark everything [[nodiscard]], fix some comments. --- src/options.hpp | 4 ++-- src/search.hpp | 5 +++-- src/zip.hpp | 13 +++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/options.hpp b/src/options.hpp index 289d8e4..26e1f12 100644 --- a/src/options.hpp +++ b/src/options.hpp @@ -27,7 +27,7 @@ namespace epubgrep::options namespace po = boost::program_options; //! Parse options and return them. -po::variables_map parse_options(int argc, char *argv[]); +[[nodiscard]] po::variables_map parse_options(int argc, char *argv[]); /*! * @brief Returns the path of the config file. @@ -36,7 +36,7 @@ po::variables_map parse_options(int argc, char *argv[]); * If HOME is set: ${HOME}/.config/epubgrep.conf * Otherwise: epubgrep.conf */ -fs::path get_config_path(); +[[nodiscard]] fs::path get_config_path(); } // namespace epubgrep::options diff --git a/src/search.hpp b/src/search.hpp index 981771a..daf77e8 100644 --- a/src/search.hpp +++ b/src/search.hpp @@ -47,8 +47,9 @@ struct options std::uint64_t context{0}; }; -std::vector search(const fs::path &filepath, std::string_view regex, - const options &opts); +[[nodiscard]] std::vector search(const fs::path &filepath, + std::string_view regex, + const options &opts); } // namespace epubgrep::search diff --git a/src/zip.hpp b/src/zip.hpp index 4af2de7..18adbbf 100644 --- a/src/zip.hpp +++ b/src/zip.hpp @@ -29,19 +29,20 @@ namespace epubgrep::zip { -//! List the contents of a zip file. -std::vector list(const fs::path &filepath); +//! Return the table of contents of a zip file. +[[nodiscard]] std::vector list(const fs::path &filepath); -//! Read a file from a zip archive. -std::string read_file(const fs::path &filepath, std::string_view entry_path); +//! Read a file from a zip archive and return its contents. +[[nodiscard]] std::string read_file(const fs::path &filepath, + std::string_view entry_path); //! Open zip file and return handle. -struct archive *open_file(const fs::path &filepath); +[[nodiscard]] struct archive *open_file(const fs::path &filepath); //! Close zip file. void close_file(struct archive *zipfile, const fs::path &filepath); -// It's std::runtime_error, but with another name. +//! It's std::runtime_error, but with another name. class exception : public std::runtime_error { public: