[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
klfutil.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * file klfutil.cpp
3 * This file is part of the KLatexFormula Project.
4 * Copyright (C) 2011 by Philippe Faist
5 * philippe.faist at bluewin.ch
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
22/* $Id$ */
23
24#include <stdlib.h>
25
26#include <QFile>
27#include <QDir>
28#include <QLibraryInfo>
29#include <QUrl>
30#include <QUrlQuery>
31#include <QMessageBox>
32#include <QPushButton>
33#include <QApplication>
34#include <QDesktopWidget>
35#include <QProcess>
36
37#include "klfutil.h"
38#include "klfsysinfo.h"
39
40
42{
43 if ( ! QDir(dir).exists() ) {
44 bool r = QDir("/").mkpath(dir);
45 if ( ! r ) {
46 qWarning("Can't create local directory %s!", qPrintable(dir));
47 return false;
48 }
49 // set permissions to "rwx------"
50 r = QFile::setPermissions(dir, QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner|
51 QFile::ReadUser|QFile::WriteUser|QFile::ExeUser);
52 if ( ! r ) {
53 qWarning("Can't set permissions to local config directory `%s' !", qPrintable(dir));
54 return false;
55 }
56 }
57 return true;
58}
59
60
61
62static QMap<QString,QString> klf_url_query_items_map(const QUrl& url,
63 const QStringList& interestQueryItems)
64{
67 int k;
68 for (k = 0; k < qitems.size(); ++k) {
69 const QPair<QString,QString>& p = qitems[k];
70 if (interestQueryItems.isEmpty() || interestQueryItems.contains(p.first))
71 map[p.first] = p.second;
72 }
73 return map;
74}
75
76
77
78KLF_EXPORT uint klfUrlCompare(const QUrl& url1, const QUrl& url2, uint interestFlags,
79 const QStringList& interestQueryItems)
80{
81 KLF_DEBUG_BLOCK(KLF_FUNC_NAME);
82 klfDbg( ": 1="<<url1<<"; 2="<<url2<<"; interestflags="<<interestFlags<<"; int.q.i="
83 <<interestQueryItems ) ;
84 uint compareflags = 0x00;
85
86 Qt::CaseSensitivity queryItemValsCS = Qt::CaseSensitive;
88 queryItemValsCS = Qt::CaseInsensitive;
89
90 QMap<QString,QString> qitems_map1;
91 QMap<QString,QString> qitems_map2;
92
93 QUrl u1 = url1;
94 QUrl u2 = url2;
95 u1.setQuery("");
96 u2.setQuery("");
97
98 klfDbg( " after q-i-stripping: u1="<<u1<<"; u2="<<u2 ) ;
99
100 if (interestFlags &
102 // have an operation that needs these maps, so load them
103 qitems_map1 = klf_url_query_items_map(url1, interestQueryItems);
104 qitems_map2 = klf_url_query_items_map(url2, interestQueryItems);
105 }
106
107 if (interestFlags & KlfUrlCompareEqual) {
108 // test equality
109 if (u1 == u2 && qitems_map1 == qitems_map2)
110 compareflags |= KlfUrlCompareEqual;
111 }
112
113 if (interestFlags & KlfUrlCompareLessSpecific) {
114 // test url1 is less specific than url2 <-> url1 items are included in those of url2
115 if (u1 == u2) {
116 bool ok = klfMapIsIncludedIn(qitems_map1, qitems_map2, queryItemValsCS);
117 if (ok)
118 compareflags |= KlfUrlCompareLessSpecific;
119 }
120 }
121 if (interestFlags & KlfUrlCompareMoreSpecific) {
122 // test url1 is more specific than url2 <-> url2 items are included in those of url1
123 if (u1 == u2) {
124 bool ok = klfMapIsIncludedIn(qitems_map2, qitems_map1, queryItemValsCS);
125 if (ok)
126 compareflags |= KlfUrlCompareMoreSpecific;
127 }
128 }
129
130 if (interestFlags & KlfUrlCompareBaseEqual) {
131 if (u1 == u2)
132 compareflags |= KlfUrlCompareBaseEqual;
133 }
134
135 klfDbg( "... and the result is compareflags="<<compareflags ) ;
136 return compareflags;
137}
138
139
140// ------------------------------------------------------------
141
142
143
144// ignores: flags: Recurse, Wrap. (!)
145KLF_EXPORT bool klfMatch(const QVariant& testForHitCandidateValue, const QVariant& queryValue,
146 Qt::MatchFlags flags, const QString& queryStringCache /* = QString()*/)
147{
148 //
149 // *** NOTE ***
150 // code inspired from Qt's QAbstractItemModel::match() defined in
151 // src/corelib/kernel/qabstractitemmodel.cpp
152 //
153
154 uint matchType = flags & 0x0F;
155 Qt::CaseSensitivity cs = (flags & Qt::MatchCaseSensitive)
156 ? Qt::CaseSensitive
157 : Qt::CaseInsensitive;
158
159 const QVariant& v = testForHitCandidateValue; // the name is a bit long :)
160
161 // QVariant based matching
162 if (matchType == Qt::MatchExactly)
163 return (queryValue == v);
164
165 // QString based matching
166 QString text = !queryStringCache.isNull() ? queryStringCache : queryValue.toString();
167 QString t = v.toString();
168 switch (matchType) {
169 case Qt::MatchRegExp:
170 return (QRegExp(text, cs).exactMatch(t));
171 case Qt::MatchWildcard:
172 return (QRegExp(text, cs, QRegExp::Wildcard).exactMatch(t));
173 case Qt::MatchStartsWith:
174 return (t.startsWith(text, cs));
175 case Qt::MatchEndsWith:
176 return (t.endsWith(text, cs));
177 case Qt::MatchFixedString:
178 return (QString::compare(t, text, cs) == 0);
179 case Qt::MatchContains:
180 default:
181 return (t.contains(text, cs));
182 }
183}
184
185
186// ----------------------------------------------------
187
188
189// negative limit means "no limit"
190static QStringList __search_find_test(const QString& root, const QStringList& pathlist,
191 int level, int limit)
192{
193 if (limit == 0)
194 return QStringList();
195
196 if (limit < 0)
197 limit = -1; // normalize negative values to -1 (mostly cosmetic...)
198
199 klfDebugf(("root=`%s', pathlist=`%s', level=%d, limit=%d", qPrintable(root), qPrintable(pathlist.join("\t")),
200 level, limit));
201
202 QStringList newpathlist = pathlist;
203 // our level: levelpathlist contains items in pathlist from 0 to level-1 inclusive.
204 QStringList levelpathlist;
205 int k;
206 for (k = 0; k < level; ++k) { levelpathlist << newpathlist[k]; }
207 // the dir/file at our level:
208 QString flpath = root+levelpathlist.join("/");
209 klfDebugf(("our path = `%s' ...", qPrintable(flpath)));
210 QFileInfo flinfo(flpath);
211 if (flinfo.isDir() && level < pathlist.size()) { // is dir, and we still have path level to explore
212 klfDebugf(("... is dir.")) ;
213 QDir d(flpath);
214 QStringList entries;
215 entries = d.entryList(QStringList()<<pathlist[level], QDir::AllEntries|QDir::System|QDir::Hidden);
216 if (entries.size()) {
217 klfDebugf(("got entry list: %s", qPrintable(entries.join("\t"))));
218 }
219 QStringList hitlist;
220 for (k = 0; k < (int)entries.size(); ++k) {
221 newpathlist[level] = entries[k];
222 hitlist += __search_find_test(root, newpathlist, level+1, limit - hitlist.size());
223 if (limit >= 0 && (int)hitlist.size() >= limit) // reached limit
224 break;
225 }
226 return hitlist;
227 }
228 if (flinfo.exists()) {
229 klfDebugf(("... is existing file.")) ;
230 return QStringList() << QDir::toNativeSeparators(root+pathlist.join("/"));
231 }
232 klfDebugf(("... is invalid.")) ;
233 return QStringList();
234}
235
236
237
238
239
240
241
242
243KLF_EXPORT QStringList klfSearchFind(const QString& wildcard_expression, int limit)
244{
245 klfDbg("looking for "+wildcard_expression) ;
246
247 QString expr;
248 expr = QDir::fromNativeSeparators(wildcard_expression);
249 QStringList pathlist = expr.split("/", QString::SkipEmptyParts);
250 QString root = "/";
251 // drive regular expression, or simply QResource :/path
252 static QRegExp driveregexp("^[A-Za-z]?:$");
253 if (driveregexp.exactMatch(pathlist[0])) {
254 // Windows System with X: drive letter
255 root = pathlist[0]+"/";
256 pathlist.pop_front();
257 }
258 return __search_find_test(root, pathlist, 0, limit);
259}
260
261KLF_EXPORT QString klfSearchPath(const QString& programName, const QString& extra_path)
262{
263 KLF_DEBUG_BLOCK(KLF_FUNC_NAME) ;
264
265 static const QString PATH = getenv("PATH");
266 static const QString pathsep = QString("")+KLF_PATH_SEP;
267
268 QFileInfo fi(programName);
269 if (fi.isAbsolute() && fi.exists() && fi.isExecutable())
270 return programName;
271
272
273 QString path = PATH;
274 if (!extra_path.isEmpty())
275 path = extra_path + pathsep + path;
276
277 const QStringList paths = path.split(pathsep, QString::KeepEmptyParts);
278 QString test;
279 int k, j;
280 for (k = 0; k < (int)paths.size(); ++k) {
281 klfDbg("searching for "<<programName<<" in "<<paths[k]) ;
282 QStringList hits = klfSearchFind(paths[k]+"/"+programName);
283 klfDbg("\t...resulting in hits = "<<hits) ;
284 for (j = 0; j < (int)hits.size(); ++j) {
285 if ( QFileInfo(hits[j]).isExecutable() ) {
286 klfDbg("\tFound definitive (executable) hit at "+hits[j]) ;
287 return hits[j];
288 }
289 }
290 }
291 return QString::null;
292}
293
295{
296 KLF_DEBUG_BLOCK(KLF_FUNC_NAME) ;
297
298 if (QFileInfo(fname).isAbsolute() && QFile::exists(fname))
299 return fname;
300
301 QString test;
302 int k;
303 QStringList hits;
304 for (k = 0; k < (int)paths.size(); ++k) {
305 klfDbg("searching for "<<fname<<" in "<<paths[k]) ;
306 hits = klfSearchFind(paths[k]+"/"+fname);
307 klfDbg("\t...resulting in hits = "<<hits) ;
308 if (hits.size() > 0) {
309 klfDbg("\t...returning "<<hits[0]);
310 return hits[0];
311 }
312 }
313 return QString::null;
314}
315
317{
318 KLF_DEBUG_BLOCK(KLF_FUNC_NAME) ;
319
320 QString path = path_;
321 QString ref = ref_;
322
323 klfDbg("path="<<path<<"; reference="<<ref) ;
324
325 if (path == "~") {
326 return QDir::homePath();
327 }
328 if (path.startsWith("~/")) {
329 path = QDir::homePath() + "/" + path.mid(2);
330 }
331
332 QFileInfo fi(path);
333
334 if (fi.isAbsolute()) {
335 return fi.absoluteFilePath();
336 }
337
338 if (!ref.isEmpty()) {
339 if (ref == "~") {
340 ref = QDir::homePath();
341 } else if (ref.startsWith("~/")) {
342 ref = QDir::homePath() + "/" + path.mid(2);
343 }
344 ref = QFileInfo(ref).absoluteFilePath();
345 } else {
347 }
348
349 // return path relative to reference
350 if (!ref.endsWith("/")) {
351 ref += "/";
352 }
353 klfDbg("reference is "<<ref) ;
354
355 QString result = QFileInfo(ref + path).absoluteFilePath();
356 klfDbg("result = " << result) ;
357 return result;
358}
359
360
361// -----------------------------------------------------
362
363
365{
366 QString vareq = var + QLatin1String("=");
367 // search for declaration of var in list
368 int k;
369 for (k = 0; k < env.size(); ++k) {
370 if (env[k].startsWith(vareq)) {
371 return env[k].mid(vareq.length());
372 }
373 }
374 // declaration not found. Return null QString().
375 return QString();
376}
377
379 const QString& value)
380{
381 QString vareq = var + QLatin1String("=");
382 // search for declaration of var in list
383 int k;
384 for (k = 0; k < env->size(); ++k) {
385 if (env->operator[](k).startsWith(vareq)) {
386 env->operator[](k) = vareq+value;
387 return;
388 }
389 }
390 // declaration not found, just append
391 env->append(vareq+value);
392 return;
393}
394
396 const QString& value)
397{
398 QStringList env2 = env;
399 klfSetEnvironmentVariable(&env2, var, value);
400 return env2;
401}
402
404{
405 QStringList list;
406 for (QMap<QString,QString>::const_iterator it = map.begin(); it != map.end(); ++it)
407 list << it.key() + "=" + it.value();
408 return list;
409}
410
411static bool parse_env_line(const QString& s, QString * var, QString * val)
412{
413 KLF_ASSERT_NOT_NULL(var, "var argument is NULL!", return false; ) ;
414 KLF_ASSERT_NOT_NULL(val, "val argument is NULL!", return false; ) ;
415 int i = s.indexOf('=');
416 if (i == -1) {
417 *var = *val = QString();
418 klfWarning("Line "<<s<<" is not an environment variable setting.") ;
419 return false;
420 }
421 *var = s.mid(0, i);
422 *val = s.mid(i+1);
423 return true;
424}
425
427{
429
430 foreach (QString s, env) {
431 QString var, val;
432 if (!parse_env_line(s, &var, &val))
433 continue; // warning already issued
434 if (map.contains(var))
435 klfWarning("Line "<<s<<" will overwrite previous value of variable "<<var) ;
436 map[var] = val;
437 }
438
439 return map;
440}
441
442
443void klfMergeEnvironment(QStringList * env, const QStringList& addvars, const QStringList& pathvars, uint actions)
444{
445 KLF_DEBUG_BLOCK(KLF_FUNC_NAME) ;
446 foreach (QString s, addvars) {
447 QString var, val;
448 if (!parse_env_line(s, &var, &val))
449 continue; // warning issued already
450
451 if (actions & KlfEnvMergeExpandVars) {
453 }
454 if (pathvars.contains(var)) {
455 // this variable is a PATH, special treatment: prepend new values to old ones
456 val = klfSetEnvironmentPath(klfGetEnvironmentVariable(*env, var), val, actions);
457 }
458
459 klfSetEnvironmentVariable(env, var, val);
460 }
461}
462
464 const QStringList& pathvars, uint actions)
465{
466 KLF_DEBUG_BLOCK(KLF_FUNC_NAME) ;
467 QStringList merged = env;
468 klfMergeEnvironment(&merged, addvars, pathvars, actions);
469 return merged;
470}
471
472
474{
475 QString value = klfGetEnvironmentVariable(env, var);
476 // split value according to PATH_SEP
477 return klfSplitEnvironmentPath(value);
478}
479
481{
482 if (value.isEmpty())
483 return QStringList();
484 QStringList items = value.split(KLF_PATH_SEP, QString::KeepEmptyParts);
485
486 // with KeepEmptyParts, if there is a trailing or leading colon, then two empty parts
487 // will (probably) be generated. remove one of them.
488 if (items.size() >= 2) {
489 if (items[0].isEmpty() && items[1].isEmpty())
490 items.removeAt(0);
491 if (items[items.size()-1].isEmpty() && items[items.size()-2].isEmpty())
492 items.removeAt(items.size()-1);
493 }
494 return items;
495}
496
498{
499 return paths.join(QString("")+KLF_PATH_SEP);
500}
501
502/*
503 enum KlfEnvPathAction {
504 KlfEnvPathPrepend = 0x0001, //!< Prepend given value to list of path items
505 KlfEnvPathReplace = 0x0002, //!< Replace current path items by given ones
506 KlfEnvPathAppend = 0x0003, //!< Append given path items to current list
507 KlfEnvPathNoAction = 0x0000, //!< Don't take any action, just apply flags
508 KlfEnvPathActionMask = 0x00ff, //!< Mask out the requested action
509 KlfEnvPathNoDuplicates = 0x0100, //!< Remove duplicates from the variable
510 KlfEnvPathFlagsMask = 0xff00, //!< Mask out the flags
511 };
512*/
513
514QStringList klfSetEnvironmentPath(const QStringList& oldpaths, const QStringList& newpaths, uint action)
515{
516 QStringList newitems;
517 switch (action & KlfEnvPathActionMask) {
519 newitems = QStringList() << newpaths << oldpaths;
520 break;
521 case KlfEnvPathAppend:
522 newitems = QStringList() << oldpaths << newpaths;
523 break;
525 newitems = newpaths;
526 break;
528 newitems = oldpaths;
529 break;
530 default:
531 klfWarning("No or unknown action specified! action="<<action) ;
532 break;
533 }
534 if (action & KlfEnvPathNoDuplicates) {
535 // remove duplicates from newitems
536 QStringList newitems2;
537 int k;
538 for (k = 0; k < newitems.size(); ++k) {
539 if (newitems2.contains(newitems[k]))
540 continue;
541 newitems2.append(newitems[k]);
542 }
543 newitems = newitems2;
544 }
545 return newitems;
546}
547
548QString klfSetEnvironmentPath(const QString& oldpaths, const QString& newpaths, uint action)
549{
551 klfSplitEnvironmentPath(newpaths),
552 action) . join(QString("")+KLF_PATH_SEP);
553}
554
556 const QString& var, uint action)
557{
558 QStringList newval;
559 newval = klfSetEnvironmentPath(klfGetEnvironmentPath(env, var), newpaths, action);
560 return klfSetEnvironmentVariable(env, var, klfJoinEnvironmentPath(newval));
561}
562
564 const QString& var, uint action)
565{
566 QStringList newval;
567 newval = klfSetEnvironmentPath(klfGetEnvironmentPath(*env, var), newpaths, action);
569}
570
571
572static QString __klf_expandenvironmentvariables(const QString& expression, const QStringList& env,
573 bool recursive, const QStringList& recstack)
574{
575 QString s = expression;
576 QRegExp rx("\\$(?:(\\$|(?:[A-Za-z0-9_]+))|\\{([A-Za-z0-9_]+)\\})");
577 int i = 0;
578 while ( (i = rx.indexIn(s, i)) != -1 ) {
579 // match found, replace it
580 QString envvarname = rx.cap(1);
581 if (envvarname.isEmpty() || envvarname == QLatin1String("$")) {
582 // note: empty variable name expands to a literal '$'
583 s.replace(i, rx.matchedLength(), QLatin1String("$"));
584 i += 1;
585 continue;
586 }
587 // if we're already expanding the value of this variable at some higher recursion level, abort
588 // this replacement and leave the variable name.
589 if (recstack.contains(envvarname)) {
590 klfWarning("Recursive definition detected for variable "<<envvarname<<"!") ;
591 i += rx.matchedLength();
592 continue;
593 }
594 // get the environment variable's value
595 QString val;
596 if (env.isEmpty()) {
597 const char *svalue = getenv(qPrintable(envvarname));
598 val = (svalue != NULL) ? QString::fromLocal8Bit(svalue) : QString();
599 } else {
600 val = klfGetEnvironmentVariable(env, envvarname);
601 }
602 // if recursive, perform replacements on its value
603 if (recursive) {
604 val = __klf_expandenvironmentvariables(val, env, true, QStringList()<<recstack<<envvarname) ;
605 }
606 klfDbg("Replaced value of "<<envvarname<<" is "<<val) ;
607 s.replace(i, rx.matchedLength(), val);
608 i += val.length();
609 }
610 // replacements performed
611 return s;
612}
613
615 bool recursive)
616{
617 return __klf_expandenvironmentvariables(expression, env, recursive, QStringList());
618}
619
620
625
626
627
628
629
630
631
632// ----------------------------------------------------
633
635{
636#ifdef Q_OS_WIN32
637 QString p = url.path();
638 if (p.startsWith("/"))
639 p = p.mid(1);
640 return p;
641#else
642 return url.path();
643#endif
644}
645
646// ------------------------------------------------------
647
649{
650 KLF_DEBUG_BLOCK(KLF_FUNC_NAME) ;
651
652 int k;
653 const QList<KLFTargeter*> targeters = pTargetOf;
654 for (k = 0; k < targeters.size(); ++k) {
655 targeters[k]->pTarget = NULL;
656 }
657}
658
660{
661 KLF_DEBUG_BLOCK(KLF_FUNC_NAME) ;
662
663 if (pTarget != NULL)
665}
666
668{
669 KLF_DEBUG_BLOCK(KLF_FUNC_NAME) ;
670 klfDbg("target="<<target) ;
671
672 if (pTarget != NULL)
674
675 pTarget = target;
676
677 if (pTarget != NULL)
678 pTarget->pTargetOf.append(this);
679}
virtual ~KLFTarget()
Definition klfutil.cpp:648
QList< KLFTargeter * > pTargetOf
Definition klfutil.h:518
KLFTarget * pTarget
Definition klfutil.h:530
virtual void setTarget(KLFTarget *target)
Definition klfutil.cpp:667
virtual ~KLFTargeter()
Definition klfutil.cpp:659
#define klfWarning(streamableItems)
Definition klfdebug.h:171
#define KLF_DEBUG_BLOCK(msg)
Utility to debug the execution of a block.
Definition klfdebug.h:152
#define KLF_ASSERT_NOT_NULL(ptr, msg, failaction)
Asserting Non-NULL pointers (NON-FATAL)
Definition klfdebug.h:210
#define klfDbg(streamableItems)
print debug stream items
Definition klfdebug.h:158
#define klfDebugf(arglist)
print debug stream items
Definition klfdebug.h:156
#define KLF_EXPORT
Definition klfdefs.h:41
#define KLF_PATH_SEP
The character used in the $PATH environment variable to separate different locations.
Definition klfsysinfo.h:64
KLF_EXPORT QStringList klfSearchFind(const QString &wildcard_expression, int limit)
Find files matching a path with wildcards.
Definition klfutil.cpp:243
KLF_EXPORT void klfSetEnvironmentVariable(QStringList *env, const QString &var, const QString &value)
set the value of a variable in environment variables list, replacing existing definition if any.
Definition klfutil.cpp:378
KLF_EXPORT QString klfPrefixedPath(const QString &path_, const QString &ref_)
Returns absolute path to path as seen from reference.
Definition klfutil.cpp:316
void klfMergeEnvironment(QStringList *env, const QStringList &addvars, const QStringList &pathvars, uint actions)
merge two environment definitions
Definition klfutil.cpp:443
QStringList klfMapToEnvironmentList(const QMap< QString, QString > &map)
convert a map of variable names to values to an environment list
Definition klfutil.cpp:403
QString klfExpandEnvironmentVariables(const QString &expression, const QStringList &env, bool recursive)
Expands references to environment variables to their values.
Definition klfutil.cpp:614
KLF_EXPORT QStringList klfCurrentEnvironment()
Returns the current system's environment.
Definition klfutil.cpp:621
KLF_EXPORT uint klfUrlCompare(const QUrl &url1, const QUrl &url2, uint interestFlags, const QStringList &interestQueryItems)
Compares two URLs and returns some flags as to how they differ.
Definition klfutil.cpp:78
QStringList klfSetEnvironmentPath(const QStringList &oldpaths, const QStringList &newpaths, uint action)
set/add path items to a PATH-like environment variable (commonly $PATH)
Definition klfutil.cpp:514
QString klfJoinEnvironmentPath(const QStringList &paths)
join several paths together to form a PATH-like environment variable value (common for $PATH)
Definition klfutil.cpp:497
QStringList klfGetEnvironmentPath(const QStringList &env, const QString &var)
get the path items of an environment variable (commonly $PATH)
Definition klfutil.cpp:473
QString klfGetEnvironmentVariable(const QStringList &env, const QString &var)
returns the value of an environment variable, defined in env.
Definition klfutil.cpp:364
KLF_EXPORT QString klfUrlLocalFilePath(const QUrl &url)
Definition klfutil.cpp:634
QMap< QString, QString > klfEnvironmentListToMap(const QStringList &env)
convert environment list into a map of variable names to values
Definition klfutil.cpp:426
KLF_EXPORT QString klfSearchPath(const QString &programName, const QString &extra_path)
Smart executable searching in a given path list with wildcards.
Definition klfutil.cpp:261
KLF_EXPORT bool klfEnsureDir(const QString &dir)
Ensure existence of a directory.
Definition klfutil.cpp:41
QStringList klfSplitEnvironmentPath(const QString &value)
split the value of a PATH-like environment variable into paths (common for $PATH)
Definition klfutil.cpp:480
KLF_EXPORT bool klfMatch(const QVariant &testForHitCandidateValue, const QVariant &queryValue, Qt::MatchFlags flags, const QString &queryStringCache)
Generalized value matching.
Definition klfutil.cpp:145
bool klfMapIsIncludedIn(const QMap< Key, Value > &a, const QMap< Key, Value > &b, ValCompareFunc cfunc=klfEqualFunc< Value >())
Compares two QMap's for inclusion.
Definition klfutil.h:82
@ KlfEnvPathNoAction
Don't take any action, just apply flags.
Definition klfutil.h:307
@ KlfEnvPathNoDuplicates
Remove duplicates from the variable.
Definition klfutil.h:309
@ KlfEnvPathPrepend
Prepend given value to list of path items.
Definition klfutil.h:304
@ KlfEnvMergeExpandNotRecursive
If we're expanding new environment variables, don't expand them recursively.
Definition klfutil.h:315
@ KlfEnvMergeExpandVars
Merge environments by expanding new values according to current environment.
Definition klfutil.h:313
@ KlfEnvPathAppend
Append given path items to current list.
Definition klfutil.h:306
@ KlfEnvPathActionMask
Mask out the requested action.
Definition klfutil.h:308
@ KlfEnvPathReplace
Replace current path items by given ones.
Definition klfutil.h:305
@ klfUrlCompareFlagIgnoreQueryItemValueCase
This is NOT a specific test. It modifies the behavior of klfUrlCompare() by instructing it to compare...
Definition klfutil.h:139
@ KlfUrlCompareEqual
Urls are equal. The order of query items may be different, but the same are given with the same value...
Definition klfutil.h:123
@ KlfUrlCompareBaseEqual
Urls have same base URL. Query items are ignored.
Definition klfutil.h:133
@ KlfUrlCompareMoreSpecific
Urls have same base URL. All query items in url2 are present in url1 with the same values,...
Definition klfutil.h:131
@ KlfUrlCompareLessSpecific
Urls have same base URL. All query items in url1 are present in url2 with the same values,...
Definition klfutil.h:127
QString applicationDirPath()
QString fromNativeSeparators(const QString &pathName)
QString homePath()
bool mkpath(const QString &dirPath) const
QString toNativeSeparators(const QString &pathName)
bool exists() const
virtual bool setPermissions(Permissions permissions)
QString absoluteFilePath() const
bool exists() const
bool isAbsolute() const
bool isExecutable() const
void append(const T &value)
bool isEmpty() const
QList< T > mid(int pos, int length) const
void pop_front()
int removeAll(const T &value)
void removeAt(int i)
int size() const
bool startsWith(const T &value) const
T value(int i) const
iterator begin()
bool contains(const Key &key) const
iterator end()
QStringList systemEnvironment()
bool exactMatch(const QString &str) const
int compare(const QString &other, Qt::CaseSensitivity cs) const
bool contains(QChar ch, Qt::CaseSensitivity cs) const
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
QString fromLocal8Bit(const char *str, int size)
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
bool isEmpty() const
bool isNull() const
int length() const
QString mid(int position, int n) const
QString & replace(int position, int n, QChar after)
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QString join(const QString &separator) const
typedef MatchFlags
QString path(ComponentFormattingOptions options) const
void setQuery(const QString &query, ParsingMode mode)
QList< QPair< QString, QString > > queryItems(QUrl::ComponentFormattingOptions encoding) const
QString toString() const

Generated by doxygen 1.10.0