Added new MUtils::parent_path() function.

This commit is contained in:
LoRd_MuldeR 2019-10-26 21:45:47 +02:00
parent 17b473a6ee
commit 876e2d3e6d
13 changed files with 94 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -73,7 +73,7 @@ $(function() {
<div class="ttc" id="_hash_8h_html_aa9e34ac422f4e52061cb8908f922fe17"><div class="ttname"><a href="../../d2/dad/_hash_8h.html#aa9e34ac422f4e52061cb8908f922fe17">MUtils::Hash::HASH_BLAKE2_512</a></div><div class="ttdeci">static const quint16 HASH_BLAKE2_512</div><div class="ttdoc">Hash algorithm identifier. </div><div class="ttdef"><b>Definition:</b> Hash.h:42</div></div> <div class="ttc" id="_hash_8h_html_aa9e34ac422f4e52061cb8908f922fe17"><div class="ttname"><a href="../../d2/dad/_hash_8h.html#aa9e34ac422f4e52061cb8908f922fe17">MUtils::Hash::HASH_BLAKE2_512</a></div><div class="ttdeci">static const quint16 HASH_BLAKE2_512</div><div class="ttdoc">Hash algorithm identifier. </div><div class="ttdef"><b>Definition:</b> Hash.h:42</div></div>
<div class="ttc" id="_hash_8h_html_af80dfb1569816fab7ab5ed32e6386458"><div class="ttname"><a href="../../d2/dad/_hash_8h.html#af80dfb1569816fab7ab5ed32e6386458">MUtils::Hash::HASH_KECCAK_384</a></div><div class="ttdeci">static const quint16 HASH_KECCAK_384</div><div class="ttdoc">Hash algorithm identifier. </div><div class="ttdef"><b>Definition:</b> Hash.h:45</div></div> <div class="ttc" id="_hash_8h_html_af80dfb1569816fab7ab5ed32e6386458"><div class="ttname"><a href="../../d2/dad/_hash_8h.html#af80dfb1569816fab7ab5ed32e6386458">MUtils::Hash::HASH_KECCAK_384</a></div><div class="ttdeci">static const quint16 HASH_KECCAK_384</div><div class="ttdoc">Hash algorithm identifier. </div><div class="ttdef"><b>Definition:</b> Hash.h:45</div></div>
<div class="ttc" id="namespace_m_utils_html"><div class="ttname"><a href="../../d3/da6/namespace_m_utils.html">MUtils</a></div><div class="ttdoc">Global MUtils namespace. </div><div class="ttdef"><b>Definition:</b> CPUFeatures.h:37</div></div> <div class="ttc" id="namespace_m_utils_html"><div class="ttname"><a href="../../d3/da6/namespace_m_utils.html">MUtils</a></div><div class="ttdoc">Global MUtils namespace. </div><div class="ttdef"><b>Definition:</b> CPUFeatures.h:37</div></div>
<div class="ttc" id="_global_8h_html_a8e7b4857b78f9749233e5abc96534ca8"><div class="ttname"><a href="../../d5/d3b/_global_8h.html#a8e7b4857b78f9749233e5abc96534ca8">MUTILS_NO_COPY</a></div><div class="ttdeci">#define MUTILS_NO_COPY(CLASS)</div><div class="ttdoc">Disables copy constructor and assignment operator in the specified class. This macro should be used i...</div><div class="ttdef"><b>Definition:</b> Global.h:418</div></div> <div class="ttc" id="_global_8h_html_a8e7b4857b78f9749233e5abc96534ca8"><div class="ttname"><a href="../../d5/d3b/_global_8h.html#a8e7b4857b78f9749233e5abc96534ca8">MUTILS_NO_COPY</a></div><div class="ttdeci">#define MUTILS_NO_COPY(CLASS)</div><div class="ttdoc">Disables copy constructor and assignment operator in the specified class. This macro should be used i...</div><div class="ttdef"><b>Definition:</b> Global.h:429</div></div>
<div class="ttc" id="_hash_8h_html_a330b73d6927d6cd95892712f9396f40e"><div class="ttname"><a href="../../d2/dad/_hash_8h.html#a330b73d6927d6cd95892712f9396f40e">MUtils::Hash::create</a></div><div class="ttdeci">MUTILS_API Hash * create(const quint16 &amp;hashId, const char *const key=NULL)</div><div class="ttdoc">Create instance of a hash function. </div></div> <div class="ttc" id="_hash_8h_html_a330b73d6927d6cd95892712f9396f40e"><div class="ttname"><a href="../../d2/dad/_hash_8h.html#a330b73d6927d6cd95892712f9396f40e">MUtils::Hash::create</a></div><div class="ttdeci">MUTILS_API Hash * create(const quint16 &amp;hashId, const char *const key=NULL)</div><div class="ttdoc">Create instance of a hash function. </div></div>
<div class="ttc" id="class_m_utils_1_1_hash_1_1_hash_html"><div class="ttname"><a href="../../da/db0/class_m_utils_1_1_hash_1_1_hash.html">MUtils::Hash::Hash</a></div><div class="ttdoc">This abstract class specifies the generic interface for all support hash algorithms. </div><div class="ttdef"><b>Definition:</b> Hash.h:57</div></div> <div class="ttc" id="class_m_utils_1_1_hash_1_1_hash_html"><div class="ttname"><a href="../../da/db0/class_m_utils_1_1_hash_1_1_hash.html">MUtils::Hash::Hash</a></div><div class="ttdoc">This abstract class specifies the generic interface for all support hash algorithms. </div><div class="ttdef"><b>Definition:</b> Hash.h:57</div></div>
<div class="ttc" id="_hash_8h_html_ae38cda07e425eb7c745492215a48ae08"><div class="ttname"><a href="../../d2/dad/_hash_8h.html#ae38cda07e425eb7c745492215a48ae08">MUtils::Hash::HASH_KECCAK_256</a></div><div class="ttdeci">static const quint16 HASH_KECCAK_256</div><div class="ttdoc">Hash algorithm identifier. </div><div class="ttdef"><b>Definition:</b> Hash.h:44</div></div> <div class="ttc" id="_hash_8h_html_ae38cda07e425eb7c745492215a48ae08"><div class="ttname"><a href="../../d2/dad/_hash_8h.html#ae38cda07e425eb7c745492215a48ae08">MUtils::Hash::HASH_KECCAK_256</a></div><div class="ttdeci">static const quint16 HASH_KECCAK_256</div><div class="ttdoc">Hash algorithm identifier. </div><div class="ttdef"><b>Definition:</b> Hash.h:44</div></div>

View File

@ -185,6 +185,9 @@ MUTILS_API bool&#160;</td><td class="memItemRight" valign="bottom"><b>regexp_par
<tr class="memitem:a8fa486ed4aee98c4d0029b7e6e7c8d2c"><td class="memItemLeft" align="right" valign="top"><a id="a8fa486ed4aee98c4d0029b7e6e7c8d2c"></a> <tr class="memitem:a8fa486ed4aee98c4d0029b7e6e7c8d2c"><td class="memItemLeft" align="right" valign="top"><a id="a8fa486ed4aee98c4d0029b7e6e7c8d2c"></a>
MUTILS_API bool&#160;</td><td class="memItemRight" valign="bottom"><b>regexp_parse_int32</b> (const QRegExp &amp;regexp, qint32 &amp;value, const size_t &amp;offset)</td></tr> MUTILS_API bool&#160;</td><td class="memItemRight" valign="bottom"><b>regexp_parse_int32</b> (const QRegExp &amp;regexp, qint32 &amp;value, const size_t &amp;offset)</td></tr>
<tr class="separator:a8fa486ed4aee98c4d0029b7e6e7c8d2c"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="separator:a8fa486ed4aee98c4d0029b7e6e7c8d2c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9916e02e90bdb987b95b3cc9d463f949"><td class="memItemLeft" align="right" valign="top">MUTILS_API QString&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/da6/namespace_m_utils.html#a9916e02e90bdb987b95b3cc9d463f949">parent_path</a> (const QString &amp;path)</td></tr>
<tr class="memdesc:a9916e02e90bdb987b95b3cc9d463f949"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get parent path. <a href="#a9916e02e90bdb987b95b3cc9d463f949">More...</a><br /></td></tr>
<tr class="separator:a9916e02e90bdb987b95b3cc9d463f949"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a81704d66d34e37d3e0e159b5f436babf"><td class="memItemLeft" align="right" valign="top">MUTILS_API bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/da6/namespace_m_utils.html#a81704d66d34e37d3e0e159b5f436babf">regexp_parse_uint32</a> (const QRegExp &amp;regexp, quint32 *values, const size_t &amp;count)</td></tr> <tr class="memitem:a81704d66d34e37d3e0e159b5f436babf"><td class="memItemLeft" align="right" valign="top">MUTILS_API bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/da6/namespace_m_utils.html#a81704d66d34e37d3e0e159b5f436babf">regexp_parse_uint32</a> (const QRegExp &amp;regexp, quint32 *values, const size_t &amp;count)</td></tr>
<tr class="memdesc:a81704d66d34e37d3e0e159b5f436babf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Parse regular expression results. <a href="#a81704d66d34e37d3e0e159b5f436babf">More...</a><br /></td></tr> <tr class="memdesc:a81704d66d34e37d3e0e159b5f436babf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Parse regular expression results. <a href="#a81704d66d34e37d3e0e159b5f436babf">More...</a><br /></td></tr>
<tr class="separator:a81704d66d34e37d3e0e159b5f436babf"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="separator:a81704d66d34e37d3e0e159b5f436babf"><td class="memSeparator" colspan="2">&#160;</td></tr>
@ -622,6 +625,34 @@ class MUTILS_API&#160;</td><td class="memItemRight" valign="bottom"><b>Taskbar7_
<p>The <em>random</em> value is created using a "strong" PRNG of the underlying system, if possible. Otherwise a fallback PRNG is used. It is <b>not</b> required or useful to call <code>srand()</code> or <code>qsrand()</code> prior to using this function. If necessary, the seeding of the PRNG happen <em>automatically</em> on the first call.</p> <p>The <em>random</em> value is created using a "strong" PRNG of the underlying system, if possible. Otherwise a fallback PRNG is used. It is <b>not</b> required or useful to call <code>srand()</code> or <code>qsrand()</code> prior to using this function. If necessary, the seeding of the PRNG happen <em>automatically</em> on the first call.</p>
<dl class="section return"><dt>Returns</dt><dd>The function returns a <em>random</em> unsigned 64-Bit value. </dd></dl> <dl class="section return"><dt>Returns</dt><dd>The function returns a <em>random</em> unsigned 64-Bit value. </dd></dl>
</div>
</div>
<a id="a9916e02e90bdb987b95b3cc9d463f949"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9916e02e90bdb987b95b3cc9d463f949">&sect;&nbsp;</a></span>parent_path()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">MUTILS_API QString MUtils::parent_path </td>
<td>(</td>
<td class="paramtype">const QString &amp;&#160;</td>
<td class="paramname"><em>path</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get parent path. </p>
<p>This function determines the "parent" path, by removing the <em>last</em> path component (file name or directory) form the given original path.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">path</td><td>A read-only reference to the original path string.</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The remaining path string (i.e. "parent" path); an empty string if the original path only consited of a single component. </dd></dl>
</div> </div>
</div> </div>
<a id="aea4a212153b09b24b04f30ef5159f29b"></a> <a id="aea4a212153b09b24b04f30ef5159f29b"></a>

File diff suppressed because one or more lines are too long

View File

@ -221,6 +221,9 @@ MUTILS_API bool&#160;</td><td class="memItemRight" valign="bottom"><b>MUtils::re
<tr class="memitem:a8fa486ed4aee98c4d0029b7e6e7c8d2c"><td class="memItemLeft" align="right" valign="top"><a id="a8fa486ed4aee98c4d0029b7e6e7c8d2c"></a> <tr class="memitem:a8fa486ed4aee98c4d0029b7e6e7c8d2c"><td class="memItemLeft" align="right" valign="top"><a id="a8fa486ed4aee98c4d0029b7e6e7c8d2c"></a>
MUTILS_API bool&#160;</td><td class="memItemRight" valign="bottom"><b>MUtils::regexp_parse_int32</b> (const QRegExp &amp;regexp, qint32 &amp;value, const size_t &amp;offset)</td></tr> MUTILS_API bool&#160;</td><td class="memItemRight" valign="bottom"><b>MUtils::regexp_parse_int32</b> (const QRegExp &amp;regexp, qint32 &amp;value, const size_t &amp;offset)</td></tr>
<tr class="separator:a8fa486ed4aee98c4d0029b7e6e7c8d2c"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="separator:a8fa486ed4aee98c4d0029b7e6e7c8d2c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9916e02e90bdb987b95b3cc9d463f949"><td class="memItemLeft" align="right" valign="top">MUTILS_API QString&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/da6/namespace_m_utils.html#a9916e02e90bdb987b95b3cc9d463f949">MUtils::parent_path</a> (const QString &amp;path)</td></tr>
<tr class="memdesc:a9916e02e90bdb987b95b3cc9d463f949"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get parent path. <a href="../../d3/da6/namespace_m_utils.html#a9916e02e90bdb987b95b3cc9d463f949">More...</a><br /></td></tr>
<tr class="separator:a9916e02e90bdb987b95b3cc9d463f949"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a81704d66d34e37d3e0e159b5f436babf"><td class="memItemLeft" align="right" valign="top">MUTILS_API bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/da6/namespace_m_utils.html#a81704d66d34e37d3e0e159b5f436babf">MUtils::regexp_parse_uint32</a> (const QRegExp &amp;regexp, quint32 *values, const size_t &amp;count)</td></tr> <tr class="memitem:a81704d66d34e37d3e0e159b5f436babf"><td class="memItemLeft" align="right" valign="top">MUTILS_API bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/da6/namespace_m_utils.html#a81704d66d34e37d3e0e159b5f436babf">MUtils::regexp_parse_uint32</a> (const QRegExp &amp;regexp, quint32 *values, const size_t &amp;count)</td></tr>
<tr class="memdesc:a81704d66d34e37d3e0e159b5f436babf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Parse regular expression results. <a href="../../d3/da6/namespace_m_utils.html#a81704d66d34e37d3e0e159b5f436babf">More...</a><br /></td></tr> <tr class="memdesc:a81704d66d34e37d3e0e159b5f436babf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Parse regular expression results. <a href="../../d3/da6/namespace_m_utils.html#a81704d66d34e37d3e0e159b5f436babf">More...</a><br /></td></tr>
<tr class="separator:a81704d66d34e37d3e0e159b5f436babf"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="separator:a81704d66d34e37d3e0e159b5f436babf"><td class="memSeparator" colspan="2">&#160;</td></tr>

File diff suppressed because one or more lines are too long

View File

@ -307,6 +307,9 @@ $(function() {
<h3><a id="index_p"></a>- p -</h3><ul> <h3><a id="index_p"></a>- p -</h3><ul>
<li>parent_path()
: <a class="el" href="d3/da6/namespace_m_utils.html#a9916e02e90bdb987b95b3cc9d463f949">MUtils</a>
</li>
<li>parity() <li>parity()
: <a class="el" href="d3/da6/namespace_m_utils.html#aea4a212153b09b24b04f30ef5159f29b">MUtils</a> : <a class="el" href="d3/da6/namespace_m_utils.html#aea4a212153b09b24b04f30ef5159f29b">MUtils</a>
</li> </li>

View File

@ -102,6 +102,9 @@ $(function() {
<li>next_rand_u64() <li>next_rand_u64()
: <a class="el" href="d3/da6/namespace_m_utils.html#ad7edd4aece64faf3aa16c9509243608c">MUtils</a> : <a class="el" href="d3/da6/namespace_m_utils.html#ad7edd4aece64faf3aa16c9509243608c">MUtils</a>
</li> </li>
<li>parent_path()
: <a class="el" href="d3/da6/namespace_m_utils.html#a9916e02e90bdb987b95b3cc9d463f949">MUtils</a>
</li>
<li>parity() <li>parity()
: <a class="el" href="d3/da6/namespace_m_utils.html#aea4a212153b09b24b04f30ef5159f29b">MUtils</a> : <a class="el" href="d3/da6/namespace_m_utils.html#aea4a212153b09b24b04f30ef5159f29b">MUtils</a>
</li> </li>

View File

@ -1,4 +1,5 @@
var searchData= var searchData=
[ [
['parent_5fpath',['parent_path',['../d3/da6/namespace_m_utils.html#a9916e02e90bdb987b95b3cc9d463f949',1,'MUtils']]],
['parity',['parity',['../d3/da6/namespace_m_utils.html#aea4a212153b09b24b04f30ef5159f29b',1,'MUtils']]] ['parity',['parity',['../d3/da6/namespace_m_utils.html#aea4a212153b09b24b04f30ef5159f29b',1,'MUtils']]]
]; ];

View File

@ -1,4 +1,5 @@
var searchData= var searchData=
[ [
['parent_5fpath',['parent_path',['../d3/da6/namespace_m_utils.html#a9916e02e90bdb987b95b3cc9d463f949',1,'MUtils']]],
['parity',['parity',['../d3/da6/namespace_m_utils.html#aea4a212153b09b24b04f30ef5159f29b',1,'MUtils']]] ['parity',['parity',['../d3/da6/namespace_m_utils.html#aea4a212153b09b24b04f30ef5159f29b',1,'MUtils']]]
]; ];

View File

@ -39,7 +39,7 @@ template<typename K, typename V> class QHash;
*/ */
//Interface version //Interface version
#define MUTILS_INTERFACE 3 #define MUTILS_INTERFACE 4
//MUtils API //MUtils API
#ifdef _MSC_VER #ifdef _MSC_VER
@ -323,6 +323,17 @@ namespace MUtils
MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value, const size_t &offset); MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value, const size_t &offset);
MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 &value, const size_t &offset); 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 * \brief Parse regular expression results
* *

View File

@ -31,7 +31,7 @@
#define VER_MUTILS_MAJOR 1 #define VER_MUTILS_MAJOR 1
#define VER_MUTILS_MINOR_HI 1 #define VER_MUTILS_MINOR_HI 1
#define VER_MUTILS_MINOR_LO 3 #define VER_MUTILS_MINOR_LO 4
#define VER_MUTILS_PATCH 0 #define VER_MUTILS_PATCH 0
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -772,6 +772,40 @@ QString MUtils::clean_file_path(const QString &path, const bool &pretty)
return prefix.first.isEmpty() ? cleanPath : prefix.first + cleanPath; return prefix.first.isEmpty() ? cleanPath : prefix.first + cleanPath;
} }
///////////////////////////////////////////////////////////////////////////////
// PARENT PATH
///////////////////////////////////////////////////////////////////////////////
static void remove_trailing_separators(QString &pathStr)
{
while (pathStr.endsWith('/'))
{
pathStr.chop(1);
}
}
MUTILS_API QString MUtils::parent_path(const QString &path)
{
QString parentPath(QDir::fromNativeSeparators(path));
remove_trailing_separators(parentPath);
const int pos = parentPath.lastIndexOf(QLatin1Char('/'));
if (pos >= 0)
{
parentPath.truncate(pos);
remove_trailing_separators(parentPath);
if (parentPath.isEmpty())
{
return QLatin1String("/");
}
if ((parentPath.length() == 2) && parentPath.at(0).isLetter() && (parentPath.at(1) == QLatin1Char(':')))
{
parentPath += QLatin1Char('/');
}
return parentPath;
}
return QString();
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// REGULAR EXPESSION HELPER // REGULAR EXPESSION HELPER
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////