Mercurial > hg > orthanc
comparison OrthancServer/FromDcmtkBridge.cpp @ 1929:cda5b0ab4ce5
ORTHANC_MAXIMUM_TAG_LENGTH made explicit
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 21 Mar 2016 14:28:59 +0100 |
parents | 84c7eaeb5244 |
children | 1c147c3c3121 |
comparison
equal
deleted
inserted
replaced
1928:84c7eaeb5244 | 1929:cda5b0ab4ce5 |
---|---|
304 } | 304 } |
305 | 305 |
306 | 306 |
307 void FromDcmtkBridge::Convert(DicomMap& target, | 307 void FromDcmtkBridge::Convert(DicomMap& target, |
308 DcmDataset& dataset, | 308 DcmDataset& dataset, |
309 unsigned int maxStringLength, | |
309 Encoding defaultEncoding) | 310 Encoding defaultEncoding) |
310 { | 311 { |
311 Encoding encoding = DetectEncoding(dataset, defaultEncoding); | 312 Encoding encoding = DetectEncoding(dataset, defaultEncoding); |
312 | 313 |
313 target.Clear(); | 314 target.Clear(); |
316 DcmElement* element = dataset.getElement(i); | 317 DcmElement* element = dataset.getElement(i); |
317 if (element && element->isLeaf()) | 318 if (element && element->isLeaf()) |
318 { | 319 { |
319 target.SetValue(element->getTag().getGTag(), | 320 target.SetValue(element->getTag().getGTag(), |
320 element->getTag().getETag(), | 321 element->getTag().getETag(), |
321 ConvertLeafElement(*element, DicomToJsonFlags_Default, encoding)); | 322 ConvertLeafElement(*element, DicomToJsonFlags_Default, maxStringLength, encoding)); |
322 } | 323 } |
323 } | 324 } |
324 } | 325 } |
325 | 326 |
326 | 327 |
336 } | 337 } |
337 | 338 |
338 | 339 |
339 DicomValue* FromDcmtkBridge::ConvertLeafElement(DcmElement& element, | 340 DicomValue* FromDcmtkBridge::ConvertLeafElement(DcmElement& element, |
340 DicomToJsonFlags flags, | 341 DicomToJsonFlags flags, |
342 unsigned int maxStringLength, | |
341 Encoding encoding) | 343 Encoding encoding) |
342 { | 344 { |
343 if (!element.isLeaf()) | 345 if (!element.isLeaf()) |
344 { | 346 { |
345 // This function is only applicable to leaf elements | 347 // This function is only applicable to leaf elements |
357 else | 359 else |
358 { | 360 { |
359 std::string s(c); | 361 std::string s(c); |
360 std::string utf8 = Toolbox::ConvertToUtf8(s, encoding); | 362 std::string utf8 = Toolbox::ConvertToUtf8(s, encoding); |
361 | 363 |
362 if (utf8.size() > ORTHANC_MAXIMUM_TAG_LENGTH) | 364 if (maxStringLength != 0 && |
365 utf8.size() > maxStringLength) | |
363 { | 366 { |
364 return new DicomValue; // Create a NULL value | 367 return new DicomValue; // Create a NULL value |
365 } | 368 } |
366 else | 369 else |
367 { | 370 { |
703 assert(parent.type() == Json::objectValue); | 706 assert(parent.type() == Json::objectValue); |
704 Json::Value& target = PrepareNode(parent, element, format); | 707 Json::Value& target = PrepareNode(parent, element, format); |
705 | 708 |
706 if (element.isLeaf()) | 709 if (element.isLeaf()) |
707 { | 710 { |
708 std::auto_ptr<DicomValue> v(FromDcmtkBridge::ConvertLeafElement(element, flags, encoding)); | 711 std::auto_ptr<DicomValue> v(FromDcmtkBridge::ConvertLeafElement(element, flags, maxStringLength, encoding)); |
709 LeafValueToJson(target, *v, format, flags, maxStringLength); | 712 LeafValueToJson(target, *v, format, flags, maxStringLength); |
710 } | 713 } |
711 else | 714 else |
712 { | 715 { |
713 assert(target.type() == Json::nullValue); | 716 assert(target.type() == Json::nullValue); |