comparison OrthancServer/Search/HierarchicalMatcher.cpp @ 3712:2a170a8f1faf

replacing std::auto_ptr by std::unique_ptr
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Mar 2020 15:32:45 +0100
parents 4922bdd046dd
children
comparison
equal deleted inserted replaced
3709:1f4910999fe7 3712:2a170a8f1faf
121 else 121 else
122 { 122 {
123 flatTags_.insert(tag); 123 flatTags_.insert(tag);
124 124
125 std::set<DicomTag> ignoreTagLength; 125 std::set<DicomTag> ignoreTagLength;
126 std::auto_ptr<DicomValue> value(FromDcmtkBridge::ConvertLeafElement 126 std::unique_ptr<DicomValue> value(FromDcmtkBridge::ConvertLeafElement
127 (*element, DicomToJsonFlags_None, 127 (*element, DicomToJsonFlags_None,
128 0, encoding, hasCodeExtensions, ignoreTagLength)); 128 0, encoding, hasCodeExtensions, ignoreTagLength));
129 129
130 // WARNING: Also modify "DatabaseLookup::IsMatch()" if modifying this code 130 // WARNING: Also modify "DatabaseLookup::IsMatch()" if modifying this code
131 if (value.get() == NULL || 131 if (value.get() == NULL ||
132 value->IsNull()) 132 value->IsNull())
133 { 133 {
255 255
256 DcmDataset* HierarchicalMatcher::ExtractInternal(DcmItem& source, 256 DcmDataset* HierarchicalMatcher::ExtractInternal(DcmItem& source,
257 Encoding encoding, 257 Encoding encoding,
258 bool hasCodeExtensions) const 258 bool hasCodeExtensions) const
259 { 259 {
260 std::auto_ptr<DcmDataset> target(new DcmDataset); 260 std::unique_ptr<DcmDataset> target(new DcmDataset);
261 261
262 for (std::set<DicomTag>::const_iterator it = flatTags_.begin(); 262 for (std::set<DicomTag>::const_iterator it = flatTags_.begin();
263 it != flatTags_.end(); ++it) 263 it != flatTags_.end(); ++it)
264 { 264 {
265 DcmTagKey tag = ToDcmtkBridge::Convert(*it); 265 DcmTagKey tag = ToDcmtkBridge::Convert(*it);
272 { 272 {
273 throw OrthancException(ErrorCode_NotImplemented, 273 throw OrthancException(ErrorCode_NotImplemented,
274 "Not applicable to private tags: " + it->Format()); 274 "Not applicable to private tags: " + it->Format());
275 } 275 }
276 276
277 std::auto_ptr<DcmElement> cloned(FromDcmtkBridge::CreateElementForTag(*it, "" /* no private creator */)); 277 std::unique_ptr<DcmElement> cloned(FromDcmtkBridge::CreateElementForTag(*it, "" /* no private creator */));
278 cloned->copyFrom(*element); 278 cloned->copyFrom(*element);
279 target->insert(cloned.release()); 279 target->insert(cloned.release());
280 } 280 }
281 } 281 }
282 282
287 287
288 DcmSequenceOfItems* sequence = NULL; 288 DcmSequenceOfItems* sequence = NULL;
289 if (source.findAndGetSequence(tag, sequence).good() && 289 if (source.findAndGetSequence(tag, sequence).good() &&
290 sequence != NULL) 290 sequence != NULL)
291 { 291 {
292 std::auto_ptr<DcmSequenceOfItems> cloned(new DcmSequenceOfItems(tag)); 292 std::unique_ptr<DcmSequenceOfItems> cloned(new DcmSequenceOfItems(tag));
293 293
294 for (unsigned long i = 0; i < sequence->card(); i++) 294 for (unsigned long i = 0; i < sequence->card(); i++)
295 { 295 {
296 if (it->second == NULL) 296 if (it->second == NULL)
297 { 297 {
301 { 301 {
302 // It is necessary to encapsulate the child dataset into a 302 // It is necessary to encapsulate the child dataset into a
303 // "DcmItem" object before it can be included in a 303 // "DcmItem" object before it can be included in a
304 // sequence. Otherwise, "dciodvfy" reports an error "Bad 304 // sequence. Otherwise, "dciodvfy" reports an error "Bad
305 // tag in sequence - Expecting Item or Sequence Delimiter." 305 // tag in sequence - Expecting Item or Sequence Delimiter."
306 std::auto_ptr<DcmDataset> child(it->second->ExtractInternal(*sequence->getItem(i), encoding, hasCodeExtensions)); 306 std::unique_ptr<DcmDataset> child(it->second->ExtractInternal(*sequence->getItem(i), encoding, hasCodeExtensions));
307 cloned->append(new DcmItem(*child)); 307 cloned->append(new DcmItem(*child));
308 } 308 }
309 } 309 }
310 310
311 target->insert(cloned.release()); 311 target->insert(cloned.release());
319 ParsedDicomFile* HierarchicalMatcher::Extract(ParsedDicomFile& dicom) const 319 ParsedDicomFile* HierarchicalMatcher::Extract(ParsedDicomFile& dicom) const
320 { 320 {
321 bool hasCodeExtensions; 321 bool hasCodeExtensions;
322 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); 322 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
323 323
324 std::auto_ptr<DcmDataset> dataset(ExtractInternal(*dicom.GetDcmtkObject().getDataset(), 324 std::unique_ptr<DcmDataset> dataset(ExtractInternal(*dicom.GetDcmtkObject().getDataset(),
325 encoding, hasCodeExtensions)); 325 encoding, hasCodeExtensions));
326 326
327 std::auto_ptr<ParsedDicomFile> result(new ParsedDicomFile(*dataset)); 327 std::unique_ptr<ParsedDicomFile> result(new ParsedDicomFile(*dataset));
328 result->SetEncoding(encoding); 328 result->SetEncoding(encoding);
329 329
330 return result.release(); 330 return result.release();
331 } 331 }
332 } 332 }