本文整理汇总了C++中ConversionData::appendError方法的典型用法代码示例。如果您正苦于以下问题:C++ ConversionData::appendError方法的具体用法?C++ ConversionData::appendError怎么用?C++ ConversionData::appendError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConversionData
的用法示例。
在下文中一共展示了ConversionData::appendError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadUI
bool loadUI(Translator &translator, const QString &filename, ConversionData &cd)
{
cd.m_sourceFileName = filename;
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
cd.appendError(QString::fromLatin1("Cannot open %1: %2")
.arg(filename, file.errorString()));
return false;
}
QXmlInputSource in(&file);
QXmlSimpleReader reader;
reader.setFeature(QLatin1String("http://xml.org/sax/features/namespaces"), false);
reader.setFeature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"), true);
reader.setFeature(QLatin1String(
"http://trolltech.com/xml/features/report-whitespace-only-CharData"), false);
UiReader handler(translator, cd);
reader.setContentHandler(&handler);
reader.setErrorHandler(&handler);
bool result = reader.parse(in);
if (!result)
cd.appendError(QLatin1String("Parse error in UI file"));
reader.setContentHandler(0);
reader.setErrorHandler(0);
return result;
}
示例2: extend
void Translator::extend(const TranslatorMessage &msg, ConversionData &cd)
{
int index = find(msg);
if (index == -1) {
append(msg);
} else {
TranslatorMessage &emsg = m_messages[index];
if (emsg.sourceText().isEmpty()) {
delIndex(index);
emsg.setSourceText(msg.sourceText());
addIndex(index, msg);
} else if (!msg.sourceText().isEmpty() && emsg.sourceText() != msg.sourceText()) {
cd.appendError(QString::fromLatin1("Contradicting source strings for message with id '%1'.")
.arg(emsg.id()));
return;
}
if (emsg.extras().isEmpty()) {
emsg.setExtras(msg.extras());
} else if (!msg.extras().isEmpty() && emsg.extras() != msg.extras()) {
cd.appendError(QString::fromLatin1("Contradicting meta data for for %1.")
.arg(!emsg.id().isEmpty()
? QString::fromLatin1("message with id '%1'").arg(emsg.id())
: QString::fromLatin1("message '%1'").arg(makeMsgId(msg))));
return;
}
emsg.addReferenceUniq(msg.fileName(), msg.lineNumber());
if (!msg.extraComment().isEmpty()) {
QString cmt = emsg.extraComment();
if (!cmt.isEmpty()) {
QStringList cmts = cmt.split(QLatin1String("\n----------\n"));
if (!cmts.contains(msg.extraComment())) {
cmts.append(msg.extraComment());
cmt = cmts.join(QLatin1String("\n----------\n"));
}
} else {
cmt = msg.extraComment();
}
emsg.setExtraComment(cmt);
}
}
}
示例3: loadJava
bool loadJava(Translator &translator, const QString &filename, ConversionData &cd)
{
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
cd.appendError(QString::fromLatin1("Cannot open %1: %2")
.arg(filename, file.errorString()));
return false;
}
yyDefaultContext = cd.m_defaultContext;
yyInPos = -1;
yyFileName = filename;
yyPackage.clear();
yyScope.clear();
yyTok = -1;
yyParenDepth = 0;
yyCurLineNo = 0;
yyParenLineNo = 1;
QTextStream ts(&file);
QByteArray codecName;
if (!cd.m_codecForSource.isEmpty())
codecName = cd.m_codecForSource;
else
codecName = translator.codecName(); // Just because it should be latin1 already
ts.setCodec(QTextCodec::codecForName(codecName));
ts.setAutoDetectUnicode(true);
yyInStr = ts.readAll();
yyInPos = 0;
yyFileName = filename;
yyCurLineNo = 1;
yyParenLineNo = 1;
parse(&translator);
// Java uses UTF-16 internally and Jambi makes UTF-8 for tr() purposes of it.
translator.setCodecName("UTF-8");
return true;
}