void ImageSpec::attribute (string_view name, TypeDesc type, string_view value) { ImageIOParameter param (name, type, 1, NULL); TypeDesc::BASETYPE basetype = (TypeDesc::BASETYPE)type.basetype; if (basetype == TypeDesc::INT) { parse_elements<int> (name, type, "%d", value, param); } else if (basetype == TypeDesc::UINT) { parse_elements<unsigned int> (name, type, "%u", value, param); } else if (basetype == TypeDesc::FLOAT) { parse_elements<float> (name, type, "%f", value, param); } else if (basetype == TypeDesc::DOUBLE) { parse_elements<double> (name, type, "%lf", value, param); } else if (basetype == TypeDesc::INT64) { parse_elements<long long> (name, type, "%lld", value, param); } else if (basetype == TypeDesc::UINT64) { parse_elements<unsigned long long> (name, type, "%llu", value, param); } else if (basetype == TypeDesc::INT16) { parse_elements<short> (name, type, "%hd", value, param); } else if (basetype == TypeDesc::UINT16) { parse_elements<unsigned short> (name, type, "%hu", value, param); } else if (type == TypeDesc::STRING) { ustring s (value); param.init (name, TypeDesc::TypeString, 1, &s); } // Don't allow duplicates ImageIOParameter *f = find_attribute (name); if (f) { *f = param; } else { extra_attribs.push_back (param); } }
void ImageSpec::attribute (const std::string &name, TypeDesc type, const void *value) { // Don't allow duplicates ImageIOParameter *f = find_attribute (name); if (! f) { extra_attribs.resize (extra_attribs.size() + 1); f = &extra_attribs.back(); } f->init (name, type, 1, value); }