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
49 sprintf(greltag,"%04x|%04x ",g,e);
52 d2 = _CreateCleanString(v); // replace non printable characters by '.'
55 lgth = GetReadLength(); // ReadLength, as opposed to UsableLength
56 if (lgth == 0xffffffff) {
57 sprintf(st,"x(ffff)"); // I said : "x(ffff)" !
58 s.setf(std::ios::left);
59 s << std::setw(10-strlen(st)) << " ";
61 s.setf(std::ios::left);
62 s << std::setw(8) << "-1";
64 sprintf(st,"x(%x)",lgth);
65 s.setf(std::ios::left);
66 s << std::setw(10-strlen(st)) << " ";
68 s.setf(std::ios::left);
69 s << std::setw(8) << lgth;
72 sprintf(st,"x(%x)",o);
73 s << std::setw(10-strlen(st)) << " ";
75 s << std::setw(8) << o;
78 s << "[" << vr << "] ";
81 s.setf(std::ios::left);
82 s << std::setw(66-GetName().length()) << " ";
85 s << "[" << GetName()<< "]";
87 if (voidArea != NULL) {
88 s << " [gdcm::Non String Data Loaded in Unsecure Area ("
89 << GetLength() << ") ]";
93 if( (GetLength()<MAX_SIZE_PRINT_ELEMENT_VALUE) ||
95 (d2.find("gdcm::NotLoaded.") < d2.length()) )
96 s << " [" << d2 << "]";
98 s << " [gdcm::too long for print (" << GetLength() << ") ]";
101 // Display the UID value (instead of displaying the rough code)
102 if (g == 0x0002) { // Any more to be displayed ?
103 if ( (e == 0x0010) || (e == 0x0002) )
104 s << " ==>\t[" << ts->GetValue(v) << "]";
107 if ( (e == 0x0016) || (e == 0x1150) )
108 s << " ==>\t[" << ts->GetValue(v) << "]";
111 if ( (e == 0x1510) || (e == 0x1512) )
112 s << " ==>\t[" << ts->GetValue(v) << "]";
116 //if (e == 0x0000) { // elem 0x0000 --> group length
117 if ( (vr == "UL") || (vr == "US") || (vr == "SL") || (vr == "SS") ) {
118 if (v == "4294967295") // to avoid troubles in convertion
119 sprintf (st," x(ffffffff)");
121 sprintf(st," x(%x)",(unsigned long)atof(v.c_str()));
128 //-----------------------------------------------------------------------------
131 //-----------------------------------------------------------------------------
134 //-----------------------------------------------------------------------------
137 //-----------------------------------------------------------------------------