MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / decomposeKey

Method decomposeKey

src/properties.cpp:5229–5253  ·  view source on GitHub ↗

@cond IGNORE

Source from the content-addressed store, hash-verified

5227
5228//! @cond IGNORE
5229void XmpKey::Impl::decomposeKey(const std::string& key) {
5230 // Get the family name, prefix and property name parts of the key
5231 std::string::size_type pos1 = key.find('.');
5232 if (pos1 == std::string::npos)
5233 throw Error(ErrorCode::kerInvalidKey, key);
5234 if (key.substr(0, pos1) != familyName_)
5235 throw Error(ErrorCode::kerInvalidKey, key);
5236 std::string::size_type pos0 = pos1 + 1;
5237 pos1 = key.find('.', pos0);
5238 if (pos1 == std::string::npos)
5239 throw Error(ErrorCode::kerInvalidKey, key);
5240 std::string prefix = key.substr(pos0, pos1 - pos0);
5241 if (prefix.empty())
5242 throw Error(ErrorCode::kerInvalidKey, key);
5243 std::string property = key.substr(pos1 + 1);
5244 if (property.empty())
5245 throw Error(ErrorCode::kerInvalidKey, key);
5246
5247 // Validate prefix
5248 if (XmpProperties::ns(prefix).empty())
5249 throw Error(ErrorCode::kerNoNamespaceForPrefix, prefix);
5250
5251 property_ = property;
5252 prefix_ = prefix;
5253} // XmpKey::Impl::decomposeKey
5254
5255// *************************************************************************
5256// free functions

Callers 1

XmpKeyMethod · 0.45

Calls 2

ErrorFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected