PDF4QT/Pdf4QtLib/sources/pdfnametounicode.h

65 lines
2.1 KiB
C
Raw Normal View History

2021-04-30 20:12:10 +02:00
// Copyright (C) 2018-2021 Jakub Melka
2019-03-25 18:44:45 +01:00
//
2020-12-20 19:03:58 +01:00
// This file is part of Pdf4Qt.
2019-03-25 18:44:45 +01:00
//
2020-12-20 19:03:58 +01:00
// Pdf4Qt is free software: you can redistribute it and/or modify
2019-03-25 18:44:45 +01:00
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
2021-04-30 20:12:10 +02:00
// with the written consent of the copyright owner, any later version.
2019-03-25 18:44:45 +01:00
//
2020-12-20 19:03:58 +01:00
// Pdf4Qt is distributed in the hope that it will be useful,
2019-03-25 18:44:45 +01:00
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
2020-12-20 19:03:58 +01:00
// along with Pdf4Qt. If not, see <https://www.gnu.org/licenses/>.
2019-03-25 18:44:45 +01:00
#ifndef PDFNAMETOUNICODE_H
#define PDFNAMETOUNICODE_H
#include "pdfglobal.h"
#include <QChar>
#include <QByteArray>
namespace pdf
{
2020-12-20 19:03:58 +01:00
class Pdf4QtLIBSHARED_EXPORT PDFNameToUnicode
2019-03-25 18:44:45 +01:00
{
public:
explicit PDFNameToUnicode() = delete;
/// Returns unicode character for name. If name is not found, then null character is returned.
static QChar getUnicodeForName(const QByteArray& name);
/// Returns unicode character for name (for ZapfDingbats). If name is not found, then null character is returned.
static QChar getUnicodeForNameZapfDingbats(const QByteArray& name);
2019-04-30 14:39:48 +02:00
/// Tries to resolve unicode name
static QChar getUnicodeUsingResolvedName(const QByteArray& name);
2019-03-25 18:44:45 +01:00
private:
struct Comparator
{
inline bool operator()(const QByteArray& left, const std::pair<QChar, const char*>& right)
{
return left < right.second;
}
inline bool operator()(const std::pair<QChar, const char*>& left, const QByteArray& right)
{
return left.second < right;
}
inline bool operator()(const std::pair<QChar, const char*>& left, const std::pair<QChar, const char*>& right)
{
return QLatin1String(left.second) < QLatin1String(right.second);
}
};
};
} // namespace pdf
#endif // PDFNAMETOUNICODE_H