1 /*=========================================================================
4 Module: $RCSfile: TestHash.cxx,v $
6 Date: $Date: 2005/02/02 10:05:26 $
7 Version: $Revision: 1.17 $
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 =========================================================================*/
18 #include "gdcmCommon.h" //to shut up warnings
19 // Checks the basic functionalities of STL <map>.
24 int TestHash( int, char *[] )
26 std::cout << "Test::TestHash : " << std::endl;
27 std::cout << " Checks that the basic STL <map> functionalities required "
29 << " by gdcm are operational. " << std::endl;
31 typedef std::map<std::string, std::string> dict;
34 // Adding entries by key:
36 dict::iterator im = tb1.find("00380010");
37 tb1["00100010"] = "Patient Name";
38 tb1["7fe00010"] = "Pixel Data";
39 tb1["50000010"] = "Number of points";
40 tb1["00380010"] = "Admission ID";
42 // Travesing the dictionary:
44 std::cout << " Traversal of dictionary (note the proper ordering on key):"
46 for ( im = tb1.begin(); im != tb1.end(); ++im )
47 std::cout << " \"" << im->first << "\" = " << im->second
49 std::cout << " End of dictionary." << std::endl;
53 std::cout << " Find request on key 00380010" << std::endl;
54 im = tb1.find("00380010");
55 std::cout << " \"" << im->first << "\" = " << im->second << std::endl;
57 // The following should print in hexadecimal an in decimal the given
58 // integer as stated by:
59 // http://www.developer.com/net/cplus/article.php/10919_2119781_3
60 // Alas it doesn't work with g++ (at least)...
62 //std::cout.setf(std::ios::hex);
63 std::cout << "Test::TestHash : hexdecimal output : " << std::hex << i << std::endl;
64 //std::cout.setf(std::ios::dec);
65 std::cout << "Test::TestHash : decimal output : " << std::dec << i << std::endl;