]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Split util headers into interface and implementation sections
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 14 Jul 2021 07:41:55 +0000 (09:41 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 19 Jul 2021 06:43:53 +0000 (08:43 +0200)
src/util/file_utils.hpp
src/util/path_utils.hpp
src/util/string_utils.hpp

index b5fddda307c61357eaeb80c2083de3de6454c405..e0af9dd586eadc4791b4e18f2dd2f60c051a6fc0 100644 (file)
@@ -22,6 +22,8 @@
 
 namespace util {
 
+// --- Interface ---
+
 void create_cachedir_tag(const std::string& dir);
 
-}
+} // namespace util
index 17d422c4c44058e31a60ebf601b7edbba3388230..3e26251225a8dd9af56f6f14eb4033661e31f548 100644 (file)
 
 namespace util {
 
+// --- Interface ---
+
 // Return whether `path` is absolute.
 bool is_absolute_path(nonstd::string_view path);
 
 // Return whether `path` includes at least one directory separator.
+bool is_full_path(nonstd::string_view path);
+
+// Split a list of paths (such as the content of $PATH on Unix platforms or
+// %PATH% on Windows platforms) into paths.
+std::vector<std::string> split_path_list(nonstd::string_view path_list);
+
+// Make `path` an absolute path.
+std::string to_absolute_path(nonstd::string_view path);
+
+// --- Inline implementations ---
+
 inline bool
-is_full_path(nonstd::string_view path)
+is_full_path(const nonstd::string_view path)
 {
 #ifdef _WIN32
   if (path.find('\\') != nonstd::string_view::npos) {
@@ -40,11 +53,4 @@ is_full_path(nonstd::string_view path)
   return path.find('/') != nonstd::string_view::npos;
 }
 
-// Split a list of paths (such as the content of $PATH on Unix platforms or
-// %PATH% on Windows platforms) into paths.
-std::vector<std::string> split_path_list(nonstd::string_view path_list);
-
-// Make `path` an absolute path.
-std::string to_absolute_path(nonstd::string_view path);
-
 } // namespace util
index ac27704e1268afdfb5fbea329cd759c17e3516c8..956de8fe2b55d7edb3b6c23b33f735e97f4433f4 100644 (file)
 
 namespace util {
 
+// --- Interface ---
+
 // Return true if `suffix` is a suffix of `string`.
-inline bool
-ends_with(const nonstd::string_view string, const nonstd::string_view suffix)
-{
-  return string.ends_with(suffix);
-}
+bool ends_with(nonstd::string_view string, nonstd::string_view suffix);
 
 // Parse a string into a signed integer.
 //
@@ -77,22 +75,33 @@ std::pair<nonstd::string_view, nonstd::optional<nonstd::string_view>>
 split_once(nonstd::string_view string, char split_char);
 
 // Return true if `prefix` is a prefix of `string`.
+bool starts_with(const char* string, nonstd::string_view prefix);
+
+// Return true if `prefix` is a prefix of `string`.
+bool starts_with(nonstd::string_view string, nonstd::string_view prefix);
+
+// Strip whitespace from left and right side of a string.
+[[nodiscard]] std::string strip_whitespace(nonstd::string_view string);
+
+// --- Inline implementations ---
+
 inline bool
-starts_with(const char* string, const nonstd::string_view prefix)
+ends_with(const nonstd::string_view string, const nonstd::string_view suffix)
+{
+  return string.ends_with(suffix);
+}
+inline bool
+starts_with(const char* const string, const nonstd::string_view prefix)
 {
   // Optimized version of starts_with(string_view, string_view): avoid computing
   // the length of the string argument.
   return std::strncmp(string, prefix.data(), prefix.length()) == 0;
 }
 
-// Return true if `prefix` is a prefix of `string`.
 inline bool
 starts_with(const nonstd::string_view string, const nonstd::string_view prefix)
 {
   return string.starts_with(prefix);
 }
 
-// Strip whitespace from left and right side of a string.
-[[nodiscard]] std::string strip_whitespace(nonstd::string_view string);
-
 } // namespace util