1 /*=========================================================================
4 Module: $RCSfile: gdcmValidator.cxx,v $
6 Date: $Date: 2005/11/03 08:28:40 $
7 Version: $Revision: 1.7 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #include "gdcmValidator.h"
20 #include "gdcmElementSet.h"
21 #include "gdcmDataEntry.h"
29 Validator::Validator()
33 Validator::~Validator()
37 // Function to compare the VM found while parsing d->GetString()
38 // compare to the one from the dictionary
39 bool CheckVM(DataEntry *entry)
41 // Don't waste time checking tags where VM is OB and OW, since we know
42 // it's allways 1, whatever the actual length (found on disc)
44 if ( entry->GetVR() == "OB" || entry->GetVR() == "OW" )
47 const std::string &s = entry->GetString();
49 /* std::string::size_type n = s.find("\\");
50 if ( n == s.npos ) // none found
56 int n = Util::CountSubstring( s , "\\");
58 n++; // number of '\' + 1 == Value Multiplicity
60 std::string vmFromDict = entry->GetVM();
61 if ( vmFromDict == "1-n" || vmFromDict == "2-n" || vmFromDict == "3-n" )
65 std::istringstream is;
72 void Validator::SetInput(ElementSet *input)
74 // berk for now SetInput do two things at the same time
75 DocEntry *d=input->GetFirstEntry();
78 std::cout << "No Entry found" << std::endl;
83 if ( DataEntry *v = dynamic_cast<DataEntry *>(d) )
85 if ( v->GetVM() != gdcm::GDCM_UNKNOWN )
88 std::cout << "Tag (" << v->GetKey()
89 << ")-> [" << v->GetName() << "] contains an illegal VM. "
90 << "value [" << v->GetString() << "] VR :"
91 << v->GetVR() << ", Expected VM :" << v->GetVM() << " "
95 if ( v->GetReadLength() % 2 )
97 std::cout << "Tag (" << v->GetKey()
98 << ")-> [" << v->GetName() << "] has an uneven length :"
100 << " [" << v->GetString() << "] "
106 // We skip pb of SQ recursive exploration
108 d=input->GetNextEntry();
112 } // end namespace gdcm