2 //-----------------------------------------------------------------------------
5 #include "gdcmDocEntry.h"
7 #include "gdcmGlobal.h"
10 #include <iomanip> // for std::ios::left, ...
13 #define MAX_SIZE_PRINT_ELEMENT_VALUE 64
15 //-----------------------------------------------------------------------------
16 // Constructor / Destructor
18 * \ingroup gdcmDocEntry
19 * \brief Constructor from a given gdcmDictEntry
20 * @param in Pointer to existing dictionary entry
22 gdcmDocEntry::gdcmDocEntry(gdcmDictEntry* in) {
28 * \ingroup gdcmDocEntry
29 * \brief Canonical Printer
30 * @param os ostream we want to print in
32 void gdcmDocEntry::Print(std::ostream & os) {
39 //-----------------------------------------------------------------------------
42 * \ingroup gdcmDocEntry
43 * \brief Prints the common part of gdcmValEntry, gdcmBinEntry, gdcmSeqEntry
45 void gdcmDocEntry::PrintCommonPart(std::ostream & os) {
47 printLevel=2; // FIXME
50 unsigned short int g, e;
56 char greltag[10]; //group element tag
62 sprintf(greltag,"%04x|%04x ",g,e);
67 lgth = GetReadLength(); // ReadLength, as opposed to UsableLength
68 if (lgth == 0xffffffff) {
69 sprintf(st,"x(ffff)"); // I said : "x(ffff)" !
70 s.setf(std::ios::left);
71 s << std::setw(10-strlen(st)) << " ";
73 s.setf(std::ios::left);
74 s << std::setw(8) << "-1";
76 sprintf(st,"x(%x)",lgth);
77 s.setf(std::ios::left);
78 s << std::setw(10-strlen(st)) << " ";
80 s.setf(std::ios::left);
81 s << std::setw(8) << lgth;
84 sprintf(st,"x(%x)",o);
85 s << std::setw(10-strlen(st)) << " ";
87 s << std::setw(8) << o;
90 s << "[" << vr << "] ";
93 s.setf(std::ios::left);
94 s << std::setw(66-GetName().length()) << " ";
97 s << "[" << GetName()<< "]";
101 //-----------------------------------------------------------------------------
105 * \ingroup gdcmDocEntry
106 * \brief Gets the full length of the elementary DocEntry (not only value length)
108 guint32 gdcmDocEntry::GetFullLength(void) {
111 if ( IsImplicitVR() )
112 l = l + 8; // 2 (gr) + 2 (el) + 4 (lgth)
114 if ( GetVR()=="OB" || GetVR()=="OW" || GetVR()=="SQ" )
115 l = l + 12; // 2 (gr) + 2 (el) + 2 (vr) + 2 (unused) + 4 (lgth)
117 l = l + 8; // 2 (gr) + 2 (el) + 2 (vr) + 2 (lgth)
122 * \ingroup gdcmDocEntry
123 * \brief Copies all the attributes from an other DocEntry
125 void gdcmDocEntry::Copy (gdcmDocEntry* e) {
126 this->entry = e->entry;
127 this->UsableLength = e->UsableLength;
128 this->ReadLength = e->ReadLength;
129 this->ImplicitVR = e->ImplicitVR;
130 this->Offset = e->Offset;
131 this->printLevel = e->printLevel;
132 // TODO : remove gdcmDocEntry SQDepth
136 * \ingroup gdcmDocEntry
137 * \brief tells us if entry is the first one of a Sequence Item (fffe,e00d)
139 bool gdcmDocEntry::isItemDelimitor() {
140 if ( (GetGroup() == 0xfffe) && (GetElement() == 0xe00d) )
146 * \ingroup gdcmDocEntry
147 * \brief tells us if entry is the last one of a 'no length' Sequence fffe,e0dd)
149 bool gdcmDocEntry::isSequenceDelimitor() {
150 if (GetGroup() == 0xfffe && GetElement() == 0xe0dd)
156 //-----------------------------------------------------------------------------
160 //-----------------------------------------------------------------------------
163 //-----------------------------------------------------------------------------