2 //-----------------------------------------------------------------------------
4 #include "gdcmHeaderEntry.h"
8 #ifdef GDCM_NO_ANSI_STRING_STREAM
10 # define ostringstream ostrstream
14 #include <iomanip> // for std::ios::left, ...
17 #define MAX_SIZE_PRINT_ELEMENT_VALUE 64
19 //-----------------------------------------------------------------------------
20 // Constructor / Destructor
22 * \ingroup gdcmHeaderEntry
23 * \brief Constructor from a given gdcmDictEntry
24 * @param in Pointer to existing dictionary entry
26 gdcmHeaderEntry::gdcmHeaderEntry(gdcmDictEntry* in) {
28 voidArea = NULL; // unsecure memory area to hold 'non string' values
32 //-----------------------------------------------------------------------------
34 void gdcmHeaderEntry::Print(std::ostream & os) {
36 unsigned short int g, e;
40 gdcmTS * ts = gdcmGlobal::GetTS();
43 char greltag[10]; //group element tag
50 sprintf(greltag,"%04x|%04x ",g,e);
53 d2 = _CreateCleanString(v); // replace non printable characters by '.'
56 lgth = GetReadLength(); // ReadLength, as opposed to UsableLength
57 if (lgth == 0xffffffff) {
58 sprintf(st,"x(ffff)"); // I said : "x(ffff)" !
59 s.setf(std::ios::left);
60 s << std::setw(10-strlen(st)) << " ";
62 s.setf(std::ios::left);
63 s << std::setw(8) << "-1";
65 sprintf(st,"x(%x)",lgth);
66 s.setf(std::ios::left);
67 s << std::setw(10-strlen(st)) << " ";
69 s.setf(std::ios::left);
70 s << std::setw(8) << lgth;
73 sprintf(st,"x(%x)",o);
74 s << std::setw(10-strlen(st)) << " ";
76 s << std::setw(8) << o;
79 s << "[" << vr << "] ";
82 s.setf(std::ios::left);
83 s << std::setw(66-GetName().length()) << " ";
86 s << "[" << GetName()<< "]";
88 if (voidArea != NULL) {
89 s << " [gdcm::Non String Data Loaded in Unsecure Area ("
90 << GetLength() << ") ]";
94 if( (GetLength()<MAX_SIZE_PRINT_ELEMENT_VALUE) ||
96 (d2.find("gdcm::NotLoaded.") < d2.length()) )
97 s << " [" << d2 << "]";
99 s << " [gdcm::too long for print (" << GetLength() << ") ]";
102 // Display the UID value (instead of displaying the rough code)
103 if (g == 0x0002) { // Any more to be displayed ?
104 if ( (e == 0x0010) || (e == 0x0002) )
105 s << " ==>\t[" << ts->GetValue(v) << "]";
108 if ( (e == 0x0016) || (e == 0x1150) )
109 s << " ==>\t[" << ts->GetValue(v) << "]";
112 if ( (e == 0x1510) || (e == 0x1512) )
113 s << " ==>\t[" << ts->GetValue(v) << "]";
117 //if (e == 0x0000) { // elem 0x0000 --> group length
118 if ( (vr == "UL") || (vr == "US") || (vr == "SL") || (vr == "SS") ) {
119 if (v == "4294967295") // to avoid troubles in convertion
120 sprintf (st," x(ffffffff)");
122 sprintf(st," x(%x)",(unsigned long)atof(v.c_str()));
129 //-----------------------------------------------------------------------------
132 //-----------------------------------------------------------------------------
135 //-----------------------------------------------------------------------------
138 //-----------------------------------------------------------------------------