]> Creatis software - gdcm.git/blobdiff - src/gdcm.h
2002-12-6 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
[gdcm.git] / src / gdcm.h
index 6a43de040255dd7b70e17c144571754e14e6391f..3b35c7629547c70a4e09e148e47e3138c052e399 100644 (file)
                       // 3/ Make sure we can setup some default size value,
                       //    which should be around 4500 entries which is the
                       //    average dictionary size (said JPR)
+
+#define g_malloc malloc
+#define g_free   free
+
 #ifdef __GNUC__
 #include <stdint.h>
 #define guint16 uint16_t
 #define guint32 uint32_t
-#define g_malloc malloc
-#define g_free   free
 #endif
-#ifdef _MSC_VER
-#include <glib.h>
+#ifdef _MSC_VER 
+typedef  unsigned short guint16;
+typedef  unsigned int guint32;
+
 #endif
 
 #ifdef _MSC_VER
@@ -163,14 +167,16 @@ public:
        string  value;     // used to be char * valeurElem
        size_t Offset;     // Offset from the begining of file for direct user access
        ElValue(gdcmDictEntry*);
-       void   SetVR(string);
-       string GetVR(void);
+       void SetDictEntry(gdcmDictEntry *NewEntry) { entry = NewEntry; };
+
        bool   IsVrUnknown(void) { return entry->IsVrUnknown(); };
        void SetLength(guint32 l){LgrElem = l; };
        void SetValue(string val){ value = val; };
        void SetOffset(size_t of){ Offset = of; };
        void SetImplicitVr(void) { ImplicitVr = true; };
        bool  IsImplicitVr(void) { return ImplicitVr; };
+       void    SetVR(string);
+       string  GetVR(void);
        string  GetValue(void)   { return value; };
        guint32 GetLength(void)  { return LgrElem; };
        size_t  GetOffset(void)  { return Offset; };
@@ -184,7 +190,7 @@ typedef map<TagKey, ElValue*> TagElValueHT;
 typedef map<string, ElValue*> TagElValueNameHT;
 // Container for a set of succefully parsed ElValues.
 class GDCM_EXPORT ElValSet {
-       // We need both accesses with a TagKey and the Dicentry.Name
+       // We need both accesses with a TagKey and the Dictentry.Name
        TagElValueHT tagHt;
        TagElValueNameHT NameHt;
 public:
@@ -211,7 +217,7 @@ typedef map<TagKey, VRAtr> VRHT;    // Value Representation Hash Table
 // Notes:
 // * the gdcmHeader::Set*Tag* family members cannot be defined as protected
 //   (Swig limitations for as Has_a dependency between gdcmFile and gdcmHeader)
-class GDCM_EXPORT gdcmHeader { 
+class GDCM_EXPORT gdcmHeader {
 //FIXME sw should be qn EndianType !!!
        //enum EndianType {
                //LittleEndian, 
@@ -219,13 +225,15 @@ class GDCM_EXPORT gdcmHeader {
                //BigEndian, 
                //BadBigEndian};
 private:
-       // All instances share the same value representation dictionary
+       // All instances share the same Value Representation dictionary
        static VRHT *dicom_vr;
+       // Dictionaries of data elements:
        static gdcmDictSet* Dicts;  // Global dictionary container
        gdcmDict* RefPubDict;       // Public Dictionary
        gdcmDict* RefShaDict;       // Shadow Dictionary (optional)
-       ElValSet PubElVals;     // Element Values parsed with Public Dictionary
-       ElValSet ShaElVals;     // Element Values parsed with Shadow Dictionary
+       // Parsed element values:
+       ElValSet PubElVals;         // parsed with Public Dictionary
+       ElValSet ShaElVals;         // parsed with Shadow Dictionary
        // In order to inspect/navigate through the file
        string filename;
        FILE * fp;
@@ -235,7 +243,13 @@ private:
        // outside of the elements:
        guint16 grPixel;
        guint16 numPixel;
+       // Swap code (little, big, big-bad endian): this code is not fixed
+       // during parsing.
        int sw;
+       // Only the elements whose size are below this bound shall be loaded.
+       // By default, this upper bound is limited to 1024 (which looks reasonable
+       // when one considers the definition of the various VR contents).
+       guint32 MaxSizeLoadElementValue;
 
        guint16 ReadInt16(void);
        guint32 ReadInt32(void);
@@ -246,10 +260,15 @@ private:
        void FindLength(ElValue *);
        void FindVR(ElValue *);
        void LoadElementValue(ElValue *);
+       void LoadElementValueSafe(ElValue *);
        void SkipElementValue(ElValue *);
        void InitVRDict(void);
-       bool IsAnInteger(guint16, guint16, string, guint32);
-       ElValue * ReadNextElement(void);
+       void SwitchSwapToBigEndian(void);
+       void FixFoundLength(ElValue*, guint32);
+       bool IsAnInteger(ElValue *);
+       bool IsBigEndianTransferSyntax(void);
+       void SetMaxSizeLoadElementValue(long);
+       ElValue       * ReadNextElement(void);
        gdcmDictEntry * IsInDicts(guint32, guint32);
        size_t GetPixelOffset(void);
 protected: