OSDN Git Service

Added new MUtils::parent_path() function.
[mutilities/MUtilities.git] / include / MUtils / Global.h
index ca7fe75..90266a3 100644 (file)
@@ -39,7 +39,7 @@ template<typename K, typename V> class QHash;
  */
 
  //Interface version
-#define MUTILS_INTERFACE 3
+#define MUTILS_INTERFACE 4
 
 //MUtils API
 #ifdef _MSC_VER
@@ -324,6 +324,17 @@ namespace MUtils
        MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 &value, const size_t &offset);
 
        /**
+       * \brief Get parent path
+       *
+       * This function determines the "parent" path, by removing the *last* path component (file name or directory) form the given original path.
+       *
+       * \param path A read-only reference to the original path string.
+       *
+       * \return The remaining path string (i.e. "parent" path); an empty string if the original path only consited of a single component.
+       */
+       MUTILS_API QString parent_path(const QString &path);
+
+       /**
        * \brief Parse regular expression results
        *
        * This function tries to parses the results (captures) of a regular expression as unsigned 32-Bit values. The given regular expression must contain at least \p count captures. Only the *first* \p count captures are considered, additional captures are ignored.