]> Creatis software - gdcm.git/blob - src/gdcmCommon.h
ENH: Adding support for BCB6, big thanks to Luca Picello for patch
[gdcm.git] / src / gdcmCommon.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmCommon.h,v $
5   Language:  C++
6   Date:      $Date: 2005/07/02 15:54:18 $
7   Version:   $Revision: 1.67 $
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.html 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 #ifndef GDCMCOMMON_H
20 #define GDCMCOMMON_H
21
22 #include "gdcmConfigure.h"
23
24 //-----------------------------------------------------------------------------
25 //This is needed when compiling in debug mode
26 #ifdef _MSC_VER
27 // 'identifier' : class 'type' needs to have dll-interface to be used by
28 // clients of class 'type2'
29 #pragma warning ( disable : 4251 )
30 // non dll-interface class 'type' used as base for dll-interface class 'type2'
31 #pragma warning ( disable : 4275 )
32 // 'identifier' : identifier was truncated to 'number' characters in the
33 // debug information
34 #pragma warning ( disable : 4786 )
35 //'identifier' : decorated name length exceeded, name was truncated
36 #pragma warning ( disable : 4503 )
37 // C++ exception specification ignored except to indicate a 
38 // function is not __declspec(nothrow)
39 #pragma warning ( disable : 4290 )
40 // signed/unsigned mismatch
41 #pragma warning ( disable : 4018 )
42 // return type for 'identifier' is '' (ie; not a UDT or reference to UDT. Will
43 // produce errors if applied using infix notation
44 #pragma warning ( disable : 4284 )
45 // 'type' : forcing value to bool 'true' or 'false' (performance warning)
46 // //#pragma warning ( disable : 4800 )
47 #endif //_MSC_VER
48
49 //-----------------------------------------------------------------------------
50 #ifdef CMAKE_HAVE_STDINT_H
51    #include <stdint.h>
52 #else
53 #ifdef CMAKE_HAVE_INTTYPES_H
54    // Old system only have this
55    #include <inttypes.h>   // For uint8_t uint16_t and uint32_t
56 #endif
57 #endif
58
59 // Broken plateform do not respect C99 and do not provide those typedef
60 // Special case for recent borland compiler, comes with stdint.h
61 #if defined(_MSC_VER) || __BORLANDC__ < 0x0560  || defined(__MINGW32__)
62 typedef  signed char         int8_t;
63 typedef  signed short        int16_t;
64 typedef  signed int          int32_t;
65 typedef  unsigned char       uint8_t;
66 typedef  unsigned short      uint16_t;
67 typedef  unsigned int        uint32_t;
68 #define UINT32_MAX    (4294967295U)
69 #endif
70
71 #if defined(_WIN32) && defined(BUILD_SHARED_LIBS)
72   #ifdef gdcm_EXPORTS
73     #define GDCM_EXPORT __declspec( dllexport )
74   #else
75     #define GDCM_EXPORT __declspec( dllimport )
76   #endif
77 #else
78   #define GDCM_EXPORT
79 #endif
80
81 #include <string>
82
83 /// \brief namespace for Grass root DiCoM
84 namespace gdcm
85 {
86
87 // Centralize information about the gdcm dictionary in only one file:
88 #ifndef PUB_DICT_PATH
89 #  define PUB_DICT_PATH   "../Dicts/"
90 #endif
91 #define PUB_DICT_NAME     "DicomV3Dict"
92 #define PUB_DICT_FILENAME "gdcm.dic"
93 #define DICT_ELEM         "DicomDir.dic"
94 #define DICT_TS           "dicomTS.dic"
95 #define DICT_VR           "dicomVR.dic"
96 #define DICT_GROUP_NAME   "DictGroupName.dic"
97
98 GDCM_EXPORT extern const std::string GDCM_UNKNOWN;
99 GDCM_EXPORT extern const std::string GDCM_UNFOUND;
100 GDCM_EXPORT extern const std::string GDCM_BINLOADED;
101 GDCM_EXPORT extern const std::string GDCM_NOTLOADED;
102 GDCM_EXPORT extern const std::string GDCM_UNREAD;
103
104 /// \brief TagKey is made to hold an "universal" (as in URL, Universal
105 ///        Ressource Locator) key to a DocEntry i.e. a dicom tag.
106 ///        A dicom tag always has a group and an elem, but a set of tags
107 ///        embeded in various (optionally nested) sequences and sharing
108 ///        the same group and elem all share the same (group, elem)
109 ///        "identifier". Hence the (group, elem) cannot be used as an
110 ///        identifier (in gdcm we shall refer to a "TagKey") of a tag.
111 ///        In order to construct a proper tag identifier (i.e. a key) we
112 ///        consider the following definition of a TagKey:
113 ///        - let Group, Element be the string representation of the
114 ///          group and elem dicom tag members,
115 ///        - let ItemNumber be the string representation of the integer
116 ///          index of the considered item number of a sequence,
117 ///        Let the key of a tag embeded in a sequence, noted SeqTag, be
118 ///        the form:
119 ///           /ItemNumber#Group|Element
120 ///        where "/", "#" and "|" are characters acting as separators.
121 ///        Then the general form of a TagKey is given by:
122 ///           Group|Element[SeqTag]
123 ///        where [SeqTag] means NO or many instances of SeqTag.
124 ///        Hence the TagKey of a tag not "leaving" in a sequence is the
125 ///        string e.g. 
126 ///            0028|1201
127 ///        but the TagKey of a tag "embeded" is the first item of
128 ///        a sequence, itself nested in the third item of a sequence is the
129 ///        string e.g.
130 ///            0004|1220/2#0008|0082/0#0008|0090
131 typedef std::string TagKey;
132 typedef std::string TagName;
133
134 enum FileType {
135    Unknown = 0,
136    ExplicitVR, // DicomDir is in this case. Except when it's ImplicitVR !...
137    ImplicitVR,
138    ACR,
139    ACR_LIBIDO
140 };
141
142 /// \brief type of the elements composing a DICOMDIR (for internal use only)
143 enum DicomDirType {
144    DD_UNKNOWN = 0,
145    DD_META,
146    DD_PATIENT,
147    DD_STUDY,
148    DD_SERIE,
149    DD_IMAGE
150 };
151
152 /**
153  * \brief structure, for internal use only
154  */  
155 struct Element
156 {
157    /// DicomGroup number
158    unsigned short int Group;
159    /// DicomElement number
160    unsigned short int Elem;
161    /// value (coded as a std::string) of the Element
162    std::string Value;
163 };
164
165 } //namespace gdcm
166 //-----------------------------------------------------------------------------
167 #endif