当前位置: 首页>>代码示例>>C++>>正文


C++ TypeInfo::type方法代码示例

本文整理汇总了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();
    }
}
开发者ID:KDE,项目名称:kfilemetadata,代码行数:61,代码来源:externalextractor.cpp

示例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;
  }
}
开发者ID:191919,项目名称:fbthrift,代码行数:91,代码来源:Decoder.cpp


注:本文中的TypeInfo::type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。