]> Creatis software - gdcm.git/blob - src/gdcmBinEntry.cxx
ae4c5be868395906260f7a5a65a114f2a1d498bc
[gdcm.git] / src / gdcmBinEntry.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmBinEntry.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/06/24 18:03:14 $
7   Version:   $Revision: 1.18 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #include "gdcmBinEntry.h"
20 #include "gdcmDebug.h"
21
22
23 //-----------------------------------------------------------------------------
24 // Constructor / Destructor
25
26 /**
27  * \brief   Constructor from a given gdcmBinEntry
28  */
29 gdcmBinEntry::gdcmBinEntry(gdcmDictEntry* e) : gdcmValEntry(e)
30 {
31    this->voidArea = NULL;
32 }
33
34 /**
35  * \brief   Constructor from a given gdcmBinEntry
36  * @param   e Pointer to existing Doc entry
37  */
38 gdcmBinEntry::gdcmBinEntry(gdcmDocEntry* e) : gdcmValEntry(e->GetDictEntry())
39 {
40    this->UsableLength = e->GetLength();
41    this->ReadLength   = e->GetReadLength();
42    this->ImplicitVR   = e->IsImplicitVR();
43    this->Offset       = e->GetOffset();
44    this->printLevel   = e->GetPrintLevel();
45    this->SQDepthLevel = e->GetDepthLevel();
46
47    this->voidArea = NULL; // let's be carefull !
48 }
49
50 /**
51  * \brief   Canonical destructor.
52  */
53 gdcmBinEntry::~gdcmBinEntry(){
54    if (voidArea)
55       free (voidArea);
56 }
57
58
59 //-----------------------------------------------------------------------------
60 // Print
61 /*
62  * \brief   canonical Printer
63  */
64  
65 void gdcmBinEntry::Print(std::ostream &os)
66 {
67    gdcmDocEntry::Print(os);
68    std::ostringstream s;
69    void *voidArea = GetVoidArea();      
70    if (voidArea != NULL)
71    {
72       s << " [gdcm::Binary data loaded with length is "
73         << GetLength() << "]";
74    }
75    else
76    {
77       if ( GetLength() == 0 )
78          s << " []";
79       else 
80       {
81          s << " [gdcm::Binary data NOT loaded]";
82       }
83          
84    }
85    os << s.str();
86 }
87
88 /*
89  * \brief   canonical Writer
90  */
91 void gdcmBinEntry::Write(FILE *fp, FileType filetype) {
92    gdcmDocEntry::Write(fp, filetype);
93    void *voidArea = GetVoidArea();
94    int lgr=GetLength();
95    if (voidArea != NULL) 
96    { // there is a 'non string' LUT, overlay, etc
97       fwrite ( voidArea,(size_t)lgr ,(size_t)1 ,fp); // Elem value
98       return;            
99    } 
100 }
101 //-----------------------------------------------------------------------------
102 // Public
103
104 //-----------------------------------------------------------------------------
105 // Protected
106
107 //-----------------------------------------------------------------------------
108 // Private
109    
110 //-----------------------------------------------------------------------------