]> Creatis software - gdcm.git/blob - Testing/TestDict.cxx
* src/gdcmDocument.[h|cxx] : comment all methods concerning a flat hash
[gdcm.git] / Testing / TestDict.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestDict.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/14 11:28:29 $
7   Version:   $Revision: 1.1 $
8                                                                                 
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.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18 #include "gdcmGlobal.h"
19 #include "gdcmDictSet.h"
20 #include "gdcmDict.h"
21 #include "gdcmDictEntry.h"
22
23 #include <iostream>
24 #include <iomanip>
25
26 int TestDict(int argc, char* argv[])
27 {  
28    // Print the DictSet
29    std::cout<<"#######################################################\n";
30    gdcm::DictSet *dicts=gdcm::Global::GetDicts();
31    if(!dicts)
32    {
33       std::cout<<"The DictSet hasn't be found... Failed\n";
34       return(1);
35    }
36    std::cout<<"DictSet content :\n";
37 //   dicts->Print(std::cout);
38
39    // Print the Dict (public)
40    std::cout<<"#######################################################\n";
41    gdcm::Dict *pubDict=dicts->GetDefaultPubDict();
42    if(!pubDict)
43    {
44       std::cout<<"The public Dict hasn't be found... Failed\n";
45       return(1);
46    }
47    std::cout<<"Public Dict content :\n";
48 //   pubDict->Print(std::cout);
49
50    // Print the DictEntry (0x10,0x20)
51    std::cout<<"#######################################################\n";
52    const int ENTRY_GR = 0x10;
53    const int ENTRY_EL = 0x20;
54    std::string key=gdcm::DictEntry::TranslateToKey(ENTRY_GR,ENTRY_EL);
55    gdcm::DictEntry *entry=pubDict->GetDictEntry(ENTRY_GR,ENTRY_EL);
56    if(!entry)
57    {
58       std::cout<<"The DictEntry hasn't be found... Failed\n";
59       return(1);
60    }
61    std::cout<<"Entry "<<key<<" content :\n";
62    entry->Print(std::cout);
63
64    // Print all the DictEntry
65    std::cout<<"#######################################################\n";
66    pubDict->InitTraversal();
67    entry=pubDict->GetNextEntry();
68    while(entry)
69    {
70       entry->Print(std::cout);
71       entry=pubDict->GetNextEntry();
72    }
73
74    return(0);
75 }