Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qtranslator.cpp File Reference
#include "qplatformdefs.h"
#include "qtranslator.h"
#include "qfileinfo.h"
#include "qstring.h"
#include "qstringlist.h"
#include "qcoreapplication.h"
#include "qcoreapplication_p.h"
#include "qdatastream.h"
#include "qendian.h"
#include "qfile.h"
#include "qmap.h"
#include "qalgorithms.h"
#include "qtranslator_p.h"
#include "qlocale.h"
#include "qresource.h"
#include <stdlib.h>
#include <new>
#include "qobject_p.h"
#include <vector>
#include <memory>
#include "moc_qtranslator.cpp"
+ Include dependency graph for qtranslator.cpp:

Go to the source code of this file.

Classes

class  QTranslatorPrivate
 

Enumerations

enum  Tag {
  Tag_End = 1 , Tag_SourceText16 , Tag_Translation , Tag_Context16 ,
  Tag_Obsolete1 , Tag_SourceText , Tag_Context , Tag_Comment ,
  Tag_Obsolete2 , acsp = IccTag('a', 'c', 's', 'p') , RGB_ = IccTag('R', 'G', 'B', ' ') , XYZ_ = IccTag('X', 'Y', 'Z', ' ') ,
  rXYZ = IccTag('r', 'X', 'Y', 'Z') , gXYZ = IccTag('g', 'X', 'Y', 'Z') , bXYZ = IccTag('b', 'X', 'Y', 'Z') , rTRC = IccTag('r', 'T', 'R', 'C') ,
  gTRC = IccTag('g', 'T', 'R', 'C') , bTRC = IccTag('b', 'T', 'R', 'C') , kTRC = IccTag('k', 'T', 'R', 'C') , A2B0 = IccTag('A', '2', 'B', '0') ,
  A2B1 = IccTag('A', '2', 'B', '1') , B2A0 = IccTag('B', '2', 'A', '0') , B2A1 = IccTag('B', '2', 'A', '1') , desc = IccTag('d', 'e', 's', 'c') ,
  text = IccTag('t', 'e', 'x', 't') , cprt = IccTag('c', 'p', 'r', 't') , curv = IccTag('c', 'u', 'r', 'v') , para = IccTag('p', 'a', 'r', 'a') ,
  wtpt = IccTag('w', 't', 'p', 't') , bkpt = IccTag('b', 'k', 'p', 't') , mft1 = IccTag('m', 'f', 't', '1') , mft2 = IccTag('m', 'f', 't', '2') ,
  mluc = IccTag('m', 'l', 'u', 'c') , mAB_ = IccTag('m', 'A', 'B', ' ') , mBA_ = IccTag('m', 'B', 'A', ' ') , chad = IccTag('c', 'h', 'a', 'd') ,
  sf32 = IccTag('s', 'f', '3', '2') , aarg = IccTag('a', 'a', 'r', 'g') , aagg = IccTag('a', 'a', 'g', 'g') , aabg = IccTag('a', 'a', 'b', 'g')
}
 

Functions

static QString dotQmLiteral ()
 
static bool match (const uchar *found, uint foundLen, const char *target, uint targetLen)
 
static void elfHash_continue (const char *name, uint &h)
 
static void elfHash_finish (uint &h)
 
static uint elfHash (const char *name)
 
static bool isValidNumerusRules (const uchar *rules, uint rulesSize)
 
static uint numerusHelper (int n, const uchar *rules, uint rulesSize)
 
static Q_NEVER_INLINE bool is_readable_file (const QString &name)
 
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 quint32 read32 (const uchar *data)
 
static QString getMessage (const uchar *m, const uchar *end, const char *context, const char *sourceText, const char *comment, uint numerus)
 

Variables

static const int MagicLength = 16
 
static const uchar magic [MagicLength]
 

Enumeration Type Documentation

◆ Tag

enum Tag
Enumerator
Tag_End 
Tag_SourceText16 
Tag_Translation 
Tag_Context16 
Tag_Obsolete1 
Tag_SourceText 
Tag_Context 
Tag_Comment 
Tag_Obsolete2 
acsp 
RGB_ 
XYZ_ 
rXYZ 
gXYZ 
bXYZ 
rTRC 
gTRC 
bTRC 
kTRC 
A2B0 
A2B1 
B2A0 
B2A1 
desc 
text 
cprt 
curv 
para 
wtpt 
bkpt 
mft1 
mft2 
mluc 
mAB_ 
mBA_ 
chad 
sf32 
aarg 
aagg 
aabg 

Definition at line 42 of file qtranslator.cpp.

Function Documentation

◆ dotQmLiteral()

static QString dotQmLiteral ( )
inlinestatic

Definition at line 57 of file qtranslator.cpp.

References QStringLiteral.

Referenced by find_translation(), and QTranslator::load().

+ Here is the caller graph for this function:

◆ elfHash()

static uint elfHash ( const char *  name)
static

Definition at line 88 of file qtranslator.cpp.

References elfHash_continue(), elfHash_finish(), and hash.

Referenced by QTranslatorPrivate::do_translate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elfHash_continue()

static void elfHash_continue ( const char *  name,
uint h 
)
static

Definition at line 68 of file qtranslator.cpp.

Referenced by QTranslatorPrivate::do_translate(), and elfHash().

+ Here is the caller graph for this function:

◆ elfHash_finish()

static void elfHash_finish ( uint h)
static

Definition at line 82 of file qtranslator.cpp.

Referenced by QTranslatorPrivate::do_translate(), and elfHash().

+ Here is the caller graph for this function:

◆ find_translation()

static QString find_translation ( const QLocale locale,
const QString filename,
const QString prefix,
const QString directory,
const QString suffix 
)
static

Definition at line 603 of file qtranslator.cpp.

References directory, dotQmLiteral(), i, is_readable_file(), QString::isNull(), isRelative(), QString::replace(), QString::size(), QString::toLower(), and QString::truncate().

Referenced by QTranslator::load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMessage()

static QString getMessage ( const uchar m,
const uchar end,
const char *  context,
const char *  sourceText,
const char *  comment,
uint  numerus 
)
static

Definition at line 854 of file qtranslator.cpp.

References context, QString::data(), match(), read32(), read8(), QString::size(), str, tag, Tag_Comment, Tag_Context, Tag_End, Tag_Obsolete1, Tag_SourceText, Tag_Translation, and Qt::Uninitialized.

Referenced by QTranslatorPrivate::do_translate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_readable_file()

static Q_NEVER_INLINE bool is_readable_file ( const QString name)
static

Definition at line 597 of file qtranslator.cpp.

References fi, QFileInfo::isFile(), and QFileInfo::isReadable().

Referenced by find_translation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValidNumerusRules()

static bool isValidNumerusRules ( const uchar rules,
uint  rulesSize 
)
static

Definition at line 102 of file qtranslator.cpp.

References opcode, Q_AND, Q_BETWEEN, Q_EQ, Q_LEQ, Q_LT, Q_NEWRULE, Q_OP_MASK, and Q_OR.

Referenced by QTranslatorPrivate::do_load().

+ Here is the caller graph for this function:

◆ match()

static bool match ( const uchar found,
uint  foundLen,
const char *  target,
uint  targetLen 
)
static

Definition at line 59 of file qtranslator.cpp.

Referenced by QBluetoothServiceDiscoveryAgentPrivate::QBluetoothServiceDiscoveryAgentPrivate(), QVncIntegration::QVncIntegration(), QTapTestLogger::addIncident(), Parser::addIncludesRecursive(), AVFImageCapture::applySettings(), architectureFromName(), arrayLength(), QDBusAbstractInterface::callWithArgumentList(), SyncScanner::checkLineForSymbols(), QPlatformFileDialogHelper::cleanFilterList(), detectMenuRole(), QTranslatorPrivate::do_translate(), QQuickShortcut::event(), QSSGQmlUtilities::expandComponents(), findDependencyInfo(), Parser::findEnumValues(), QFontDatabasePrivate::findFont(), findScreen(), Widget::firstIndexOfFunction(), QEglFSDeviceIntegration::framebufferIndex(), LocalFileApi::Type::fromQt(), QGraphicsAnchorLayoutPrivate::getGraphParts(), QT_BEGIN_NAMESPACE::getKeyFromCode(), getMessage(), QBenchmarkValgrindUtils::getNewestFileName(), src_gui_text_qsyntaxhighlighter::MyHighlighter::highlightBlock(), QPlaceManagerEngineNokiaV2::icon(), QIntegrityFbScreen::initialize(), QBsdFbScreen::initialize(), QLinuxFbScreen::initialize(), QVncScreen::initialize(), QAbstractItemView::keyboardSearch(), QTreeView::keyboardSearch(), Widget::lastIndexOfFunction(), main(), QResourceRoot::mappingRootSubdir(), QKeySequence::matches(), matches(), QV4::RegExpPrototype::method_match(), QV4::StringPrototype::method_match(), QV4::RegExpPrototype::method_replace(), QOCIDriver::open(), QtPrivate::q_boyer_moore_searcher_hashed_needle< RandomIt1, Hash, BinaryPredicate >::operator()(), QRegularExpressionMatch::operator<<(), QRegularExpressionMatch::operator=(), QRegularExpressionMatch::operator=(), Parser::parse(), parseDateString(), SyncScanner::parseHeader(), parseIconEntryInfo(), Parser::parseMetadata(), parseProvider(), parseTestArgs(), parseTracepoint(), SyncScanner::parseVersionScriptContent(), QSvgHandler::processingInstruction(), qFindPSQLVersion(), qt_find_best_framerate_match(), qt_find_supported_framerate_range(), qt_idForPointSize(), qt_idForPpdKey(), qt_idForSize(), qt_idForWindowsID(), qt_strip_filters(), QString::remove(), QDomDocumentPrivate::saveDocument(), QColorDialogPrivate::selectColor(), and sequenceLength().

◆ numerusHelper()

static uint numerusHelper ( int  n,
const uchar rules,
uint  rulesSize 
)
static

Definition at line 170 of file qtranslator.cpp.

References i, opcode, Q_AND, Q_ASSERT, Q_BETWEEN, Q_EQ, Q_LEAD_1000, Q_LEQ, Q_LT, Q_MOD_10, Q_MOD_100, Q_NOT, Q_OP_MASK, and Q_OR.

Referenced by QTranslatorPrivate::do_translate().

+ Here is the caller graph for this function:

◆ read16()

static quint16 read16 ( const uchar data)
static

Definition at line 768 of file qtranslator.cpp.

Referenced by QTranslatorPrivate::do_translate().

+ Here is the caller graph for this function:

◆ read32()

static quint32 read32 ( const uchar data)
static

Definition at line 773 of file qtranslator.cpp.

Referenced by QTranslatorPrivate::do_load(), QTranslatorPrivate::do_translate(), and getMessage().

+ Here is the caller graph for this function:

◆ read8()

static quint8 read8 ( const uchar data)
static

Definition at line 763 of file qtranslator.cpp.

References qFromBigEndian< quint8 >().

Referenced by QTranslatorPrivate::do_load(), QTranslatorPrivate::do_translate(), and getMessage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ magic

const uchar magic[MagicLength]
static
Initial value:
= {
0x3c, 0xb8, 0x64, 0x18, 0xca, 0xef, 0x9c, 0x95,
0xcd, 0x21, 0x1c, 0xbf, 0x60, 0xa1, 0xbd, 0xdd
}

Definition at line 52 of file qtranslator.cpp.

Referenced by QTranslatorPrivate::do_load(), isDigit(), isDigit(), QTranslator::load(), parseIconEntryData(), wrapInFunction(), and QQsbCollection::writeEndHeader().

◆ MagicLength

const int MagicLength = 16
static