|
Packit |
d7e8d0 |
/*
|
|
Packit |
d7e8d0 |
engineinfo.h
|
|
Packit |
d7e8d0 |
Copyright (C) 2004 Klarälvdalens Datakonsult AB
|
|
Packit |
d7e8d0 |
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
Packit |
d7e8d0 |
Software engineering by Intevation GmbH
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
This file is part of GPGME++.
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
GPGME++ is free software; you can redistribute it and/or
|
|
Packit |
d7e8d0 |
modify it under the terms of the GNU Library General Public
|
|
Packit |
d7e8d0 |
License as published by the Free Software Foundation; either
|
|
Packit |
d7e8d0 |
version 2 of the License, or (at your option) any later version.
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
GPGME++ is distributed in the hope that it will be useful,
|
|
Packit |
d7e8d0 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
d7e8d0 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
d7e8d0 |
GNU Library General Public License for more details.
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
You should have received a copy of the GNU Library General Public License
|
|
Packit |
d7e8d0 |
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
Packit |
d7e8d0 |
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Packit |
d7e8d0 |
Boston, MA 02110-1301, USA.
|
|
Packit |
d7e8d0 |
*/
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#ifndef __GPGMEPP_ENGINEINFO_H__
|
|
Packit |
d7e8d0 |
#define __GPGMEPP_ENGINEINFO_H__
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include "global.h"
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include <memory>
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include <algorithm>
|
|
Packit |
d7e8d0 |
#include <string>
|
|
Packit |
d7e8d0 |
#include <iostream>
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
namespace GpgME
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
class GPGMEPP_EXPORT EngineInfo
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
public:
|
|
Packit |
d7e8d0 |
struct Version
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
int major, minor, patch;
|
|
Packit |
d7e8d0 |
Version()
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
major = 0;
|
|
Packit |
d7e8d0 |
minor = 0;
|
|
Packit |
d7e8d0 |
patch = 0;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
Version(const std::string& version)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
if (version.empty() ||
|
|
Packit |
d7e8d0 |
std::sscanf(version.c_str(), "%d.%d.%d", &major, &minor, &patch) != 3) {
|
|
Packit |
d7e8d0 |
major = 0;
|
|
Packit |
d7e8d0 |
minor = 0;
|
|
Packit |
d7e8d0 |
patch = 0;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
Version(const char *version)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
if (!version ||
|
|
Packit |
d7e8d0 |
std::sscanf(version, "%d.%d.%d", &major, &minor, &patch) != 3) {
|
|
Packit |
d7e8d0 |
major = 0;
|
|
Packit |
d7e8d0 |
minor = 0;
|
|
Packit |
d7e8d0 |
patch = 0;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
bool operator < (const Version& other)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
if (major > other.major ||
|
|
Packit |
d7e8d0 |
(major == other.major && minor > other.minor) ||
|
|
Packit |
d7e8d0 |
(major == other.major && minor == other.minor && patch > other.patch) ||
|
|
Packit |
d7e8d0 |
(major >= other.major && minor >= other.minor && patch >= other.patch)) {
|
|
Packit |
d7e8d0 |
return false;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
return true;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
bool operator < (const char* other)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return operator<(Version(other));
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
bool operator > (const char* other)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return !operator<(Version(other));
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
bool operator > (const Version & other)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return !operator<(other);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
bool operator == (const Version& other)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return major == other.major
|
|
Packit |
d7e8d0 |
&& minor == other.minor
|
|
Packit |
d7e8d0 |
&& patch == other.patch;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
bool operator == (const char* other)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return operator==(Version(other));
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
friend std::ostream& operator << (std::ostream& stream, const Version& ver)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
stream << ver.major;
|
|
Packit |
d7e8d0 |
stream << '.';
|
|
Packit |
d7e8d0 |
stream << ver.minor;
|
|
Packit |
d7e8d0 |
stream << '.';
|
|
Packit |
d7e8d0 |
stream << ver.patch;
|
|
Packit |
d7e8d0 |
return stream;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
};
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
EngineInfo();
|
|
Packit |
d7e8d0 |
explicit EngineInfo(gpgme_engine_info_t engine);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
const EngineInfo &operator=(EngineInfo other)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
swap(other);
|
|
Packit |
d7e8d0 |
return *this;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
void swap(EngineInfo &other)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
using std::swap;
|
|
Packit |
d7e8d0 |
swap(this->d, other.d);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
bool isNull() const;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
Protocol protocol() const;
|
|
Packit |
d7e8d0 |
const char *fileName() const;
|
|
Packit |
d7e8d0 |
const char *version() const;
|
|
Packit |
d7e8d0 |
Version engineVersion() const;
|
|
Packit |
d7e8d0 |
const char *requiredVersion() const;
|
|
Packit |
d7e8d0 |
const char *homeDirectory() const;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
private:
|
|
Packit |
d7e8d0 |
class Private;
|
|
Packit |
d7e8d0 |
std::shared_ptr<Private> d;
|
|
Packit |
d7e8d0 |
};
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(EngineInfo)
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#endif // __GPGMEPP_ENGINEINFO_H__
|