2012-04-09 23:53:46 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 or (at your option)
|
|
|
|
* version 3 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KEEPASSX_TOOLS_H
|
|
|
|
#define KEEPASSX_TOOLS_H
|
|
|
|
|
2015-10-13 22:52:07 +02:00
|
|
|
#include "core/Global.h"
|
|
|
|
|
2013-10-03 15:18:16 +02:00
|
|
|
#include <QDateTime>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
2012-04-09 23:53:46 +02:00
|
|
|
|
2015-10-13 22:52:07 +02:00
|
|
|
#include <algorithm>
|
|
|
|
|
2012-05-02 11:06:24 +02:00
|
|
|
class QIODevice;
|
|
|
|
|
2012-04-09 23:53:46 +02:00
|
|
|
namespace Tools {
|
|
|
|
|
|
|
|
QString humanReadableFileSize(qint64 bytes);
|
2012-04-19 00:04:52 +02:00
|
|
|
bool hasChild(const QObject* parent, const QObject* child);
|
2012-05-10 19:00:36 +02:00
|
|
|
bool readFromDevice(QIODevice* device, QByteArray& data, int size = 16384);
|
2012-05-02 11:06:24 +02:00
|
|
|
bool readAllFromDevice(QIODevice* device, QByteArray& data);
|
2012-05-10 18:09:42 +02:00
|
|
|
QString imageReaderFilter();
|
2012-05-10 18:34:51 +02:00
|
|
|
bool isHex(const QByteArray& ba);
|
2015-11-01 18:30:50 +01:00
|
|
|
bool isBase64(const QByteArray& ba);
|
2012-07-12 13:51:50 +02:00
|
|
|
void sleep(int ms);
|
|
|
|
void wait(int ms);
|
2012-10-13 11:05:50 +02:00
|
|
|
void disableCoreDumps();
|
2015-12-06 14:32:06 +01:00
|
|
|
void setupSearchPaths();
|
2017-02-25 01:12:01 +01:00
|
|
|
bool createWindowsDACL();
|
2012-04-09 23:53:46 +02:00
|
|
|
|
2015-10-13 22:52:07 +02:00
|
|
|
template <typename RandomAccessIterator, typename T>
|
2016-02-13 11:54:54 +01:00
|
|
|
RandomAccessIterator binaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T& value)
|
2015-10-13 22:52:07 +02:00
|
|
|
{
|
|
|
|
RandomAccessIterator it = std::lower_bound(begin, end, value);
|
|
|
|
|
|
|
|
if ((it == end) || (value < *it)) {
|
|
|
|
return end;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-18 22:08:22 +02:00
|
|
|
} // namespace Tools
|
2012-04-09 23:53:46 +02:00
|
|
|
|
|
|
|
#endif // KEEPASSX_TOOLS_H
|