comparison OrthancFramework/Sources/DicomFormat/DicomPath.cpp @ 4735:e17fdc43ef6c

optimized version of DicomPath::IsMatch()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 05 Jul 2021 17:03:46 +0200
parents 13efc0967cea
children 7053502fbf97
comparison
equal deleted inserted replaced
4734:b51c08bd5c38 4735:e17fdc43ef6c
370 { 370 {
371 return (path.GetPrefixTag(pattern.GetPrefixLength()) == pattern.GetFinalTag()); 371 return (path.GetPrefixTag(pattern.GetPrefixLength()) == pattern.GetFinalTag());
372 } 372 }
373 } 373 }
374 } 374 }
375
376
377 bool DicomPath::IsMatch(const DicomPath& pattern,
378 const std::vector<Orthanc::DicomTag>& prefixTags,
379 const std::vector<size_t>& prefixIndexes,
380 const DicomTag& finalTag)
381 {
382 if (prefixTags.size() != prefixIndexes.size())
383 {
384 throw OrthancException(ErrorCode_ParameterOutOfRange);
385 }
386
387 if (prefixTags.size() < pattern.GetPrefixLength())
388 {
389 return false;
390 }
391 else
392 {
393 for (size_t i = 0; i < pattern.GetPrefixLength(); i++)
394 {
395 if (prefixTags[i] != pattern.GetPrefixTag(i) ||
396 (!pattern.IsPrefixUniversal(i) &&
397 prefixIndexes[i] != pattern.GetPrefixIndex(i)))
398 {
399 return false;
400 }
401 }
402
403 if (prefixTags.size() == pattern.GetPrefixLength())
404 {
405 return (finalTag == pattern.GetFinalTag());
406 }
407 else
408 {
409 return (prefixTags[pattern.GetPrefixLength()] == pattern.GetFinalTag());
410 }
411 }
412 }
375 } 413 }