本文整理汇总了C++中TypeInfo::type方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeInfo::type方法的具体用法?C++ TypeInfo::type怎么用?C++ TypeInfo::type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeInfo
的用法示例。
在下文中一共展示了TypeInfo::type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extract
void ExternalExtractor::extract(ExtractionResult* result)
{
Q_D(ExternalExtractor);
QJsonDocument writeData;
QJsonObject writeRootObject;
QByteArray output;
QByteArray errorOutput;
writeRootObject[QStringLiteral("path")] = QJsonValue(result->inputUrl());
writeRootObject[QStringLiteral("mimetype")] = result->inputMimetype();
writeData.setObject(writeRootObject);
QProcess extractorProcess;
extractorProcess.start(d->mainPath, QIODevice::ReadWrite);
extractorProcess.write(writeData.toJson());
extractorProcess.closeWriteChannel();
extractorProcess.waitForFinished(EXTRACTOR_TIMEOUT_MS);
output = extractorProcess.readAll();
errorOutput = extractorProcess.readAllStandardError();
if (extractorProcess.exitStatus()) {
qDebug() << errorOutput;
return;
}
// now we read in the output (which is a standard json format) into the
// ExtractionResult
QJsonDocument extractorData = QJsonDocument::fromJson(output);
if (!extractorData.isObject()) {
return;
}
QJsonObject rootObject = extractorData.object();
QJsonObject propertiesObject = rootObject[QStringLiteral("properties")].toObject();
Q_FOREACH(auto key, propertiesObject.keys()) {
if (key == QStringLiteral("typeInfo")) {
TypeInfo info = TypeInfo::fromName(propertiesObject.value(key).toString());
result->addType(info.type());
continue;
}
// for plaintext extraction
if (key == QStringLiteral("text")) {
result->append(propertiesObject.value(key).toString(QStringLiteral("")));
continue;
}
PropertyInfo info = PropertyInfo::fromName(key);
if (info.name() != key) {
continue;
}
result->add(info.property(), propertiesObject.value(key).toVariant());
}
if (rootObject[QStringLiteral("status")].toString() != QStringLiteral("OK")) {
qDebug() << rootObject[QStringLiteral("error")].toString();
}
}
示例2: switch
void Decoder::DecoderState::addType(TypeInfo& tinfo,
const StructField& field,
int16_t tag, uint32_t count) {
const bool isStruct = (state == IN_STRUCT);
auto type = tinfo.type();
switch (type) {
case reflection::TYPE_BOOL:
bools.count += count;
if (isStruct) {
str.boolTags.emplace_back(tag, type);
}
break;
case reflection::TYPE_BYTE:
bytes.count += count;
if (isStruct) {
str.byteTags.emplace_back(tag, type);
}
break;
case reflection::TYPE_I64: // fallthrough
case reflection::TYPE_DOUBLE:
int64s.count += count;
if (isStruct) {
if (field.isFixed) {
str.fixedInt64Tags.emplace_back(tag, type);
} else {
str.int64Tags.emplace_back(tag, type);
}
}
break;
case reflection::TYPE_I16:
ints.count += count;
if (isStruct) {
if (field.isFixed) {
str.fixedInt16Tags.emplace_back(tag, type);
} else {
str.intTags.emplace_back(tag, type);
}
}
break;
case reflection::TYPE_ENUM:
if (field.isStrictEnum) {
strictEnums.count += count;
totalStrictEnumBits += count * tinfo.dataType->enumBits();
if (isStruct) {
str.strictEnumTags.emplace_back(tag, tinfo);
}
break;
}
type = reflection::TYPE_I32; // handle non-strict enums as i32
// fallthrough (to TYPE_I32)
case reflection::TYPE_I32:
ints.count += count;
if (isStruct) {
if (field.isFixed) {
str.fixedInt32Tags.emplace_back(tag, type);
} else {
str.intTags.emplace_back(tag, type);
}
}
break;
case reflection::TYPE_STRING:
if (field.isInterned) {
internedStrings.count += count;
if (isStruct) {
str.internedStringTags.emplace_back(tag, type);
}
} else {
if (field.isTerminated) {
tinfo.length = kTerminated;
tinfo.terminator = field.terminator;
} else if (field.isFixed) {
tinfo.length = field.fixedStringSize;
} else {
vars.count += count;
}
strings.count += count;
if (isStruct) {
str.stringTags.emplace_back(tag, tinfo);
}
}
break;
default: // user-defined type
strings.count += count;
if (isStruct) {
str.stringTags.emplace_back(tag, tinfo);
}
break;
}
}