X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestAllEntryVerify.cxx;h=641b8f7829c384b4803d8292a7a68c91180a8445;hb=f540ed5835e7b89478e6048a577d494c0e156f2a;hp=adcf230699a5c32217b448900d6e6902b022af38;hpb=87ce10cce5438852b777c8ff296a19f4ab0d065c;p=gdcm.git diff --git a/Testing/TestAllEntryVerify.cxx b/Testing/TestAllEntryVerify.cxx index adcf2306..641b8f78 100644 --- a/Testing/TestAllEntryVerify.cxx +++ b/Testing/TestAllEntryVerify.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestAllEntryVerify.cxx,v $ Language: C++ - Date: $Date: 2005/01/27 10:47:29 $ - Version: $Revision: 1.23 $ + Date: $Date: 2005/10/18 08:35:45 $ + Version: $Revision: 1.29 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -23,12 +23,9 @@ #include #include -//Generated file: -#include "gdcmDataImages.h" - -typedef std::string EntryValueType; // same type as ValEntry::value +typedef std::string EntryValueType; // same type as DataEntry::value typedef std::map< gdcm::TagKey, EntryValueType > MapEntryValues; -typedef MapEntryValues* MapEntryValuesPtr; +typedef MapEntryValues *MapEntryValuesPtr; typedef std::string FileNameType; typedef std::map< FileNameType, MapEntryValuesPtr > MapFileValuesType; @@ -54,28 +51,28 @@ public: ReferenceFileParser(); ~ReferenceFileParser(); - bool Open( std::string& referenceFileName ); + bool Open( std::string &referenceFileName ); void Print(); void SetDataPath(std::string&); bool Check(); bool Check( std::string fileName ); private: - bool AddKeyValuePairToMap( std::string& key, std::string& value ); + bool AddKeyValuePairToMap( std::string &key, std::string &value ); - std::istream& eatwhite(std::istream& is); - void eatwhite(std::string& toClean); - std::string ExtractFirstString(std::string& toSplit); - void CleanUpLine( std::string& line ); + std::istream &eatwhite(std::istream &is); + void eatwhite(std::string &toClean); + std::string ExtractFirstString(std::string &toSplit); + void CleanUpLine( std::string &line ); bool Check( MapFileValuesType::iterator &fileIt ); - std::string ExtractValue(std::string& toSplit) throw ( ParserException ); - void ParseRegularLine( std::string& line ) throw ( ParserException ); + std::string ExtractValue(std::string &toSplit) throw ( ParserException ); + void ParseRegularLine( std::string &line ) throw ( ParserException ); void FirstPassReferenceFile() throw ( ParserException ); bool SecondPassReferenceFile() throw ( ParserException ); - void HandleFileName( std::string& line ) throw ( ParserException ); - void HandleKey( std::string& line ) throw ( ParserException ); - bool HandleValue( std::string& line ) throw ( ParserException ); + void HandleFileName( std::string &line ) throw ( ParserException ); + void HandleKey( std::string &line ) throw ( ParserException ); + bool HandleValue( std::string &line ) throw ( ParserException ); static uint16_t axtoi( char* ); private: @@ -104,7 +101,7 @@ private: std::string CurrentValue; /// The current MapEntryValues pointer: - MapEntryValues* CurrentMapEntryValuesPtr; + MapEntryValues *CurrentMapEntryValuesPtr; }; ReferenceFileParser::ReferenceFileParser() @@ -117,13 +114,13 @@ ReferenceFileParser::~ReferenceFileParser() { for (MapFileValuesType::iterator i = ProducedMap.begin(); i != ProducedMap.end(); - ++i) + ++i) { delete i->second; } } -/// As gotten from: +/// As got from: /// http://community.borland.com/article/0,1410,17203,0.html uint16_t ReferenceFileParser::axtoi(char *hexStg) { @@ -157,16 +154,16 @@ uint16_t ReferenceFileParser::axtoi(char *hexStg) m--; // adjust the position to set n++; // next digit to process } - return intValue; + return (uint16_t)intValue; } -void ReferenceFileParser::SetDataPath( std::string& inDataPath ) +void ReferenceFileParser::SetDataPath( std::string &inDataPath ) { DataPath = inDataPath; } -bool ReferenceFileParser::AddKeyValuePairToMap( std::string& key, - std::string& value ) +bool ReferenceFileParser::AddKeyValuePairToMap( std::string &key, + std::string &value ) { if ( !CurrentMapEntryValuesPtr ) return false; @@ -181,16 +178,16 @@ void ReferenceFileParser::Print() { for (MapFileValuesType::iterator i = ProducedMap.begin(); i != ProducedMap.end(); - ++i) + ++i) { std::cout << Indent << "FileName: " << i->first << std::endl; MapEntryValuesPtr KeyValues = i->second; for (MapEntryValues::iterator j = KeyValues->begin(); j != KeyValues->end(); - ++j) + ++j) { std::cout << Indent - << " Key: " << j->first + << " Key: " << j->first << " Value: " << j->second << std::endl; } @@ -204,7 +201,7 @@ bool ReferenceFileParser::Check() bool ret = true; for (MapFileValuesType::iterator i = ProducedMap.begin(); i != ProducedMap.end(); - ++i) + ++i) { ret &= Check(i); } @@ -229,7 +226,11 @@ bool ReferenceFileParser::Check( MapFileValuesType::iterator &fileIt ) { std::string fileName = DataPath + fileIt->first; std::cout << Indent << "FileName: " << fileName << std::endl; - gdcm::File* tested = new gdcm::File( fileName.c_str() ); + + gdcm::File *tested; + tested = new gdcm::File( ); + tested->SetFileName( fileName.c_str() ); + tested->Load( ); if( !tested->IsReadable() ) { std::cerr << Indent << "Failed\n" @@ -242,7 +243,7 @@ bool ReferenceFileParser::Check( MapFileValuesType::iterator &fileIt ) MapEntryValuesPtr KeyValues = fileIt->second; for (MapEntryValues::iterator j = KeyValues->begin(); j != KeyValues->end(); - ++j) + ++j) { std::string key = j->first; @@ -277,7 +278,7 @@ bool ReferenceFileParser::Check( MapFileValuesType::iterator &fileIt ) return true; } -std::istream& ReferenceFileParser::eatwhite( std::istream& is ) +std::istream &ReferenceFileParser::eatwhite( std::istream &is ) { char c; while (is.get(c)) { @@ -289,13 +290,13 @@ std::istream& ReferenceFileParser::eatwhite( std::istream& is ) return is; } -void ReferenceFileParser::eatwhite( std::string& toClean ) +void ReferenceFileParser::eatwhite( std::string &toClean ) { while( toClean.find_first_of( " " ) == 0 ) toClean.erase( 0, toClean.find_first_of( " " ) + 1 ); } -std::string ReferenceFileParser::ExtractFirstString( std::string& toSplit ) +std::string ReferenceFileParser::ExtractFirstString( std::string &toSplit ) { std::string firstString; eatwhite( toSplit ); @@ -310,7 +311,7 @@ std::string ReferenceFileParser::ExtractFirstString( std::string& toSplit ) return firstString; } -std::string ReferenceFileParser::ExtractValue( std::string& toSplit ) +std::string ReferenceFileParser::ExtractValue( std::string &toSplit ) throw ( ParserException ) { eatwhite( toSplit ); @@ -477,7 +478,7 @@ void ReferenceFileParser::FirstPassReferenceFile() throw ( ParserException ) from.seekg( 0, std::ios::beg ); } -bool ReferenceFileParser::Open( std::string& referenceFileName ) +bool ReferenceFileParser::Open( std::string &referenceFileName ) { from.open( referenceFileName.c_str(), std::ios::in ); if ( !from.is_open() ) @@ -500,7 +501,7 @@ bool ReferenceFileParser::Open( std::string& referenceFileName ) return true; //?? } -void ReferenceFileParser::CleanUpLine( std::string& line ) +void ReferenceFileParser::CleanUpLine( std::string &line ) { // Cleanup from comments: if ( line.find_first_of( "#" ) != std::string::npos ) @@ -514,7 +515,7 @@ void ReferenceFileParser::CleanUpLine( std::string& line ) eatwhite( line ); } -void ReferenceFileParser::HandleFileName( std::string& line ) +void ReferenceFileParser::HandleFileName( std::string &line ) throw ( ParserException ) { if ( line.length() == 0 ) @@ -526,7 +527,7 @@ void ReferenceFileParser::HandleFileName( std::string& line ) CurrentFileName = ExtractFirstString(line); } -void ReferenceFileParser::HandleKey( std::string& line ) +void ReferenceFileParser::HandleKey( std::string &line ) throw ( ParserException ) { if ( CurrentKey.length() != 0 ) @@ -541,7 +542,7 @@ void ReferenceFileParser::HandleKey( std::string& line ) } } -bool ReferenceFileParser::HandleValue( std::string& line ) +bool ReferenceFileParser::HandleValue( std::string &line ) throw ( ParserException ) { if ( line.length() == 0 ) @@ -564,7 +565,7 @@ bool ReferenceFileParser::HandleValue( std::string& line ) return true; } -void ReferenceFileParser::ParseRegularLine( std::string& line) +void ReferenceFileParser::ParseRegularLine( std::string &line) throw ( ParserException ) { if ( line.length() == 0 ) @@ -648,7 +649,7 @@ bool ReferenceFileParser::SecondPassReferenceFile() return true; //?? } -int TestAllEntryVerify(int argc, char* argv[]) +int TestAllEntryVerify(int argc, char *argv[]) { if ( argc > 2 ) {