Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / utility / path.h
index 99422bd45340cbdd1f3d1f33e0573a7e7bf495fd..f203e96b7bb6a0154c1e8549409359ecf66294e6 100644 (file)
@@ -54,119 +54,113 @@ namespace gmx
 
 class Path
 {
-    public:
-        static bool containsDirectory(const std::string &path);
-        static bool isAbsolute(const char *path);
-        static bool isAbsolute(const std::string &path);
-        static bool isEquivalent(const std::string &path1,
-                                 const std::string &path2);
-
-        static std::string join(const std::string &path1,
-                                const std::string &path2);
-        static std::string join(const std::string &path1,
-                                const std::string &path2,
-                                const std::string &path3);
-        //! Return a path using directory separators that suit the execution OS.
-        static std::string normalize(const std::string &path);
-        /*! \brief Returns a copy of the parent path (ie. directory
-         * components) of \c input ie. up to but excluding the last
-         * directory separator (if one exists).
-         *
-         * \returns A copy of the parent path-components, or empty if
-         * no directory separator exists. */
-        static std::string getParentPath(const std::string &input);
-        /*! \brief Returns a copy of the filename in \c input
-         * ie. after the last directory separator (if one exists). */
-        static std::string getFilename(const std::string &input);
-        //! Returns whether an extension is present in \c input.
-        static bool hasExtension(const std::string &input);
-        /*! \brief Returns whether the extension present in \c input
-         * matches \c extension (which does not include the separator
-         * character). */
-        static bool extensionMatches(compat::string_view input,
-                                     compat::string_view extension);
-        /*! \brief Returns a copy of the input without any trailing
-         * extension found in the filename component. */
-        static std::string stripExtension(const std::string &input);
-        /*! \brief Concatenate \c stringToAdd to a copy of \c input,
-         * before any file extension (if one exists), and return the
-         * result. */
-        static std::string concatenateBeforeExtension(const std::string &input,
-                                                      const std::string &stringToAdd);
-
-        static const char *stripSourcePrefix(const char *path);
-
-        static bool exists(const char *path);
-        static bool exists(const std::string &path);
-        static std::string getWorkingDirectory();
-
-        static void splitPathEnvironment(const std::string        &pathEnv,
-                                         std::vector<std::string> *result);
-        static std::vector<std::string> getExecutablePaths();
-
-        static std::string resolveSymlinks(const std::string &path);
-
-    private:
-        // Disallow instantiation.
-        Path();
+public:
+    static bool containsDirectory(const std::string& path);
+    static bool isAbsolute(const char* path);
+    static bool isAbsolute(const std::string& path);
+    static bool isEquivalent(const std::string& path1, const std::string& path2);
+
+    static std::string join(const std::string& path1, const std::string& path2);
+    static std::string join(const std::string& path1, const std::string& path2, const std::string& path3);
+    //! Return a path using directory separators that suit the execution OS.
+    static std::string normalize(const std::string& path);
+    /*! \brief Returns a copy of the parent path (ie. directory
+     * components) of \c input ie. up to but excluding the last
+     * directory separator (if one exists).
+     *
+     * \returns A copy of the parent path-components, or empty if
+     * no directory separator exists. */
+    static std::string getParentPath(const std::string& input);
+    /*! \brief Returns a copy of the filename in \c input
+     * ie. after the last directory separator (if one exists). */
+    static std::string getFilename(const std::string& input);
+    //! Returns whether an extension is present in \c input.
+    static bool hasExtension(const std::string& input);
+    /*! \brief Returns whether the extension present in \c input
+     * matches \c extension (which does not include the separator
+     * character). */
+    static bool extensionMatches(compat::string_view input, compat::string_view extension);
+    /*! \brief Returns a copy of the input without any trailing
+     * extension found in the filename component. */
+    static std::string stripExtension(const std::string& input);
+    /*! \brief Concatenate \c stringToAdd to a copy of \c input,
+     * before any file extension (if one exists), and return the
+     * result. */
+    static std::string concatenateBeforeExtension(const std::string& input, const std::string& stringToAdd);
+
+    static const char* stripSourcePrefix(const char* path);
+
+    static bool        exists(const char* path);
+    static bool        exists(const std::string& path);
+    static std::string getWorkingDirectory();
+
+    static void splitPathEnvironment(const std::string& pathEnv, std::vector<std::string>* result);
+    static std::vector<std::string> getExecutablePaths();
+
+    static std::string resolveSymlinks(const std::string& path);
+
+private:
+    // Disallow instantiation.
+    Path();
 };
 
 class File
 {
-    public:
-        struct NotFoundInfo
+public:
+    struct NotFoundInfo
+    {
+        NotFoundInfo(const char* filename, const char* message, const char* call, bool wasError, int err) :
+            filename(filename),
+            message(message),
+            call(call),
+            wasError(wasError),
+            err(err)
         {
-            NotFoundInfo(const char *filename, const char *message,
-                         const char *call, bool wasError, int err)
-                : filename(filename), message(message), call(call),
-                  wasError(wasError), err(err)
-            {
-            }
-
-            const char *filename;
-            const char *message;
-            const char *call;
-            bool        wasError;
-            int         err;
-        };
-
-        static void returnFalseOnError(const NotFoundInfo &info);
-        static void throwOnError(const NotFoundInfo &info);
-        [[ noreturn ]] static void throwOnNotFound(const NotFoundInfo &info);
-
-        typedef void (*NotFoundHandler)(const NotFoundInfo &info);
-
-        /*! \brief
-         * Checks whether a file exists and is a regular file.
-         *
-         * \param[in] filename    Path to the file to check.
-         * \param[in] onNotFound  Function to call when the file does not
-         *     exists or there is an error accessing it.
-         * \returns   `true` if \p filename exists and is accessible.
-         *
-         * Does not throw, unless onNotFound throws.
-         */
-        static bool exists(const char *filename, NotFoundHandler onNotFound);
-        //! \copydoc exists(const char *, NotFoundHandler)
-        static bool exists(const std::string &filename,
-                           NotFoundHandler    onNotFound);
-
-    private:
-        // Disallow instantiation.
-        File();
+        }
+
+        const char* filename;
+        const char* message;
+        const char* call;
+        bool        wasError;
+        int         err;
+    };
+
+    static void              returnFalseOnError(const NotFoundInfo& info);
+    static void              throwOnError(const NotFoundInfo& info);
+    [[noreturn]] static void throwOnNotFound(const NotFoundInfo& info);
+
+    typedef void (*NotFoundHandler)(const NotFoundInfo& info);
+
+    /*! \brief
+     * Checks whether a file exists and is a regular file.
+     *
+     * \param[in] filename    Path to the file to check.
+     * \param[in] onNotFound  Function to call when the file does not
+     *     exists or there is an error accessing it.
+     * \returns   `true` if \p filename exists and is accessible.
+     *
+     * Does not throw, unless onNotFound throws.
+     */
+    static bool exists(const char* filename, NotFoundHandler onNotFound);
+    //! \copydoc exists(const char *, NotFoundHandler)
+    static bool exists(const std::string& filename, NotFoundHandler onNotFound);
+
+private:
+    // Disallow instantiation.
+    File();
 };
 
 class Directory
 {
-    public:
-        static int create(const char *path);
-        static int create(const std::string &path);
-        static bool exists(const char *path);
-        static bool exists(const std::string &path);
-
-    private:
-        // Disallow instantiation.
-        Directory();
+public:
+    static int  create(const char* path);
+    static int  create(const std::string& path);
+    static bool exists(const char* path);
+    static bool exists(const std::string& path);
+
+private:
+    // Disallow instantiation.
+    Directory();
 };
 
 } // namespace gmx