comparison OrthancFramework/Sources/DicomFormat/DicomPath.cpp @ 4682:d38a7040474a

FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 07 Jun 2021 18:35:46 +0200
parents c5528c7847a6
children 7182f5732480
comparison
equal deleted inserted replaced
4681:c5528c7847a6 4682:d38a7040474a
152 { 152 {
153 prefix_.push_back(PrefixItem::CreateUniversal(tag)); 153 prefix_.push_back(PrefixItem::CreateUniversal(tag));
154 } 154 }
155 155
156 156
157 bool DicomPath::HasUniversal() const
158 {
159 for (size_t i = 0; i < prefix_.size(); i++)
160 {
161 if (prefix_[i].IsUniversal())
162 {
163 return true;
164 }
165 }
166
167 return false;
168 }
169
170
157 std::string DicomPath::Format() const 171 std::string DicomPath::Format() const
158 { 172 {
159 std::string s; 173 std::string s;
160 174
161 for (size_t i = 0; i < prefix_.size(); i++) 175 for (size_t i = 0; i < prefix_.size(); i++)
174 188
175 return s + "(" + finalTag_.Format() + ")"; 189 return s + "(" + finalTag_.Format() + ")";
176 } 190 }
177 191
178 192
179 DicomPath DicomPath::Parse(const std::string& s, 193 DicomPath DicomPath::Parse(const std::string& s)
180 bool allowUniversal)
181 { 194 {
182 std::vector<std::string> tokens; 195 std::vector<std::string> tokens;
183 Toolbox::TokenizeString(tokens, s, '.'); 196 Toolbox::TokenizeString(tokens, s, '.');
184 197
185 if (tokens.empty()) 198 if (tokens.empty())
219 try 232 try
220 { 233 {
221 std::string s = Toolbox::StripSpaces(right.substr(0, right.size() - 1)); 234 std::string s = Toolbox::StripSpaces(right.substr(0, right.size() - 1));
222 if (s == "*") 235 if (s == "*")
223 { 236 {
224 if (allowUniversal) 237 path.AddUniversalTagToPrefix(tag);
225 {
226 path.AddUniversalTagToPrefix(tag);
227 }
228 else
229 {
230 throw OrthancException(ErrorCode_ParameterOutOfRange, "Cannot create an universal parent path");
231 }
232 } 238 }
233 else 239 else
234 { 240 {
235 int index = boost::lexical_cast<int>(s); 241 int index = boost::lexical_cast<int>(s);
236 if (index < 0) 242 if (index < 0)