1 // gdcmDicomDirElement.cxx
2 //-----------------------------------------------------------------------------
5 #include "gdcmDicomDirElement.h"
9 # define PUB_DICT_PATH "../Dicts/"
11 #define DICT_ELEM "DicomDir.dic"
14 #ifdef GDCM_NO_ANSI_STRING_STREAM
16 # define ostringstream ostrstream
21 //-----------------------------------------------------------------------------
22 // Constructor / Destructor
23 gdcmDicomDirElement::gdcmDicomDirElement(void)
25 std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_ELEM);
26 std::ifstream from(filename.c_str());
27 dbg.Error(!from, "gdcmDicomDirElement::gdcmDicomDirElement: can't open dictionary",filename.c_str());
35 from.getline(buff, 1024, ' ');
38 if( (type=="metaElem") || (type=="patientElem") ||
39 (type=="studyElem") || (type=="serieElem") ||
42 from >> std::hex >> elem.group >> elem.elem;
45 from.getline(buff, 1024, '"');
47 from.getline(buff, 1024, '"');
51 MetaList.push_back(elem);
52 else if(type=="patientElem")
53 PatientList.push_back(elem);
54 else if(type=="studyElem")
55 StudyList.push_back(elem);
56 else if(type=="serieElem")
57 SerieList.push_back(elem);
58 else if(type=="imageElem")
59 ImageList.push_back(elem);
62 from.getline(buff, 1024, '\n');
67 gdcmDicomDirElement::~gdcmDicomDirElement()
76 //-----------------------------------------------------------------------------
81 * @param os The output stream to be written to.
83 void gdcmDicomDirElement::Print(std::ostream &os)
86 std::list<gdcmElement>::iterator it;
87 char greltag[10]; //group element tag
89 s << "Meta Elements :"<<std::endl;
90 for (it = MetaList.begin();it!=MetaList.end();++it)
92 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
93 s << " ("<<greltag<<") = "<< it->value<<std::endl;
96 s << "Patient Elements :"<<std::endl;
97 for (it = PatientList.begin();it!=PatientList.end();++it)
99 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
100 s << " ("<<greltag<<") = "<< it->value<<std::endl;
103 s << "Study Elements :"<<std::endl;
104 for (it = StudyList.begin();it!=StudyList.end();++it)
106 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
107 s << " ("<<greltag<<") = "<< it->value<<std::endl;
110 s << "Serie Elements :"<<std::endl;
111 for (it = SerieList.begin();it!=SerieList.end();++it)
113 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
114 s << " ("<<greltag<<") = "<< it->value<<std::endl;
117 s << "Image Elements :"<<std::endl;
118 for (it = ImageList.begin();it!=ImageList.end();++it)
120 sprintf(greltag,"%04x|%04x ",it->group,it->elem);
121 s << " ("<<greltag<<") = "<< it->value<<std::endl;
127 //-----------------------------------------------------------------------------
130 //-----------------------------------------------------------------------------
133 //-----------------------------------------------------------------------------
136 //-----------------------------------------------------------------------------