[[nodiscard]] all the functions.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
tastytea 2019-10-30 08:51:07 +01:00
parent 32cf647131
commit 37f6da6710
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
8 changed files with 41 additions and 13 deletions

View File

@ -46,24 +46,30 @@ private:
using replacemap = const std::map<const string, const string>; using replacemap = const std::map<const string, const string>;
//! Replace strings in text. //! Replace strings in text.
[[nodiscard]]
string replace(string text, const replacemap &replacements) const; string replace(string text, const replacemap &replacements) const;
//! Replaces characters in tags that asciidoctor doesn't like. //! Replaces characters in tags that asciidoctor doesn't like.
[[nodiscard]]
string replace_in_tag(const string &text) const; string replace_in_tag(const string &text) const;
//! Replaces characters in title that asciidoctor doesn't like. //! Replaces characters in title that asciidoctor doesn't like.
[[nodiscard]]
string replace_in_title(const string &text) const; string replace_in_title(const string &text) const;
//! Replaces characters in URI that asciidoctor doesn't like. //! Replaces characters in URI that asciidoctor doesn't like.
[[nodiscard]]
string replace_in_uri(const string &text) const; string replace_in_uri(const string &text) const;
//! Print things sorted by tag. //! Print things sorted by tag.
void print_tags(const tagmap &tags) const; void print_tags(const tagmap &tags) const;
//! Get ISO-8601 day from Database::entry. //! Get ISO-8601 day from Database::entry.
[[nodiscard]]
string get_day(const Database::entry &entry) const; string get_day(const Database::entry &entry) const;
//! Get ISO-8601 time from Database::entry. //! Get ISO-8601 time from Database::entry.
[[nodiscard]]
string get_time(const Database::entry &entry) const; string get_time(const Database::entry &entry) const;
}; };
} // namespace remwharead::Export } // namespace remwharead::Export

View File

@ -40,6 +40,7 @@ namespace remwharead::Export
private: private:
//! replaces " with "". //! replaces " with "".
[[nodiscard]]
string quote(string field) const; string quote(string field) const;
}; };
} // namespace remwharead::Export } // namespace remwharead::Export

View File

@ -67,6 +67,7 @@ protected:
* *
* @return Sorted list of Database::entry. * @return Sorted list of Database::entry.
*/ */
[[nodiscard]]
list<Database::entry> sort_entries(list<Database::entry> entries) const; list<Database::entry> sort_entries(list<Database::entry> entries) const;
}; };
} // namespace remwharead::Export } // namespace remwharead::Export

View File

@ -57,6 +57,7 @@ public:
* *
* @since 0.7.0 * @since 0.7.0
*/ */
[[nodiscard]]
list<Database::entry> search_tags(const string &expression, bool is_re) list<Database::entry> search_tags(const string &expression, bool is_re)
const; const;
@ -72,6 +73,7 @@ public:
* *
* @since 0.7.0 * @since 0.7.0
*/ */
[[nodiscard]]
list<Database::entry> search_all(const string &expression, bool is_re) list<Database::entry> search_all(const string &expression, bool is_re)
const; const;
@ -89,6 +91,7 @@ public:
* @since 0.7.2 * @since 0.7.2
*/ */
// TODO(tastytea): Think of something more elegant. // TODO(tastytea): Think of something more elegant.
[[nodiscard]]
list<Database::entry> search_all_threaded(const string &expression, list<Database::entry> search_all_threaded(const string &expression,
bool is_re) const; bool is_re) const;
@ -106,6 +109,7 @@ private:
* *
* @since 0.7.0 * @since 0.7.0
*/ */
[[nodiscard]]
vector<vector<string>> parse_expression(const string &expression) const; vector<vector<string>> parse_expression(const string &expression) const;
/*! /*!
@ -113,6 +117,7 @@ private:
* *
* @since 0.7.0 * @since 0.7.0
*/ */
[[nodiscard]]
inline string to_lowercase(const string &str) const; inline string to_lowercase(const string &str) const;
}; };
} // namespace remwharead } // namespace remwharead

View File

@ -75,6 +75,7 @@ public:
* *
* @since 0.6.0 * @since 0.6.0
*/ */
[[nodiscard]]
string fulltext_oneline() const; string fulltext_oneline() const;
}; };
@ -104,6 +105,7 @@ public:
* *
* @since 0.6.0 * @since 0.6.0
*/ */
[[nodiscard]]
list<entry> retrieve(const time_point &start = time_point(), list<entry> retrieve(const time_point &start = time_point(),
const time_point &end = system_clock::now()) const; const time_point &end = system_clock::now()) const;
@ -112,6 +114,7 @@ private:
std::unique_ptr<Session> _session; std::unique_ptr<Session> _session;
bool _connected; bool _connected;
[[nodiscard]]
fs::path get_data_home() const; fs::path get_data_home() const;
}; };
} // namespace remwharead } // namespace remwharead

View File

@ -36,6 +36,7 @@ using time_point = system_clock::time_point;
* @param strtime Time string in ISO 8601 or SQLite format. * @param strtime Time string in ISO 8601 or SQLite format.
* @param sqlite Is the string in SQLite format? * @param sqlite Is the string in SQLite format?
*/ */
[[nodiscard]]
time_point string_to_timepoint(const string &strtime, bool sqlite = false); 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 time_point The std::chrono::system_clock::time_point.
* @param sqlite Is the string in SQLite format? * @param sqlite Is the string in SQLite format?
*/ */
[[nodiscard]]
string timepoint_to_string(const time_point &tp, bool sqlite = false); string timepoint_to_string(const time_point &tp, bool sqlite = false);
} // namespace remwharead } // namespace remwharead

View File

@ -94,13 +94,15 @@ public:
* *
* @since 0.6.0 * @since 0.6.0
*/ */
[[nodiscard]]
html_extract get(); html_extract get();
/*! /*!
* @brief Save %URI in archive and return archive-URI. * @brief Save %URI in archive and return archive-URI.
* *
* @since 0.6.0 * @since 0.6.0
*/ */
[[nodiscard]]
archive_answer archive() const; archive_answer archive() const;
protected: protected:
@ -111,6 +113,7 @@ protected:
* *
* @since 0.6.0 * @since 0.6.0
*/ */
[[nodiscard]]
string make_request(const string &uri, bool archive = false) const; string make_request(const string &uri, bool archive = false) const;
/*! /*!
@ -118,21 +121,24 @@ protected:
* *
* @since 0.6.0 * @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. * @brief Extract the description from an HTML page.
* *
* @since 0.6.0 * @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. * @brief Removes HTML tags and superflous spaces from an HTML page.
* *
* @since 0.6.0 * @since 0.6.0
*/ */
string strip_html(const string &html); [[nodiscard]]
string strip_html(const string &html) const;
/*! /*!
* @brief Remove HTML tags. * @brief Remove HTML tags.
@ -142,21 +148,24 @@ protected:
* *
* @since 0.6.0 * @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. * @brief Convert HTML entities to UTF-8.
* *
* @since 0.6.0 * @since 0.6.0
*/ */
string unescape_html(string html); [[nodiscard]]
string unescape_html(string html) const;
/*! /*!
* @brief Replace newlines with spaces. * @brief Replace newlines with spaces.
* *
* @since 0.6.0 * @since 0.6.0
*/ */
string remove_newlines(string text); [[nodiscard]]
string remove_newlines(string text) const;
/*! /*!
* @brief Set proxy server. * @brief Set proxy server.
@ -170,6 +179,7 @@ protected:
* *
* @since 0.8.5 * @since 0.8.5
*/ */
[[nodiscard]]
string cut_text(const string &text, uint16_t n_chars) const; string cut_text(const string &text, uint16_t n_chars) const;
}; };
} // namespace remwharead } // namespace remwharead

View File

@ -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); const RegEx re_htmlfile(".*\\.(.?html?|xml|rss)$", RegEx::RE_CASELESS);
if (_uri.substr(0, 4) == "http" || re_htmlfile.match(_uri)) if (_uri.substr(0, 4) == "http" || re_htmlfile.match(_uri))
@ -241,7 +241,7 @@ string URI::extract_title(const string &html)
return ""; 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); const RegEx re_htmlfile(".*\\.(.?html?|xml|rss)$", RegEx::RE_CASELESS);
if (_uri.substr(0, 4) == "http" || re_htmlfile.match(_uri)) if (_uri.substr(0, 4) == "http" || re_htmlfile.match(_uri))
@ -259,7 +259,7 @@ string URI::extract_description(const string &html)
return ""; return "";
} }
string URI::strip_html(const string &html) string URI::strip_html(const string &html) const
{ {
string out; string out;
@ -280,7 +280,7 @@ string URI::strip_html(const string &html)
return unescape_html(out); 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. // NOTE: I did this with regex_replace before, but libstdc++ segfaulted.
string out; string out;
@ -318,7 +318,7 @@ string URI::remove_html_tags(const string &html, const string &tag)
return out; return out;
} }
string URI::unescape_html(string html) string URI::unescape_html(string html) const
{ {
// Used to convert int to utf-8 char. // Used to convert int to utf-8 char.
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> u8c; std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> u8c;
@ -642,7 +642,7 @@ archive_answer URI::archive() const
return { false, "Unknown error.", "" }; return { false, "Unknown error.", "" };
} }
string URI::remove_newlines(string text) string URI::remove_newlines(string text) const
{ {
size_t posn = 0; size_t posn = 0;
while ((posn = text.find('\n', posn)) != std::string::npos) while ((posn = text.find('\n', posn)) != std::string::npos)