2012-04-09 17:53:46 -04: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 16:52:07 -04:00
|
|
|
#include "core/Global.h"
|
|
|
|
|
2013-10-03 09:18:16 -04:00
|
|
|
#include <QDateTime>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
2012-04-09 17:53:46 -04:00
|
|
|
|
2015-10-13 16:52:07 -04:00
|
|
|
#include <algorithm>
|
|
|
|
|
2012-05-02 05:06:24 -04:00
|
|
|
class QIODevice;
|
|
|
|
|
2012-04-09 17:53:46 -04:00
|
|
|
namespace Tools {
|
|
|
|
|
|
|
|
QString humanReadableFileSize(qint64 bytes);
|
2012-04-18 18:04:52 -04:00
|
|
|
bool hasChild(const QObject* parent, const QObject* child);
|
2012-05-10 13:00:36 -04:00
|
|
|
bool readFromDevice(QIODevice* device, QByteArray& data, int size = 16384);
|
2012-05-02 05:06:24 -04:00
|
|
|
bool readAllFromDevice(QIODevice* device, QByteArray& data);
|
2012-05-10 12:09:42 -04:00
|
|
|
QString imageReaderFilter();
|
2012-05-10 12:34:51 -04:00
|
|
|
bool isHex(const QByteArray& ba);
|
2015-11-01 12:30:50 -05:00
|
|
|
bool isBase64(const QByteArray& ba);
|
2012-07-12 07:51:50 -04:00
|
|
|
void sleep(int ms);
|
|
|
|
void wait(int ms);
|
2012-10-13 05:05:50 -04:00
|
|
|
void disableCoreDumps();
|
2015-12-06 08:32:06 -05:00
|
|
|
void setupSearchPaths();
|
2017-02-24 19:12:01 -05:00
|
|
|
bool createWindowsDACL();
|
2012-04-09 17:53:46 -04:00
|
|
|
|
2015-10-13 16:52:07 -04:00
|
|
|
template <typename RandomAccessIterator, typename T>
|
2016-02-13 05:54:54 -05:00
|
|
|
RandomAccessIterator binaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T& value)
|
2015-10-13 16:52:07 -04:00
|
|
|
{
|
|
|
|
RandomAccessIterator it = std::lower_bound(begin, end, value);
|
|
|
|
|
|
|
|
if ((it == end) || (value < *it)) {
|
|
|
|
return end;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-18 16:08:22 -04:00
|
|
|
} // namespace Tools
|
2012-04-09 17:53:46 -04:00
|
|
|
|
|
|
|
#endif // KEEPASSX_TOOLS_H
|