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
26 * \ingroup gdcmDicomDirElement
29 gdcmDicomDirElement::gdcmDicomDirElement(void)
31 std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_ELEM);
32 std::ifstream from(filename.c_str());
33 dbg.Error(!from, "gdcmDicomDirElement::gdcmDicomDirElement: can't open dictionary",filename.c_str());
41 from.getline(buff, 1024, ' ');
44 if( (type=="metaElem") || (type=="patientElem") ||
45 (type=="studyElem") || (type=="serieElem") ||
48 from >> std::hex >> elem.group >> elem.elem;
51 from.getline(buff, 1024, '"');
53 from.getline(buff, 1024, '"');
57 MetaList.push_back(elem);
58 else if(type=="patientElem")
59 PatientList.push_back(elem);
60 else if(type=="studyElem")
61 StudyList.push_back(elem);
62 else if(type=="serieElem")
63 SerieList.push_back(elem);
64 else if(type=="imageElem")
65 ImageList.push_back(elem);
68 from.getline(buff, 1024, '\n');
74 * \ingroup gdcmDicomDirElement
77 gdcmDicomDirElement::~gdcmDicomDirElement()
86 //-----------------------------------------------------------------------------
89 * \ingroup gdcmDicomDirElement
91 * \todo add a 'Print Level' check
92 * @param os The output stream to be written to.
94 void gdcmDicomDirElement::Print(std::ostream &os)
97 std::list<gdcmElement>::iterator it;
98 char greltag[10]; //group element tag
100 s << "Meta Elements :"<<std::endl;
101 for (it = MetaList.begin();it!=MetaList.end();++it)
103 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
104 s << " ("<<greltag<<") = "<< it->value<<std::endl;
107 s << "Patient Elements :"<<std::endl;
108 for (it = PatientList.begin();it!=PatientList.end();++it)
110 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
111 s << " ("<<greltag<<") = "<< it->value<<std::endl;
114 s << "Study Elements :"<<std::endl;
115 for (it = StudyList.begin();it!=StudyList.end();++it)
117 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
118 s << " ("<<greltag<<") = "<< it->value<<std::endl;
121 s << "Serie Elements :"<<std::endl;
122 for (it = SerieList.begin();it!=SerieList.end();++it)
124 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
125 s << " ("<<greltag<<") = "<< it->value<<std::endl;
128 s << "Image Elements :"<<std::endl;
129 for (it = ImageList.begin();it!=ImageList.end();++it)
131 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
132 s << " ("<<greltag<<") = "<< it->value<<std::endl;
138 //-----------------------------------------------------------------------------
141 //-----------------------------------------------------------------------------
144 //-----------------------------------------------------------------------------
147 //-----------------------------------------------------------------------------