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


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

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


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

示例1: processAdd

void processAdd(const std::string& line, int num)
{
    std::string::size_type keyStart = line.find_first_not_of(" \t", 1);
    std::string::size_type keyEnd = line.find_first_of(" \t", keyStart+1);
    std::string::size_type dataStart = line.find_first_not_of(" \t", keyEnd+1);

    if (keyStart == std::string::npos ||
        keyEnd == std::string::npos ||
        dataStart == std::string::npos) {
        std::ostringstream os;
        os << "Invalid \'a\' command at line " << num;
        throw Error(os.str());
    }

    std::string key(line.substr(keyStart, keyEnd-keyStart));
    std::pair<uint16, uint16> p = IptcDataSets::decomposeKey(key);
    if (p.first == 0xffff) throw Error("Invalid key " + key);
    if (p.second == IptcDataSets::invalidRecord) throw Error("Invalid key " + key);

    std::string data(line.substr(dataStart));
    // if data starts and ends with quotes, remove them
    if (data.at(0) == '\"' && data.at(data.size()-1) == '\"') {
        data = data.substr(1, data.size()-2);
    }
    TypeId type = IptcDataSets::dataSetType(p.first, p.second);
    Value *val = Value::create(type);
    val->read(data);

    int rc = g_iptcData.add(IptcKey(key), val);
    if (rc) {
        std::string error = IptcData::strError(rc, "Input file");
        throw Error(error);
    }
    
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例2: processAdd

void processAdd(const std::string& line, int num, IptcData &iptcData)
{
    std::string::size_type keyStart = line.find_first_not_of(" \t", 1);
    std::string::size_type keyEnd = line.find_first_of(" \t", keyStart+1);
    std::string::size_type dataStart = line.find_first_not_of(" \t", keyEnd+1);

    if (keyStart == std::string::npos ||
        keyEnd == std::string::npos ||
        dataStart == std::string::npos) {
        std::ostringstream os;
        os << "Invalid \'a\' command at line " << num;
        throw Error(1, os.str());
    }

    std::string key(line.substr(keyStart, keyEnd-keyStart));
    IptcKey iptcKey(key);

    std::string data(line.substr(dataStart));
    // if data starts and ends with quotes, remove them
    if (data.at(0) == '\"' && data.at(data.size()-1) == '\"') {
        data = data.substr(1, data.size()-2);
    }
    TypeId type = IptcDataSets::dataSetType(iptcKey.tag(), iptcKey.record());
    Value::AutoPtr value = Value::create(type);
    value->read(data);

    int rc = iptcData.add(iptcKey, value.get());
    if (rc) {
        throw Error(1, "Iptc dataset already exists and is not repeatable");
    }
}
开发者ID:007durgesh219,项目名称:nomacs,代码行数:31,代码来源:iptctest.cpp


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