00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _GDCMUTIL_H_
00020 #define _GDCMUTIL_H_
00021
00022 #include "gdcmCommon.h"
00023 #include <vector>
00024 #include <string>
00025
00026 namespace GDCM_NAME_SPACE
00027 {
00034
00035
00036 class GDCM_EXPORT Util
00037 {
00038 public:
00039 static std::string Format(const char *format, ...);
00040 static void Tokenize (const std::string &str,
00041 std::vector<std::string> &tokens,
00042 const std::string &delimiters = " ");
00043 static int CountSubstring (const std::string &str,
00044 const std::string &subStr);
00045
00046 static std::string CreateCleanString(std::string const &s);
00047 static std::string CreateCleanString(uint8_t *s, int l);
00048 static bool IsCleanString(std::string const &s);
00049 static bool IsCleanArea(uint8_t *s, int l);
00050 static std::string NormalizePath(std::string const &name);
00051 static std::string GetPath(std::string const &fullName);
00052 static std::string GetName(std::string const &fullName);
00053 static std::string GetCurrentDate();
00054 static std::string GetCurrentTime();
00055 static std::string GetCurrentDateTime();
00057 static std::string GetVersion()
00058 { return GDCM_VERSION;}
00059 static unsigned int GetCurrentThreadID();
00060 static unsigned int GetCurrentProcessID();
00061 static bool IsCurrentProcessorBigEndian();
00062
00063 static std::string DicomString(const char *s, size_t l);
00064 static std::string DicomString(const char *s);
00065 static bool DicomStringEqual(const std::string &s1, const char *s2);
00066 static bool CompareDicomString(const std::string &s1,
00067 const char *s2, int op);
00068 static std::string GetMACAddress();
00069
00070 static std::string CreateUniqueUID(const std::string &root = "");
00071 static void SetRootUID(const std::string &root = "");
00072 static const std::string &GetRootUID();
00073
00074 static const uint8_t *GetFileMetaInformationVersion()
00075 { return FileMetaInformationVersion;}
00076 static void SetFileMetaInformationVersion( uint16_t fmiv )
00077 { FileMetaInformationVersion = (uint8_t *)&fmiv; }
00078
00079
00080
00081
00082
00083
00084
00085 inline void hifpswap(double *a, double *b)
00086 {
00087 double tmp;
00088 tmp = *a;
00089 *a = *b;
00090 *b = tmp;
00091 }
00092 void hNoifpswap(double *a, double *b)
00093 {
00094 double tmp;
00095 tmp = *a;
00096 *a = *b;
00097 *b = tmp;
00098 }
00099 void hfpswap(double *a, double *b);
00100 static inline void sthifpswap(double *a, double *b)
00101 {
00102 double tmp;
00103 tmp = *a;
00104 *a = *b;
00105 *b = tmp;
00106 }
00107 static void sthNoifpswap(double *a, double *b)
00108 {
00109 double tmp;
00110 tmp = *a;
00111 *a = *b;
00112 *b = tmp;
00113 }
00114
00115
00116
00117 static std::string ConvertToMD5 (std::string &stringToCrypt);
00118
00119 private:
00120 static std::string GetIPAddress();
00121
00122 static std::string RootUID;
00123 static const std::string GDCM_UID;
00124 static uint8_t *FileMetaInformationVersion;
00125 static const uint16_t FMIV;
00126 static std::string GDCM_MAC_ADRESS;
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186 typedef struct md5_state_s {
00187 uint32_t count[2];
00188 uint32_t abcd[4];
00189 uint8_t buf[64];
00190 } md5_state_t;
00191
00192 static void md5_process(md5_state_t *pms, const uint8_t *data );
00193
00194 static void md5_init(md5_state_t *pms);
00195
00196 static void md5_append(md5_state_t *pms, const uint8_t *data, int nbytes);
00197
00198 static void md5_finish(md5_state_t *pms, uint8_t digest[16]);
00199
00200 };
00201
00202 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint16_t &val);
00203 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint32_t &val);
00204 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const double &val);
00205 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const char *val);
00206 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, std::string const &val);
00207 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint8_t *val, size_t len);
00208 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint16_t *val, size_t len);
00209
00210 }
00211
00212 #endif