00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "gdcmDictEntry.h"
00020 #include "gdcmDebug.h"
00021 #include "gdcmUtil.h"
00022
00023 #include <iomanip>
00024 #include <fstream>
00025
00026 namespace gdcm
00027 {
00028
00029
00039 DictEntry::DictEntry(uint16_t group, uint16_t elem,
00040 TagName const &vr,
00041 TagName const &vm,
00042 TagName const &name)
00043 {
00044 Group = group;
00045 Element = elem;
00046 VR = vr;
00047 VM = vm;
00048 Name = name;
00049 Key = TranslateToKey(group, elem);
00050 }
00051
00052
00053
00059 void DictEntry::SetVR(TagName const &vr)
00060 {
00061 if ( IsVRUnknown() )
00062 {
00063 VR = vr;
00064 }
00065 else
00066 {
00067 gdcmErrorMacro( "Overwriting VR might compromise a dictionary");
00068 }
00069 }
00070
00076 void DictEntry::SetVM(TagName const &vm)
00077 {
00078 if ( IsVMUnknown() )
00079 {
00080 VM = vm;
00081 }
00082 else
00083 {
00084 gdcmErrorMacro( "Overwriting VM might compromise a dictionary");
00085 }
00086 }
00087
00095 TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t elem)
00096 {
00097 return Util::Format("%04x|%04x", group, elem);
00098 }
00099
00100
00101
00102
00103
00104
00105
00106
00107
00113 void DictEntry::Print(std::ostream &os, std::string const & )
00114 {
00115 std::string vr;
00116 std::ostringstream s;
00117
00118 vr = GetVR();
00119 if(vr==GDCM_UNKNOWN)
00120 vr=" ";
00121
00122 s << DictEntry::TranslateToKey(GetGroup(),GetElement());
00123 s << " [" << vr << "] ";
00124
00125 if (PrintLevel >= 1)
00126 {
00127 s.setf(std::ios::left);
00128 s << std::setw(66-GetName().length()) << " ";
00129 }
00130
00131 s << "[" << GetName()<< "]";
00132 os << s.str() << std::endl;
00133 }
00134
00135
00136 }
00137