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


C++ TagMap::insert方法代码示例

本文整理汇总了C++中TagMap::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ TagMap::insert方法的具体用法?C++ TagMap::insert怎么用?C++ TagMap::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TagMap的用法示例。


在下文中一共展示了TagMap::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: buf

size_t
GenericHeader::read(IDataReader &reader)
{
    size_t bufLen = 1024 * 32;
    DataBuffer buf(bufLen, ALIGNMENT);
    size_t numBytesRead = reader.getData(buf.getFree(), bufLen);
    buf.moveFreeToData(numBytesRead);

    if (numBytesRead < 4 /* magic */ + 4 /* size */) {
        throw IllegalHeaderException("Failed to read header info.");
    }
    uint32_t magic = buf.readInt32();
    if (magic != MAGIC) {
        throw IllegalHeaderException("Failed to verify magic bits.");
    }
    uint32_t numBytesTotal = buf.readInt32();
    if (numBytesTotal == 0) {
        throw IllegalHeaderException("Failed to read header size.");
    }
    if (numBytesTotal < getMinSize()) {
        throw IllegalHeaderException("Failed to verify header size.");
    }
    if (numBytesRead < numBytesTotal) {
        LOG(debug, "Read %d of %d header bytes, performing backfill.",
            (uint32_t)numBytesRead, numBytesTotal);
        uint32_t numBytesRemain = numBytesTotal - numBytesRead;
        buf.ensureFree(numBytesRemain);
        LOG(debug, "Reading remaining %d bytes of header.", numBytesRemain);
        numBytesRead += reader.getData(buf.getFree(), numBytesRemain);
        if (numBytesRead != numBytesTotal) {
            throw IllegalHeaderException("Failed to read full header.");
        }
        buf.moveFreeToData(numBytesRemain);
    } else {
        buf.moveDataToFree(numBytesRead - numBytesTotal);
    }

    uint32_t version = buf.readInt32();
    if (version != VERSION) {
        throw IllegalHeaderException("Failed to verify header version.");
    }
    uint32_t numTags = buf.readInt32();
    TagMap tags;
    for (uint32_t i = 0; i < numTags; ++i) {
        Tag tag;
        tag.read(buf);
        tags.insert(TagMap::value_type(tag.getName(), tag));
    }
    _tags.swap(tags);
    return numBytesTotal;
}
开发者ID:songhtdo,项目名称:vespa,代码行数:51,代码来源:fileheader.cpp

示例2: init

void QFieldDefinitionData::init(TagMap &tagMap, FieldMap &fieldMap, ActionMap &actionMap, QTranslatableSettings &config)
{
    QList<QFieldDefinition> fields;
    QMap<QString, QFieldAction> actions;

    fields = QFieldDefinitionData::readFields(config);
    actions = QFieldDefinitionData::readActions(config);

    foreach(QFieldDefinition def, fields) {
        if (!fieldMap.contains(def.id())) {
            fieldMap.insert(def.id(), def);
            QStringList tags = def.tags();
            foreach(QString tag, tags)
            {
                QSet<QString> taggedFields;
                if (tagMap.contains(tag))
                    taggedFields = tagMap.value(tag);
                taggedFields.insert(def.id());
                tagMap.insert(tag, taggedFields);
            }
        }
开发者ID:Camelek,项目名称:qtmoko,代码行数:21,代码来源:qfielddefinition.cpp


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