4#include "qplatformdefs.h"
8#ifndef QT_NO_TRANSLATION
25#if defined(Q_OS_UNIX) && !defined(Q_OS_NACL) && !defined(Q_OS_INTEGRITY)
27# include "private/qcore_unix_p.h"
53 0x3c, 0xb8, 0x64, 0x18, 0xca, 0xef, 0x9c, 0x95,
54 0xcd, 0x21, 0x1c, 0xbf, 0x60, 0xa1, 0xbd, 0xdd
63 if (foundLen > 0 && found[foundLen-1] ==
'\0')
65 return ((targetLen == foundLen) && memcmp(found,
target, foundLen) == 0);
76 if ((
g = (
h & 0xf0000000)) != 0)
118 if (++
offset == rulesSize)
132 if (
offset != rulesSize) {
150 && ++
offset != rulesSize);
179 bool orExprTruthValue =
false;
182 bool andExprTruthValue =
true;
185 bool truthValue =
true;
194 while (leftOperand >= 1000)
199 int rightOperand = rules[
i++];
203 truthValue = (leftOperand == rightOperand);
206 truthValue = (leftOperand < rightOperand);
209 truthValue = (leftOperand <= rightOperand);
212 int bottom = rightOperand;
213 int top = rules[
i++];
214 truthValue = (leftOperand >=
bottom && leftOperand <=
top);
218 truthValue = !truthValue;
220 andExprTruthValue = andExprTruthValue && truthValue;
222 if (
i == rulesSize || rules[
i] !=
Q_AND)
227 orExprTruthValue = orExprTruthValue || andExprTruthValue;
229 if (
i == rulesSize || rules[
i] !=
Q_OR)
234 if (orExprTruthValue)
256#
if defined(QT_USE_MMAP)
263#if defined(QT_USE_MMAP)
443 const QString & search_delimiters,
464 realname = prefix + fname + suffixOrDotQM;
469 realname = prefix + fname;
475 for (
int i = 0;
i < (int)delims.
size();
i++) {
476 int k = fname.lastIndexOf(delims[
i]);
485 fname.truncate(rightmost);
501 d->resource = std::make_unique<QResource>(realname);
506 d->unmapPointer =
reinterpret_cast<char *
>(
const_cast<uchar *
>(
resource->data()));
507#if defined(QT_USE_MMAP)
508 d->used_mmap =
false;
522 if (fileSize < MagicLength || fileSize > std::numeric_limits<qsizetype>::max())
540#define MAP_FAILED reinterpret_cast<void *>(-1)
545 int protection = PROT_READ;
547 void *
ptr = QT_MMAP(
nullptr,
d->unmapLength,
553 d->unmapPointer =
static_cast<char *
>(
ptr);
560 d->unmapPointer =
new (std::nothrow)
char[
d->unmapLength];
561 if (
d->unmapPointer) {
573 if (
d->do_load(
reinterpret_cast<const uchar *
>(
d->unmapPointer),
d->unmapLength,
575 d->filePath = realname;
580#if defined(QT_USE_MMAP)
589 d->resource =
nullptr;
590 d->unmapPointer =
nullptr;
612 if (!
path.isEmpty() && !
path.endsWith(u
'/'))
618 realname +=
path + filename + prefix;
619 const int realNameBaseSize = realname.
size();
631 for (
int i = languages.size()-1;
i >= 0; --
i) {
634 if (lang != lowerLang)
635 languages.insert(
i + 1, lowerLang);
638 for (
QString localeName : std::as_const(languages)) {
639 localeName.replace(u
'-', u
'_');
644 realname += localeName + suffixOrDotQM;
648 realname.
truncate(realNameBaseSize + localeName.size());
652 realname.
truncate(realNameBaseSize);
654 int rightmost = localeName.lastIndexOf(u
'_');
657 localeName.truncate(rightmost);
661 const int realNameBaseSizeFallbacks =
path.size() + filename.
size();
665 realname.
replace(realNameBaseSizeFallbacks, prefix.
size(), suffix);
669 realname.
replace(realNameBaseSizeFallbacks, suffix.
size(), prefix);
676 realname.
truncate(realNameBaseSizeFallbacks);
770 return qFromBigEndian<quint16>(
data);
775 return qFromBigEndian<quint32>(
data);
790 if (!
tag || !blockLen)
816 dependencies.append(dep);
827 for (
const QString &dependency : std::as_const(dependencies)) {
828 auto translator = std::make_unique<QTranslator>();
855 const char *sourceText,
const char *comment,
uint numerus)
857 const uchar *tn =
nullptr;
859 const uint sourceTextLen =
uint(strlen(sourceText));
861 const uint commentLen =
uint(strlen(comment));
888 if (!
match(
m,
len, sourceText, sourceTextLen))
904 if (*
m && !
match(
m,
len, comment, commentLen))
922 const char *comment,
int n)
const
926 if (sourceText ==
nullptr)
928 if (comment ==
nullptr)
935 goto searchDependencies;
964 goto searchDependencies;
983 }
else if (
hash <
h) {
1003 sourceText, comment, numerus);
1032#if defined(QT_USE_MMAP)
1086 return d->do_translate(
context, sourceText, disambiguation,
n);
1096 return !
d->messageArray && !
d->offsetArray && !
d->contextArray
1097 &&
d->subTranslators.empty();
1128#include "moc_qtranslator.cpp"
static QByteArray fromRawData(const char *data, qsizetype size)
Constructs a QByteArray that uses the first size bytes of the data array.
static bool isTranslatorInstalled(QTranslator *translator)
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
static bool removeTranslator(QTranslator *messageFile)
Removes the translation file translationFile from the list of translation files used by this applicat...
\inmodule QtCore\reentrant
bool seek(qint64 offset) override
For random-access devices, this function sets the current position to pos, returning true on success,...
int handle() const
Returns the file handle of the file.
void close() override
Calls QFileDevice::flush() and closes the file.
\inmodule QtCore \reentrant
void setFile(const QString &file)
Sets the file that the QFileInfo provides information about to file.
bool isFile() const
Returns true if this object points to a file or to a symbolic link to a file.
QString absolutePath() const
Returns a file's path absolute path.
bool isReadable() const
Returns true if the user can read the file; otherwise returns false.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
qint64 size() const override
\reimp
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString & replace(qsizetype i, qsizetype len, QChar after)
void truncate(qsizetype pos)
Truncates the string at the given position index.
void clear()
Clears the contents of the string and makes it null.
bool isNull() const
Returns true if this string is null; otherwise returns false.
qsizetype size() const
Returns the number of characters in this string.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString toLower() const &
QChar * data()
Returns a pointer to the data stored in the QString.
bool do_load(const QString &filename, const QString &directory)
std::unique_ptr< QResource > resource
QString do_translate(const char *context, const char *sourceText, const char *comment, int n) const
const uchar * messageArray
std::vector< std::unique_ptr< QTranslator > > subTranslators
const uchar * numerusRulesArray
const uchar * contextArray
const uchar * offsetArray
QTranslator(QObject *parent=nullptr)
Constructs an empty message file object with parent parent that is not connected to any file.
~QTranslator()
Destroys the object and frees any allocated resources.
virtual bool isEmpty() const
Returns true if this translator is empty, otherwise returns false.
bool load(const QString &filename, const QString &directory=QString(), const QString &search_delimiters=QString(), const QString &suffix=QString())
Loads filename + suffix (".qm" if the suffix is not specified), which may be an absolute file name or...
virtual QString translate(const char *context, const char *sourceText, const char *disambiguation=nullptr, int n=-1) const
Returns the translation for the key (context, sourceText, disambiguation).
QHash< int, QWidget * > hash
[35multi]
Combined button and popup list for selecting options.
constexpr Initialization Uninitialized
AudioChannelLayoutTag tag
quint8 qFromBigEndian< quint8 >(const void *src)
static ControlElement< T > * ptr(QWidget *widget)
GLdouble GLdouble GLdouble GLdouble top
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
static QT_BEGIN_NAMESPACE bool isRelative(const QString &path)
#define QStringLiteral(str)
static QString getMessage(const uchar *m, const uchar *end, const char *context, const char *sourceText, const char *comment, uint numerus)
static quint32 read32(const uchar *data)
static void elfHash_continue(const char *name, uint &h)
static bool isValidNumerusRules(const uchar *rules, uint rulesSize)
static Q_NEVER_INLINE bool is_readable_file(const QString &name)
static const int MagicLength
static QString dotQmLiteral()
static uint elfHash(const char *name)
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
static const uchar magic[MagicLength]
static uint numerusHelper(int n, const uchar *rules, uint rulesSize)
static QString find_translation(const QLocale &locale, const QString &filename, const QString &prefix, const QString &directory, const QString &suffix)
static quint8 read8(const uchar *data)
static quint16 read16(const uchar *data)
static void elfHash_finish(uint &h)
if(qFloatDistance(a, b)<(1<< 7))
[0]
QFileInfo fi("c:/temp/foo")
[newstuff]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent