GDCM 3.2.1

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
20 namespace gdcm_ns
21{
25
26 class GDCM_EXPORT BasicOffsetTable : public Fragment
27{
28//protected:
29// void SetTag(const Tag &t);
30 public:
31 BasicOffsetTable() : Fragment() {}
32 friend std::ostream &operator<<(std::ostream &os, const BasicOffsetTable &val);
33
34/*
35 VL GetLength() const {
36 gdcm_assert( !ValueLengthField.IsUndefined() );
37 gdcm_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 gdcm_assert(0 && "Should not happen");
50 return is;
51 }
52 //gdcm_assert( TagField == itemStart );
53 if( TagField != itemStart )
54 {
55 // Bug_Siemens_PrivateIconNoItem.dcm
56 //gdcmDebugMacro( "Could be Bug_Siemens_PrivateIconNoItem.dcm" );
57 ParseException pe;
58 pe.SetLastElement(*this);
59 //throw "SIEMENS Icon thingy";
60 throw pe;
61 }
62 if( !ValueLengthField.Read<TSwap>(is) )
63 {
64 gdcm_assert(0 && "Should not happen");
65 return is;
66 }
67 // Self
68 SmartPointer<ByteValue> bv = new ByteValue;
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 gdcm_assert(0 && "Should not happen");
87 return os;
88 }
89 gdcm_assert( TagField == itemStart );
90 if( !ValueLengthField.Write<TSwap>(os) )
91 {
92 gdcm_assert(0 && "Should not happen");
93 return os;
94 }
95 if( ValueLengthField )
96 {
97 // Self
98 const ByteValue *bv = GetByteValue();
99 gdcm_assert( bv );
100 gdcm_assert( bv->GetLength() == ValueLengthField );
101 if( !bv->Write<TSwap>(os) )
102 {
103 gdcm_assert(0 && "Should not happen");
104 return os;
105 }
106 }
107 return os;
108 }
109*/
110};
111//-----------------------------------------------------------------------------
112 inline 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 gdcm_assert( bv );
119 os << *bv;
120 }
121
122 return os;
123}
124
125
126} // end namespace gdcm_ns
127
128#endif //GDCMBASICOFFSETTABLE_H
gdcm::BasicOffsetTable
Class to represent a BasicOffsetTable.
Definition gdcmBasicOffsetTable.h:27
gdcm::BasicOffsetTable::BasicOffsetTable
BasicOffsetTable()
Definition gdcmBasicOffsetTable.h:31
gdcm::BasicOffsetTable::Read
std::istream & Read(std::istream &is)
Definition gdcmBasicOffsetTable.h:44
gdcm::BasicOffsetTable::operator<<
friend std::ostream & operator<<(std::ostream &os, const BasicOffsetTable &val)
Definition gdcmBasicOffsetTable.h:112
gdcm::ByteValue
Class to represent binary value (array of bytes)
Definition gdcmByteValue.h:36
gdcm::DataElement::ValueField
ValuePtr ValueField
Definition gdcmDataElement.h:250
gdcm::DataElement::GetByteValue
const ByteValue * GetByteValue() const
Definition gdcmDataElement.h:133
gdcm::DataElement::TagField
Tag TagField
Definition gdcmDataElement.h:243
gdcm::DataElement::ValueLengthField
VL ValueLengthField
Definition gdcmDataElement.h:245
gdcm::Fragment::Fragment
Fragment()
Definition gdcmFragment.h:48
gdcm::ParseException
ParseException Standard exception handling object.
Definition gdcmParseException.h:37
gdcm::ParseException::SetLastElement
void SetLastElement(const DataElement &de)
Definition gdcmParseException.h:71
gdcm::SmartPointer
Class for Smart Pointer.
Definition gdcmSmartPointer.h:40
gdcm::Tag
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element).
Definition gdcmTag.h:39
gdcm_assert
#define gdcm_assert(cond)
Definition gdcmException.h:104
gdcmFragment.h
gdcmAssertAlwaysMacro
#define gdcmAssertAlwaysMacro(arg)
AssertAlways.
Definition gdcmTrace.h:228
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm::operator<<
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition gdcmDirectory.h:88