GDCM 3.0.24
gdcmBasicOffsetTable.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: GDCM (Grassroots DICOM). A DICOM library
4
5 Copyright (c) 2006-2011 Mathieu Malaterre
6 All rights reserved.
7 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12
13=========================================================================*/
14
15#ifndef GDCMBASICOFFSETTABLE_H
16#define GDCMBASICOFFSETTABLE_H
17
18#include "gdcmFragment.h"
19
20namespace gdcm_ns
21{
27{
28//protected:
29// void SetTag(const Tag &t);
30public:
32 friend std::ostream &operator<<(std::ostream &os, const BasicOffsetTable &val);
33
34/*
35 VL GetLength() const {
36 assert( !ValueLengthField.IsUndefined() );
37 assert( !ValueField || ValueField->GetLength() == ValueLengthField );
38 return TagField.GetLength() + ValueLengthField.GetLength()
39 + ValueLengthField;
40 }
41*/
42
43 template <typename TSwap>
44 std::istream &Read(std::istream &is) {
45 // Superclass
46 const Tag itemStart(0xfffe, 0xe000);
47 if( !TagField.Read<TSwap>(is) )
48 {
49 assert(0 && "Should not happen");
50 return is;
51 }
52 //assert( TagField == itemStart );
53 if( TagField != itemStart )
54 {
55 // Bug_Siemens_PrivateIconNoItem.dcm
56 //gdcmDebugMacro( "Could be Bug_Siemens_PrivateIconNoItem.dcm" );
58 pe.SetLastElement(*this);
59 //throw "SIEMENS Icon thingy";
60 throw pe;
61 }
62 if( !ValueLengthField.Read<TSwap>(is) )
63 {
64 assert(0 && "Should not happen");
65 return is;
66 }
67 // Self
69 bv->SetLength(ValueLengthField);
70 if( !bv->Read<TSwap>(is) )
71 {
72 gdcmAssertAlwaysMacro(0 && "Should not happen");
73 return is;
74 }
75 ValueField = bv;
76 return is;
77 }
78
79/*
80 template <typename TSwap>
81 std::ostream &Write(std::ostream &os) const {
82 const Tag itemStart(0xfffe, 0xe000);
83 const Tag seqDelItem(0xfffe,0xe0dd);
84 if( !TagField.Write<TSwap>(os) )
85 {
86 assert(0 && "Should not happen");
87 return os;
88 }
89 assert( TagField == itemStart );
90 if( !ValueLengthField.Write<TSwap>(os) )
91 {
92 assert(0 && "Should not happen");
93 return os;
94 }
95 if( ValueLengthField )
96 {
97 // Self
98 const ByteValue *bv = GetByteValue();
99 assert( bv );
100 assert( bv->GetLength() == ValueLengthField );
101 if( !bv->Write<TSwap>(os) )
102 {
103 assert(0 && "Should not happen");
104 return os;
105 }
106 }
107 return os;
108 }
109*/
110};
111//-----------------------------------------------------------------------------
112inline std::ostream &operator<<(std::ostream &os, const BasicOffsetTable &val)
113{
114 os << " BasicOffsetTable Length=" << val.ValueLengthField << std::endl;
115 if( val.ValueField )
116 {
117 const ByteValue *bv = val.GetByteValue();
118 assert( bv );
119 os << *bv;
120 }
121
122 return os;
123}
124
125
126} // end namespace gdcm_ns
127
128#endif //GDCMBASICOFFSETTABLE_H
Class to represent a BasicOffsetTable.
Definition gdcmBasicOffsetTable.h:27
BasicOffsetTable()
Definition gdcmBasicOffsetTable.h:31
std::istream & Read(std::istream &is)
Definition gdcmBasicOffsetTable.h:44
Class to represent binary value (array of bytes)
Definition gdcmByteValue.h:35
ValuePtr ValueField
Definition gdcmDataElement.h:250
const ByteValue * GetByteValue() const
Definition gdcmDataElement.h:133
VL ValueLengthField
Definition gdcmDataElement.h:245
Class to represent a Fragment.
Definition gdcmFragment.h:44
ParseException Standard exception handling object.
Definition gdcmParseException.h:37
void SetLastElement(DataElement &de)
Definition gdcmParseException.h:71
Class for Smart Pointer.
Definition gdcmSmartPointer.h:40
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element).
Definition gdcmTag.h:39
#define gdcmAssertAlwaysMacro(arg)
AssertAlways.
Definition gdcmTrace.h:228
#define GDCM_EXPORT
Definition gdcmWin32.h:34
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition gdcmDirectory.h:88