diff --git a/include/export/adoc.hpp b/include/export/adoc.hpp index 7eaf467..7d8a984 100644 --- a/include/export/adoc.hpp +++ b/include/export/adoc.hpp @@ -46,24 +46,30 @@ private: using replacemap = const std::map; //! Replace strings in text. + [[nodiscard]] string replace(string text, const replacemap &replacements) const; //! Replaces characters in tags that asciidoctor doesn't like. + [[nodiscard]] string replace_in_tag(const string &text) const; //! Replaces characters in title that asciidoctor doesn't like. + [[nodiscard]] string replace_in_title(const string &text) const; //! Replaces characters in URI that asciidoctor doesn't like. + [[nodiscard]] string replace_in_uri(const string &text) const; //! Print things sorted by tag. void print_tags(const tagmap &tags) const; //! Get ISO-8601 day from Database::entry. + [[nodiscard]] string get_day(const Database::entry &entry) const; //! Get ISO-8601 time from Database::entry. + [[nodiscard]] string get_time(const Database::entry &entry) const; }; } // namespace remwharead::Export diff --git a/include/export/csv.hpp b/include/export/csv.hpp index 8499835..7810185 100644 --- a/include/export/csv.hpp +++ b/include/export/csv.hpp @@ -40,6 +40,7 @@ namespace remwharead::Export private: //! replaces " with "". + [[nodiscard]] string quote(string field) const; }; } // namespace remwharead::Export diff --git a/include/export/export.hpp b/include/export/export.hpp index 0ecf9e0..b4528ae 100644 --- a/include/export/export.hpp +++ b/include/export/export.hpp @@ -67,6 +67,7 @@ protected: * * @return Sorted list of Database::entry. */ + [[nodiscard]] list sort_entries(list entries) const; }; } // namespace remwharead::Export diff --git a/include/search.hpp b/include/search.hpp index 25a4a6d..3a935b9 100644 --- a/include/search.hpp +++ b/include/search.hpp @@ -57,6 +57,7 @@ public: * * @since 0.7.0 */ + [[nodiscard]] list search_tags(const string &expression, bool is_re) const; @@ -72,6 +73,7 @@ public: * * @since 0.7.0 */ + [[nodiscard]] list search_all(const string &expression, bool is_re) const; @@ -89,6 +91,7 @@ public: * @since 0.7.2 */ // TODO(tastytea): Think of something more elegant. + [[nodiscard]] list search_all_threaded(const string &expression, bool is_re) const; @@ -106,6 +109,7 @@ private: * * @since 0.7.0 */ + [[nodiscard]] vector> parse_expression(const string &expression) const; /*! @@ -113,6 +117,7 @@ private: * * @since 0.7.0 */ + [[nodiscard]] inline string to_lowercase(const string &str) const; }; } // namespace remwharead diff --git a/include/sqlite.hpp b/include/sqlite.hpp index d341683..f91cea9 100644 --- a/include/sqlite.hpp +++ b/include/sqlite.hpp @@ -75,6 +75,7 @@ public: * * @since 0.6.0 */ + [[nodiscard]] string fulltext_oneline() const; }; @@ -104,6 +105,7 @@ public: * * @since 0.6.0 */ + [[nodiscard]] list retrieve(const time_point &start = time_point(), const time_point &end = system_clock::now()) const; @@ -112,6 +114,7 @@ private: std::unique_ptr _session; bool _connected; + [[nodiscard]] fs::path get_data_home() const; }; } // namespace remwharead diff --git a/include/time.hpp b/include/time.hpp index e5fdb84..ce696e4 100644 --- a/include/time.hpp +++ b/include/time.hpp @@ -36,6 +36,7 @@ using time_point = system_clock::time_point; * @param strtime Time string in ISO 8601 or SQLite format. * @param sqlite Is the string in SQLite format? */ +[[nodiscard]] time_point string_to_timepoint(const string &strtime, bool sqlite = false); /*! @@ -46,6 +47,7 @@ time_point string_to_timepoint(const string &strtime, bool sqlite = false); * @param time_point The std::chrono::system_clock::time_point. * @param sqlite Is the string in SQLite format? */ +[[nodiscard]] string timepoint_to_string(const time_point &tp, bool sqlite = false); } // namespace remwharead diff --git a/include/uri.hpp b/include/uri.hpp index c317f74..8d2c5f1 100644 --- a/include/uri.hpp +++ b/include/uri.hpp @@ -94,13 +94,15 @@ public: * * @since 0.6.0 */ + [[nodiscard]] html_extract get(); /*! * @brief Save %URI in archive and return archive-URI. * * @since 0.6.0 - */ + */ + [[nodiscard]] archive_answer archive() const; protected: @@ -111,6 +113,7 @@ protected: * * @since 0.6.0 */ + [[nodiscard]] string make_request(const string &uri, bool archive = false) const; /*! @@ -118,21 +121,24 @@ protected: * * @since 0.6.0 */ - string extract_title(const string &html); + [[nodiscard]] + string extract_title(const string &html) const; /*! * @brief Extract the description from an HTML page. * * @since 0.6.0 */ - string extract_description(const string &html); + [[nodiscard]] + string extract_description(const string &html) const; /*! * @brief Removes HTML tags and superflous spaces from an HTML page. * * @since 0.6.0 */ - string strip_html(const string &html); + [[nodiscard]] + string strip_html(const string &html) const; /*! * @brief Remove HTML tags. @@ -142,21 +148,24 @@ protected: * * @since 0.6.0 */ - string remove_html_tags(const string &html, const string &tag = ""); + [[nodiscard]] + string remove_html_tags(const string &html, const string &tag = "") const; /*! * @brief Convert HTML entities to UTF-8. * * @since 0.6.0 */ - string unescape_html(string html); + [[nodiscard]] + string unescape_html(string html) const; /*! * @brief Replace newlines with spaces. * * @since 0.6.0 */ - string remove_newlines(string text); + [[nodiscard]] + string remove_newlines(string text) const; /*! * @brief Set proxy server. @@ -170,6 +179,7 @@ protected: * * @since 0.8.5 */ + [[nodiscard]] string cut_text(const string &text, uint16_t n_chars) const; }; } // namespace remwharead diff --git a/src/lib/uri.cpp b/src/lib/uri.cpp index c257dd0..4328b7b 100644 --- a/src/lib/uri.cpp +++ b/src/lib/uri.cpp @@ -224,7 +224,7 @@ string URI::make_request(const string &uri, bool archive) const } } -string URI::extract_title(const string &html) +string URI::extract_title(const string &html) const { const RegEx re_htmlfile(".*\\.(.?html?|xml|rss)$", RegEx::RE_CASELESS); if (_uri.substr(0, 4) == "http" || re_htmlfile.match(_uri)) @@ -241,7 +241,7 @@ string URI::extract_title(const string &html) return ""; } -string URI::extract_description(const string &html) +string URI::extract_description(const string &html) const { const RegEx re_htmlfile(".*\\.(.?html?|xml|rss)$", RegEx::RE_CASELESS); if (_uri.substr(0, 4) == "http" || re_htmlfile.match(_uri)) @@ -259,7 +259,7 @@ string URI::extract_description(const string &html) return ""; } -string URI::strip_html(const string &html) +string URI::strip_html(const string &html) const { string out; @@ -280,7 +280,7 @@ string URI::strip_html(const string &html) return unescape_html(out); } -string URI::remove_html_tags(const string &html, const string &tag) +string URI::remove_html_tags(const string &html, const string &tag) const { // NOTE: I did this with regex_replace before, but libstdc++ segfaulted. string out; @@ -318,7 +318,7 @@ string URI::remove_html_tags(const string &html, const string &tag) return out; } -string URI::unescape_html(string html) +string URI::unescape_html(string html) const { // Used to convert int to utf-8 char. std::wstring_convert, char32_t> u8c; @@ -642,7 +642,7 @@ archive_answer URI::archive() const return { false, "Unknown error.", "" }; } -string URI::remove_newlines(string text) +string URI::remove_newlines(string text) const { size_t posn = 0; while ((posn = text.find('\n', posn)) != std::string::npos)