1 // gdcmDicomDirElement.cxx
2 //-----------------------------------------------------------------------------
4 #include <stdio.h> // For sprintf
6 #include "gdcmDicomDirElement.h"
10 # define PUB_DICT_PATH "../Dicts/"
12 #define DICT_ELEM "DicomDir.dic"
15 #ifdef GDCM_NO_ANSI_STRING_STREAM
17 # define ostringstream ostrstream
22 //-----------------------------------------------------------------------------
23 // Constructor / Destructor
24 gdcmDicomDirElement::gdcmDicomDirElement(void)
26 std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_ELEM);
27 std::ifstream from(filename.c_str());
28 dbg.Error(!from, "gdcmDicomDirElement::gdcmDicomDirElement: can't open dictionary",filename.c_str());
36 from.getline(buff, 1024, ' ');
39 if( (type=="metaElem") || (type=="patientElem") ||
40 (type=="studyElem") || (type=="serieElem") ||
43 from >> std::hex >> elem.group >> elem.elem;
46 from.getline(buff, 1024, '"');
48 from.getline(buff, 1024, '"');
52 MetaList.push_back(elem);
53 else if(type=="patientElem")
54 PatientList.push_back(elem);
55 else if(type=="studyElem")
56 StudyList.push_back(elem);
57 else if(type=="serieElem")
58 SerieList.push_back(elem);
59 else if(type=="imageElem")
60 ImageList.push_back(elem);
63 from.getline(buff, 1024, '\n');
68 gdcmDicomDirElement::~gdcmDicomDirElement()
77 //-----------------------------------------------------------------------------
82 * @param os The output stream to be written to.
84 void gdcmDicomDirElement::Print(std::ostream &os)
87 std::list<gdcmElement>::iterator it;
88 char greltag[10]; //group element tag
90 s << "Meta Elements :"<<std::endl;
91 for (it = MetaList.begin();it!=MetaList.end();++it)
93 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
94 s << " ("<<greltag<<") = "<< it->value<<std::endl;
97 s << "Patient Elements :"<<std::endl;
98 for (it = PatientList.begin();it!=PatientList.end();++it)
100 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
101 s << " ("<<greltag<<") = "<< it->value<<std::endl;
104 s << "Study Elements :"<<std::endl;
105 for (it = StudyList.begin();it!=StudyList.end();++it)
107 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
108 s << " ("<<greltag<<") = "<< it->value<<std::endl;
111 s << "Serie Elements :"<<std::endl;
112 for (it = SerieList.begin();it!=SerieList.end();++it)
114 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
115 s << " ("<<greltag<<") = "<< it->value<<std::endl;
118 s << "Image Elements :"<<std::endl;
119 for (it = ImageList.begin();it!=ImageList.end();++it)
121 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
122 s << " ("<<greltag<<") = "<< it->value<<std::endl;
128 //-----------------------------------------------------------------------------
131 //-----------------------------------------------------------------------------
134 //-----------------------------------------------------------------------------
137 //-----------------------------------------------------------------------------