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


C++ IptcData::clear方法代码示例

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


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

示例1: decode

int IptcParser::decode(
    IptcData& iptcData,
    const byte*     pData,
    uint32_t  size
)
{
#ifdef DEBUG
    std::cerr << "IptcParser::decode, size = " << size << "\n";
#endif
    const byte* pRead = pData;
    iptcData.clear();

    uint16_t record = 0;
    uint16_t dataSet = 0;
    uint32_t sizeData = 0;
    byte extTest = 0;

    while (pRead + 3 < pData + size) {
        // First byte should be a marker. If it isn't, scan forward and skip
        // the chunk bytes present in some images. This deviates from the
        // standard, which advises to treat such cases as errors.
        if (*pRead++ != marker_) continue;
        record = *pRead++;
        dataSet = *pRead++;

        extTest = *pRead;
        if (extTest & 0x80) {
            // extended dataset
            uint16_t sizeOfSize = (getUShort(pRead, bigEndian) & 0x7FFF);
            if (sizeOfSize > 4) return 5;
            pRead += 2;
            sizeData = 0;
            for (; sizeOfSize > 0; --sizeOfSize) {
                sizeData |= *pRead++ << (8 *(sizeOfSize-1));
            }
        }
        else {
            // standard dataset
            sizeData = getUShort(pRead, bigEndian);
            pRead += 2;
        }
        if (pRead + sizeData <= pData + size) {
            int rc = 0;
            if ((rc = readData(iptcData, dataSet, record, pRead, sizeData)) != 0) {
#ifndef SUPPRESS_WARNINGS
                EXV_WARNING << "Failed to read IPTC dataset "
                            << IptcKey(dataSet, record)
                            << " (rc = " << rc << "); skipped.\n";
#endif
            }
        }
#ifndef SUPPRESS_WARNINGS
        else {
            EXV_WARNING << "IPTC dataset " << IptcKey(dataSet, record)
                        << " has invalid size " << sizeData << "; skipped.\n";
        }
#endif
        pRead += sizeData;
    }

    return 0;
} // IptcParser::decode
开发者ID:ahuggel,项目名称:exiv2,代码行数:62,代码来源:iptc.cpp


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