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
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 private:
00116 static std::string GetIPAddress();
00117
00118 static std::string RootUID;
00119 static const std::string GDCM_UID;
00120 static uint8_t *FileMetaInformationVersion;
00121 static const uint16_t FMIV;
00122 static std::string GDCM_MAC_ADRESS;
00123 };
00124
00125 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint16_t &val);
00126 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint32_t &val);
00127 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const double &val);
00128 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const char *val);
00129 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, std::string const &val);
00130 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint8_t *val, size_t len);
00131 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint16_t *val, size_t len);
00132 }
00133
00134 #endif