Mercurial > hg > orthanc
annotate Resources/Patches/dcmtk-dcdict_orthanc.cc @ 3677:4182cde57afb
refactoring FindStorageAccessMode
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 19 Feb 2020 17:17:27 +0100 |
parents | 0080c9b492e5 |
children |
rev | line source |
---|---|
3593
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 // Function by the Orthanc project to load a dictionary from a memory |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 // buffer, which is necessary in sandboxed environments. This is an |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 // adapted version of DcmDataDictionary::loadDictionary(). |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 |
3595 | 5 #include <string> |
3593
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 #include <boost/noncopyable.hpp> |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 struct OrthancLinesIterator; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 // This plain old C class is implemented in "../../Core/Toolbox.h" |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 OrthancLinesIterator* OrthancLinesIterator_Create(const std::string& content); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 bool OrthancLinesIterator_GetLine(std::string& target, |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 const OrthancLinesIterator* iterator); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 void OrthancLinesIterator_Next(OrthancLinesIterator* iterator); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 void OrthancLinesIterator_Free(OrthancLinesIterator* iterator); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 class LinesIterator : public boost::noncopyable |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 private: |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 OrthancLinesIterator* iterator_; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 public: |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 LinesIterator(const std::string& content) : |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 iterator_(NULL) |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 iterator_ = OrthancLinesIterator_Create(content); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 ~LinesIterator() |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 if (iterator_ != NULL) |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 OrthancLinesIterator_Free(iterator_); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 iterator_ = NULL; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 bool GetLine(std::string& target) const |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 if (iterator_ != NULL) |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 return OrthancLinesIterator_GetLine(target, iterator_); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 else |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 return false; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 void Next() |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 if (iterator_ != NULL) |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 OrthancLinesIterator_Next(iterator_); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 }; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 OFBool |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 DcmDataDictionary::loadFromMemory(const std::string& content, OFBool errorIfAbsent) |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 int lineNumber = 0; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 char* lineFields[DCM_MAXDICTFIELDS + 1]; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 int fieldsPresent; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 DcmDictEntry* e; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 int errorsEncountered = 0; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 OFBool errorOnThisLine = OFFalse; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 int i; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 DcmTagKey key, upperKey; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 DcmDictRangeRestriction groupRestriction = DcmDictRange_Unspecified; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 DcmDictRangeRestriction elementRestriction = DcmDictRange_Unspecified; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 DcmVR vr; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 char* vrName; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 char* tagName; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 char* privCreator; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 int vmMin, vmMax = 1; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 const char* standardVersion; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 LinesIterator iterator(content); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 std::string line; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 while (iterator.GetLine(line)) { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 iterator.Next(); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 if (line.size() >= DCM_MAXDICTLINESIZE) { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 DCMDATA_ERROR("DcmDataDictionary: Too long line: " << line); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 continue; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 lineNumber++; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 if (onlyWhitespace(line.c_str())) { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 continue; /* ignore this line */ |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 if (isaCommentLine(line.c_str())) { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 continue; /* ignore this line */ |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 errorOnThisLine = OFFalse; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 /* fields are tab separated */ |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 fieldsPresent = splitFields(line.c_str(), lineFields, |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 DCM_MAXDICTFIELDS, |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 DCM_DICT_FIELD_SEPARATOR_CHAR); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 /* initialize dict entry fields */ |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 vrName = NULL; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 tagName = NULL; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 privCreator = NULL; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 vmMin = vmMax = 1; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 standardVersion = "DICOM"; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 switch (fieldsPresent) { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 case 0: |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 case 1: |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 case 2: |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 DCMDATA_ERROR("DcmDataDictionary: " |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 << "too few fields (line " << lineNumber << ")"); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 errorOnThisLine = OFTrue; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 break; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 default: |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 DCMDATA_ERROR("DcmDataDictionary: " |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 << "too many fields (line " << lineNumber << "): "); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 errorOnThisLine = OFTrue; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 break; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 case 5: |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 stripWhitespace(lineFields[4]); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 standardVersion = lineFields[4]; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 /* drop through to next case label */ |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 case 4: |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 /* the VM field is present */ |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 if (!parseVMField(lineFields[3], vmMin, vmMax)) { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 DCMDATA_ERROR("DcmDataDictionary: " |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 << "bad VM field (line " << lineNumber << "): " << lineFields[3]); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 errorOnThisLine = OFTrue; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 /* drop through to next case label */ |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 case 3: |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 if (!parseWholeTagField(lineFields[0], key, upperKey, |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 groupRestriction, elementRestriction, privCreator)) |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 DCMDATA_ERROR("DcmDataDictionary: " |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 << "bad Tag field (line " << lineNumber << "): " << lineFields[0]); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 errorOnThisLine = OFTrue; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 } else { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 /* all is OK */ |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 vrName = lineFields[1]; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 stripWhitespace(vrName); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 tagName = lineFields[2]; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 stripWhitespace(tagName); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 if (!errorOnThisLine) { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 /* check the VR Field */ |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 vr.setVR(vrName); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 if (vr.getEVR() == EVR_UNKNOWN) { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 DCMDATA_ERROR("DcmDataDictionary: " |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 << "bad VR field (line " << lineNumber << "): " << vrName); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 errorOnThisLine = OFTrue; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 if (!errorOnThisLine) { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 e = new DcmDictEntry( |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 key.getGroup(), key.getElement(), |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 upperKey.getGroup(), upperKey.getElement(), |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 vr, tagName, vmMin, vmMax, standardVersion, OFTrue, |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 privCreator); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 e->setGroupRangeRestriction(groupRestriction); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 e->setElementRangeRestriction(elementRestriction); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 addEntry(e); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 for (i = 0; i < fieldsPresent; i++) { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 free(lineFields[i]); |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 lineFields[i] = NULL; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 delete[] privCreator; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 if (errorOnThisLine) { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 errorsEncountered++; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 /* return OFFalse in case of errors and set internal state accordingly */ |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 if (errorsEncountered == 0) { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 dictionaryLoaded = OFTrue; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 return OFTrue; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 else { |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 dictionaryLoaded = OFFalse; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 return OFFalse; |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 } |
0301f59450fe
improved the patch for loading DICOM dictionary from memory
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 } |