X-Git-Url: http://git.osdn.net/view?p=mutilities%2FMUtilities.git;a=blobdiff_plain;f=docs%2Fd5%2Fd3b%2F_global_8h_source.html;h=d958c123d3a2c910f50ccda0d795a05556c5af52;hp=e0b5e307a724403c1d52e68ef5ef5c7f9775d080;hb=bb40ce391c680d61168d1835dd8482a7d02766ca;hpb=b6dd06460847626f268e3fe9e39c5a1a4e7c442c diff --git a/docs/d5/d3b/_global_8h_source.html b/docs/d5/d3b/_global_8h_source.html index e0b5e30..d958c12 100644 --- a/docs/d5/d3b/_global_8h_source.html +++ b/docs/d5/d3b/_global_8h_source.html @@ -67,27 +67,28 @@ $(function() {
Global.h
-Go to the documentation of this file.
1 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 // http://www.gnu.org/licenses/lgpl-2.1.txt
21 
27 #pragma once
28 
29 #include <QString>
30 
31 //Forward Declarations
32 class QProcess;
33 
35 
39 //MUtils API
40 #ifdef _MSC_VER
41 # ifdef MUTILS_DLL_EXPORT
42 # define MUTILS_API __declspec(dllexport)
43 # else
44 # ifndef MUTILS_STATIC_LIB
45 # define MUTILS_API __declspec(dllimport)
46 # else
47 # define MUTILS_API /*static lib*/
48 # endif
49 # endif
50 #else
51 # define MUTILS_API
52 #endif
53 
54 #define MUTILS_MAKE_STRING_HELPER(X) #X
55 #define MUTILS_MAKE_STRING(X) MUTILS_MAKE_STRING_HELPER(X)
56 #define MUTILS_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" MUTILS_MAKE_STRING(__LINE__) ") : warning: " TXT))
57 
58 //Check Debug Flags
59 #if defined(_DEBUG) || defined(DEBUG) || (!defined(NDEBUG))
60 # define MUTILS_DEBUG (1)
61 # if defined(NDEBUG) || defined(QT_NO_DEBUG) || (!defined(QT_DEBUG))
62 # error Inconsistent DEBUG flags have been detected!
63 # endif
64 #else
65 # define MUTILS_DEBUG (0)
66 # if (!defined(NDEBUG)) || (!defined(QT_NO_DEBUG)) || defined(QT_DEBUG)
67 # error Inconsistent DEBUG flags have been detected!
68 # endif
69 #endif
70 
71 //Check CPU options
72 #if defined(_MSC_VER) && (!defined(__INTELLISENSE__)) && (!defined(_M_X64)) && defined(_M_IX86_FP)
73  #if (_M_IX86_FP != 0)
74  #error We should not enabled SSE or SSE2 in release builds!
75  #endif
76 #endif
77 
81 
86 namespace MUtils
87 {
91  typedef struct _fp_parts_t { double parts[2]; } fp_parts_t;
92 
100  MUTILS_API const QString& temp_folder(void);
101 
115  MUTILS_API void init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true, const QStringList *const extraPaths = NULL);
116 
124  MUTILS_API quint32 next_rand_u32(void);
125 
133  MUTILS_API quint64 next_rand_u64(void);
134 
144  MUTILS_API QString next_rand_str(const bool &bLong = false);
145 
159  MUTILS_API QString make_temp_file(const QString &basePath, const QString &extension, const bool placeholder = false);
160 
176  MUTILS_API QString make_unique_file(const QString &basePath, const QString &baseName, const QString &extension, const bool fancy = false);
177 
185  MUTILS_API bool parity(quint32 value);
186 
196  MUTILS_API bool remove_file(const QString &fileName);
197 
209  MUTILS_API bool remove_directory(const QString &folderPath, const bool &recursive);
210 
220  MUTILS_API QString& trim_right(QString &str);
221 
231  MUTILS_API QString& trim_left(QString &str);
232 
242  MUTILS_API QString trim_right(const QString &str);
243 
253  MUTILS_API QString trim_left(const QString &str);
254 
264  MUTILS_API void natural_string_sort(QStringList &list, const bool bIgnoreCase);
265 
277  MUTILS_API QString clean_file_name(const QString &name, const bool &pretty);
278 
290  MUTILS_API QString clean_file_path(const QString &path, const bool &pretty);
291 
303  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value);
304  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 &value);
305  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value, const size_t &offset);
306  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 &value, const size_t &offset);
307 
321  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 *values, const size_t &count);
322  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 *values, const size_t &count);
323  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 *values, const size_t &offset, const size_t &count);
324  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 *values, const size_t &offset, const size_t &count);
325 
335  MUTILS_API QStringList available_codepages(const bool &noAliases = true);
336 
346  MUTILS_API fp_parts_t break_fp(const double value);
347 
348  //Internal
349  namespace Internal
350  {
351  MUTILS_API int selfTest(const char *const buildKey, const bool debug);
352  static const int s_selfTest = selfTest(__DATE__ "@" __TIME__, MUTILS_DEBUG);
353  }
354 }
355 
357 
360 #define MUTILS_DELETE(PTR) do { if((PTR)) { delete (PTR); (PTR) = NULL; } } while(0)
361 
364 #define MUTILS_DELETE_ARRAY(PTR) do { if((PTR)) { delete [] (PTR); (PTR) = NULL; } } while(0)
365 
368 #define MUTILS_ZERO_MEMORY(PTR) memset(&(PTR), 0, sizeof((PTR)))
369 
372 #define MUTILS_WCHR(STR) (reinterpret_cast<const wchar_t*>((STR).utf16()))
373 
376 #define MUTILS_UTF8(STR) ((STR).toUtf8().constData())
377 
380 #define MUTILS_L1STR(STR) ((STR).toLatin1().constData())
381 
384 #define MUTILS_QSTR(STR) (QString::fromUtf16(reinterpret_cast<const unsigned short*>((STR))))
385 
388 #define MUTILS_BOOL2STR(X) ((X) ? "1" : "0")
389 
392 #define MUTILS_BOOLIFY(X) (!(!(X)))
393 
396 #define MUTILS_ARR2LEN(X) (sizeof((X)) / sizeof((X)[0]))
397 
400 #define MUTILS_NO_COPY(CLASS) \
401  CLASS(const CLASS &) { throw "Copy constructor is disabled!"; } \
402  CLASS &operator=(const CLASS &) { throw "Assignment operator is disabled!"; }
MUTILS_API QStringList available_codepages(const bool &noAliases=true)
Retrieve a list of all available codepages.
+Go to the documentation of this file.
1 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 // http://www.gnu.org/licenses/lgpl-2.1.txt
21 
27 #pragma once
28 
29 #include <QString>
30 
31 //Forward Declarations
32 class QProcess;
33 class QDir;
34 template<typename K, typename V> class QHash;
35 
37 
41 //MUtils API
42 #ifdef _MSC_VER
43 # ifdef MUTILS_DLL_EXPORT
44 # define MUTILS_API __declspec(dllexport)
45 # else
46 # ifndef MUTILS_STATIC_LIB
47 # define MUTILS_API __declspec(dllimport)
48 # else
49 # define MUTILS_API /*static lib*/
50 # endif
51 # endif
52 #else
53 # define MUTILS_API
54 #endif
55 
56 #define MUTILS_MAKE_STRING_HELPER(X) #X
57 #define MUTILS_MAKE_STRING(X) MUTILS_MAKE_STRING_HELPER(X)
58 #define MUTILS_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" MUTILS_MAKE_STRING(__LINE__) ") : warning: " TXT))
59 
60 //Check Debug Flags
61 #if defined(_DEBUG) || defined(DEBUG) || (!defined(NDEBUG))
62 # define MUTILS_DEBUG (1)
63 # if defined(NDEBUG) || defined(QT_NO_DEBUG) || (!defined(QT_DEBUG))
64 # error Inconsistent DEBUG flags have been detected!
65 # endif
66 #else
67 # define MUTILS_DEBUG (0)
68 # if (!defined(NDEBUG)) || (!defined(QT_NO_DEBUG)) || defined(QT_DEBUG)
69 # error Inconsistent DEBUG flags have been detected!
70 # endif
71 #endif
72 
73 //Check CPU options
74 #if defined(_MSC_VER) && (!defined(__INTELLISENSE__)) && (!defined(_M_X64)) && defined(_M_IX86_FP)
75  #if (_M_IX86_FP != 0)
76  #error We should not enabled SSE or SSE2 in release builds!
77  #endif
78 #endif
79 
83 
88 namespace MUtils
89 {
93  typedef struct _fp_parts_t { double parts[2]; } fp_parts_t;
94 
102  MUTILS_API const QString& temp_folder(void);
103 
117  MUTILS_API void init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true, const QStringList *const extraPaths = NULL, const QHash<QString, QString> *const extraEnv = NULL);
118 
126  MUTILS_API quint32 next_rand_u32(void);
127  MUTILS_API quint32 next_rand_u32(const quint32 max);
128 
136  MUTILS_API quint64 next_rand_u64(void);
137 
147  MUTILS_API QString next_rand_str(const bool &bLong = false);
148 
162  MUTILS_API QString make_temp_file(const QString &basePath, const QString &extension, const bool placeholder = false);
163  MUTILS_API QString make_temp_file(const QDir &basePath, const QString &extension, const bool placeholder = false);
164 
180  MUTILS_API QString make_unique_file(const QString &basePath, const QString &baseName, const QString &extension, const bool fancy = false, const bool placeholder = false);
181  MUTILS_API QString make_unique_file(const QDir &basePath, const QString &baseName, const QString &extension, const bool fancy = false, const bool placeholder = false);
182 
190  MUTILS_API bool parity(quint32 value);
191 
201  MUTILS_API bool remove_file(const QString &fileName);
202 
214  MUTILS_API bool remove_directory(const QString &folderPath, const bool &recursive);
215 
225  MUTILS_API QString& trim_right(QString &str);
226 
236  MUTILS_API QString& trim_left(QString &str);
237 
247  MUTILS_API QString trim_right(const QString &str);
248 
258  MUTILS_API QString trim_left(const QString &str);
259 
269  MUTILS_API void natural_string_sort(QStringList &list, const bool bIgnoreCase);
270 
282  MUTILS_API QString clean_file_name(const QString &name, const bool &pretty);
283 
295  MUTILS_API QString clean_file_path(const QString &path, const bool &pretty);
296 
308  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value);
309  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 &value);
310  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value, const size_t &offset);
311  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 &value, const size_t &offset);
312 
326  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 *values, const size_t &count);
327  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 *values, const size_t &count);
328  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 *values, const size_t &offset, const size_t &count);
329  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 *values, const size_t &offset, const size_t &count);
330 
340  MUTILS_API QStringList available_codepages(const bool &noAliases = true);
341 
351  MUTILS_API fp_parts_t break_fp(const double value);
352 
353  //Internal
354  namespace Internal
355  {
356  MUTILS_API int selfTest(const char *const buildKey, const bool debug);
357  static const int s_selfTest = selfTest(__DATE__ "@" __TIME__, MUTILS_DEBUG);
358  }
359 }
360 
362 
365 #define MUTILS_DELETE(PTR) do { if((PTR)) { delete (PTR); (PTR) = NULL; } } while(0)
366 
369 #define MUTILS_DELETE_ARRAY(PTR) do { if((PTR)) { delete [] (PTR); (PTR) = NULL; } } while(0)
370 
373 #define MUTILS_ZERO_MEMORY(PTR) memset(&(PTR), 0, sizeof((PTR)))
374 
377 #define MUTILS_WCHR(STR) (reinterpret_cast<const wchar_t*>((STR).utf16()))
378 
381 #define MUTILS_UTF8(STR) ((STR).toUtf8().constData())
382 
385 #define MUTILS_L1STR(STR) ((STR).toLatin1().constData())
386 
389 #define MUTILS_QSTR(STR) (QString::fromUtf16(reinterpret_cast<const unsigned short*>((STR))))
390 
393 #define MUTILS_BOOL2STR(X) ((X) ? "1" : "0")
394 
397 #define MUTILS_BOOLIFY(X) (!(!(X)))
398 
401 #define MUTILS_ARR2LEN(X) (sizeof((X)) / sizeof((X)[0]))
402 
405 #define MUTILS_NO_COPY(CLASS) \
406  CLASS(const CLASS &) { throw "Copy constructor is disabled!"; } \
407  CLASS &operator=(const CLASS &) { throw "Assignment operator is disabled!"; }
MUTILS_API QStringList available_codepages(const bool &noAliases=true)
Retrieve a list of all available codepages.
struct MUtils::_fp_parts_t fp_parts_t
This struct containes the parts (integral and fractional part) of a floating-point number...
MUTILS_API QString next_rand_str(const bool &bLong=false)
Generates a random string.
MUTILS_API bool remove_file(const QString &fileName)
Deletes the specified file.
MUTILS_API QString clean_file_path(const QString &path, const bool &pretty)
Clean up a file path string.
-
This struct containes the parts (integral and fractional part) of a floating-point number...
Definition: Global.h:91
+
This struct containes the parts (integral and fractional part) of a floating-point number...
Definition: Global.h:93
MUTILS_API void natural_string_sort(QStringList &list, const bool bIgnoreCase)
Sort a list of strings using "natural ordering" algorithm.
MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value)
Parse regular expression results.
MUTILS_API bool parity(quint32 value)
Computes the parity of the given unsigned 32-Bit value.
MUTILS_API fp_parts_t break_fp(const double value)
Break floating-point number into fractional and integral parts.
MUTILS_API quint64 next_rand_u64(void)
Generates a random unsigned 64-Bit value.
-
MUTILS_API void init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir=true, const QStringList *const extraPaths=NULL)
Initialize a given QProcess object.
MUTILS_API QString & trim_right(QString &str)
Remove trailing white-space characters.
MUTILS_API const QString & temp_folder(void)
Rerieves the full path of the application&#39;s Temp folder.
Global MUtils namespace.
Definition: CPUFeatures.h:37
MUTILS_API QString clean_file_name(const QString &name, const bool &pretty)
Clean up a file name string.
MUTILS_API quint32 next_rand_u32(void)
Generates a random unsigned 32-Bit value.
-
MUTILS_API QString make_unique_file(const QString &basePath, const QString &baseName, const QString &extension, const bool fancy=false)
Generates a unique file name.
MUTILS_API bool remove_directory(const QString &folderPath, const bool &recursive)
Recursively deletes the specified directory.
MUTILS_API QString make_temp_file(const QString &basePath, const QString &extension, const bool placeholder=false)
Generates a temporary file name.
+
MUTILS_API void init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir=true, const QStringList *const extraPaths=NULL, const QHash< QString, QString > *const extraEnv=NULL)
Initialize a given QProcess object.
MUTILS_API QString & trim_left(QString &str)
Remove leading white-space characters.
+
Definition: Global.h:34
+
MUTILS_API QString make_unique_file(const QString &basePath, const QString &baseName, const QString &extension, const bool fancy=false, const bool placeholder=false)
Generates a unique file name.