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=91753ec475dedcd5bdd0052441cfb2babb53c138;hp=2484d6108c4e6f7703e5c2a3a490ed92a88a749b;hb=4ba5510d6ef6ba14ea7d5b3ae61f34f987efe208;hpb=ad051347b86a5334261a15239f65105fdb4eaa25 diff --git a/docs/d5/d3b/_global_8h_source.html b/docs/d5/d3b/_global_8h_source.html index 2484d61..91753ec 100644 --- a/docs/d5/d3b/_global_8h_source.html +++ b/docs/d5/d3b/_global_8h_source.html @@ -67,21 +67,29 @@ $(function() {
Global.h
-Go to the documentation of this file.
1 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2016 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 
36 //MUtils API
37 #ifdef _MSC_VER
38 # ifdef MUTILS_DLL_EXPORT
39 # define MUTILS_API __declspec(dllexport)
40 # else
41 # ifndef MUTILS_STATIC_LIB
42 # define MUTILS_API __declspec(dllimport)
43 # else
44 # define MUTILS_API /*static lib*/
45 # endif
46 # endif
47 #else
48 # define MUTILS_API
49 #endif
50 
51 //Helper Macros
52 #define MUTILS_MAKE_STRING_HELPER(X) #X
53 #define MUTILS_MAKE_STRING(X) MUTILS_MAKE_STRING_HELPER(X)
54 #define MUTILS_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" MUTILS_MAKE_STRING(__LINE__) ") : warning: " TXT))
55 
56 //Check Debug Flags
57 #if defined(_DEBUG) || defined(DEBUG) || (!defined(NDEBUG))
58 # define MUTILS_DEBUG (1)
59 # if defined(NDEBUG) || defined(QT_NO_DEBUG) || (!defined(QT_DEBUG))
60 # error Inconsistent DEBUG flags have been detected!
61 # endif
62 #else
63 # define MUTILS_DEBUG (0)
64 # if (!defined(NDEBUG)) || (!defined(QT_NO_DEBUG)) || defined(QT_DEBUG)
65 # error Inconsistent DEBUG flags have been detected!
66 # endif
67 #endif
68 
69 //Check CPU options
70 #if defined(_MSC_VER) && (!defined(__INTELLISENSE__)) && (!defined(_M_X64)) && defined(_M_IX86_FP)
71  #if (_M_IX86_FP != 0)
72  #error We should not enabled SSE or SSE2 in release builds!
73  #endif
74 #endif
75 
77 
78 namespace MUtils
79 {
87  MUTILS_API const QString& temp_folder(void);
88 
89  //Process Utils
90  MUTILS_API void init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true, const QStringList *const extraPaths = NULL);
91 
99  MUTILS_API quint32 next_rand_u32(void);
100 
108  MUTILS_API quint64 next_rand_u64(void);
109 
119  MUTILS_API QString next_rand_str(const bool &bLong = false);
120 
134  MUTILS_API QString make_temp_file(const QString &basePath, const QString &extension, const bool placeholder = false);
135 
151  MUTILS_API QString make_unique_file(const QString &basePath, const QString &baseName, const QString &extension, const bool fancy = false);
152 
160  MUTILS_API bool parity(quint32 value);
161 
171  MUTILS_API bool remove_file(const QString &fileName);
172 
184  MUTILS_API bool remove_directory(const QString &folderPath, const bool &recursive);
185 
195  MUTILS_API QString& trim_right(QString &str);
196 
206  MUTILS_API QString& trim_left(QString &str);
207 
217  MUTILS_API QString trim_right(const QString &str);
218 
228  MUTILS_API QString trim_left(const QString &str);
229 
239  MUTILS_API void natural_string_sort(QStringList &list, const bool bIgnoreCase);
240 
241  MUTILS_API QString clean_file_name(const QString &name);
242  MUTILS_API QString clean_file_path(const QString &path);
243 
255  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value);
256 
270  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 *values, const size_t &count);
271 
281  MUTILS_API QStringList available_codepages(const bool &noAliases = true);
282 
283  //Internal
284  namespace Internal
285  {
286  MUTILS_API int selfTest(const char *const buildKey, const bool debug);
287  static const int s_selfTest = selfTest(__DATE__ "@" __TIME__, MUTILS_DEBUG);
288  }
289 }
290 
292 
293 //Delete helper
294 #define MUTILS_DELETE(PTR) do { if((PTR)) { delete (PTR); (PTR) = NULL; } } while(0)
295 #define MUTILS_DELETE_ARRAY(PTR) do { if((PTR)) { delete [] (PTR); (PTR) = NULL; } } while(0)
296 
297 //Zero memory
298 #define MUTILS_ZERO_MEMORY(PTR) memset(&(PTR), 0, sizeof((PTR)))
299 
300 //String conversion macros
301 #define MUTILS_WCHR(STR) (reinterpret_cast<const wchar_t*>((STR).utf16()))
302 #define MUTILS_UTF8(STR) ((STR).toUtf8().constData())
303 #define MUTILS_QSTR(STR) (QString::fromUtf16(reinterpret_cast<const unsigned short*>((STR))))
304 
305 //Boolean helper
306 #define MUTILS_BOOL2STR(X) ((X) ? "1" : "0")
bool remove_file(const QString &fileName)
Deletes the specified file.
-
quint32 next_rand_u32(void)
Generates a random unsigned 32-Bit value.
-
bool parity(quint32 value)
Computes the parity of the given unsigned 32-Bit value.
-
QString make_unique_file(const QString &basePath, const QString &baseName, const QString &extension, const bool fancy=false)
Generates a unique file name.
-
const QString & temp_folder(void)
Rerieves the full path of the application&#39;s Temp folder.
-
Definition: CPUFeatures.h:30
-
QString next_rand_str(const bool &bLong=false)
Generates a random string.
-
QString make_temp_file(const QString &basePath, const QString &extension, const bool placeholder=false)
Generates a temporary file name.
-
bool remove_directory(const QString &folderPath, const bool &recursive)
Recursively deletes the specified directory.
-
QString & trim_right(QString &str)
Remove trailing white-space characters.
-
void natural_string_sort(QStringList &list, const bool bIgnoreCase)
Sort a list of strings using "natural ordering" algorithm.
-
QStringList available_codepages(const bool &noAliases=true)
Retrieve a list of all available codepages.
-
QString & trim_left(QString &str)
Remove leading white-space characters.
-
bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value)
Parse regular expression results.
-
quint64 next_rand_u64(void)
Generates a random unsigned 64-Bit value.
+Go to the documentation of this file.
1 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2019 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  //Interface version
42 #define MUTILS_INTERFACE 4
43 
44 //MUtils API
45 #ifdef _MSC_VER
46 # ifdef MUTILS_DLL_EXPORT
47 # define MUTILS_API __declspec(dllexport)
48 # else
49 # ifndef MUTILS_STATIC_LIB
50 # define MUTILS_API __declspec(dllimport)
51 # else
52 # define MUTILS_API /*static lib*/
53 # endif
54 # endif
55 #else
56 # define MUTILS_API
57 #endif
58 
59 //Check Debug Flags
60 #if defined(_DEBUG) || defined(DEBUG) || (!defined(NDEBUG))
61 # define MUTILS_DEBUG (1)
62 # if defined(NDEBUG) || defined(QT_NO_DEBUG) || (!defined(QT_DEBUG))
63 # error Inconsistent DEBUG flags have been detected!
64 # endif
65 #else
66 # define MUTILS_DEBUG (0)
67 # if (!defined(NDEBUG)) || (!defined(QT_NO_DEBUG)) || defined(QT_DEBUG)
68 # error Inconsistent DEBUG flags have been detected!
69 # endif
70 #endif
71 
72 //Check CPU options
73 #if defined(_MSC_VER) && (!defined(__INTELLISENSE__)) && (!defined(_M_X64)) && defined(_M_IX86_FP)
74  #if (_M_IX86_FP != 0)
75  #error We should not enabled SSE or SSE2 in release builds!
76  #endif
77 #endif
78 
79 //Library initializer
80 #define MUTILS_GLUE_NAME_HELPER(X,Y) X##Y
81 #define MUTILS_GLUE_NAME(X,Y) MUTILS_GLUE_NAME_HELPER(X,Y)
82 #if MUTILS_DEBUG
83 #define MUTILS_INITIALIZER MUTILS_GLUE_NAME(initialize_d, MUTILS_INTERFACE)
84 #else
85 #define MUTILS_INITIALIZER MUTILS_GLUE_NAME(initialize_r, MUTILS_INTERFACE)
86 #endif
87 
88 //Compiler warnings
89 #define MUTILS_MAKE_STRING_HELPER(X) #X
90 #define MUTILS_MAKE_STRING(X) MUTILS_MAKE_STRING_HELPER(X)
91 #define MUTILS_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" MUTILS_MAKE_STRING(__LINE__) ") : warning: " TXT))
92 
96 
101 namespace MUtils
102 {
106  typedef struct _fp_parts_t { double parts[2]; } fp_parts_t;
107 
115  MUTILS_API const QString& temp_folder(void);
116 
130  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);
131 
139  MUTILS_API quint32 next_rand_u32(void);
140  MUTILS_API quint32 next_rand_u32(const quint32 max);
141 
149  MUTILS_API quint64 next_rand_u64(void);
150 
160  MUTILS_API QString next_rand_str(const bool &bLong = false);
161 
175  MUTILS_API QString make_temp_file(const QString &basePath, const QString &extension, const bool placeholder = false);
176  MUTILS_API QString make_temp_file(const QDir &basePath, const QString &extension, const bool placeholder = false);
177 
193  MUTILS_API QString make_unique_file(const QString &basePath, const QString &baseName, const QString &extension, const bool fancy = false, const bool placeholder = false);
194  MUTILS_API QString make_unique_file(const QDir &basePath, const QString &baseName, const QString &extension, const bool fancy = false, const bool placeholder = false);
195 
203  MUTILS_API bool parity(quint32 value);
204 
214  MUTILS_API bool remove_file(const QString &fileName);
215 
227  MUTILS_API bool remove_directory(const QString &folderPath, const bool &recursive);
228 
238  MUTILS_API QString& trim_right(QString &str);
239 
249  MUTILS_API QString& trim_left(QString &str);
250 
260  MUTILS_API QString trim_right(const QString &str);
261 
271  MUTILS_API QString trim_left(const QString &str);
272 
282  MUTILS_API void natural_string_sort(QStringList &list, const bool bIgnoreCase);
283 
295  MUTILS_API QString clean_file_name(const QString &name, const bool &pretty);
296 
308  MUTILS_API QString clean_file_path(const QString &path, const bool &pretty);
309 
321  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value);
322  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 &value);
323  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 &value, const size_t &offset);
324  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 &value, const size_t &offset);
325 
335  MUTILS_API QString parent_path(const QString &path);
336 
350  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 *values, const size_t &count);
351  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 *values, const size_t &count);
352  MUTILS_API bool regexp_parse_uint32(const QRegExp &regexp, quint32 *values, const size_t &offset, const size_t &count);
353  MUTILS_API bool regexp_parse_int32(const QRegExp &regexp, qint32 *values, const size_t &offset, const size_t &count);
354 
364  MUTILS_API QStringList available_codepages(const bool &noAliases = true);
365 
375  MUTILS_API fp_parts_t break_fp(const double value);
376 
377  //Internal (do *not* call directly!)
378  namespace Internal
379  {
380  MUTILS_API unsigned int MUTILS_INITIALIZER(const unsigned int interfaceId);
381  static const unsigned int init_flag = MUTILS_INITIALIZER(MUTILS_INTERFACE);
382  }
383 }
384 
386 
389 #define MUTILS_DELETE(PTR) do { if((PTR)) { delete (PTR); (PTR) = NULL; } } while(0)
390 
393 #define MUTILS_DELETE_ARRAY(PTR) do { if((PTR)) { delete [] (PTR); (PTR) = NULL; } } while(0)
394 
397 #define MUTILS_ZERO_MEMORY(PTR) memset(&(PTR), 0, sizeof((PTR)))
398 
401 #define MUTILS_WCHR(STR) (reinterpret_cast<const wchar_t*>((STR).utf16()))
402 
405 #define MUTILS_UTF8(STR) ((STR).toUtf8().constData())
406 
409 #define MUTILS_L1STR(STR) ((STR).toLatin1().constData())
410 
413 #define MUTILS_QSTR(STR) (QString::fromUtf16(reinterpret_cast<const unsigned short*>((STR))))
414 
417 #define MUTILS_BOOL2STR(X) ((X) ? "1" : "0")
418 
421 #define MUTILS_BOOLIFY(X) (!(!(X)))
422 
425 #define MUTILS_ARR2LEN(X) (sizeof((X)) / sizeof((X)[0]))
426 
429 #define MUTILS_NO_COPY(CLASS) \
430  CLASS(const CLASS &) { throw "Copy constructor is disabled!"; } \
431  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:106
+
MUTILS_API QString parent_path(const QString &path)
Get parent path.
+
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 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 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.