Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

gdcmUtil.h

Go to the documentation of this file.
00001 /*=========================================================================
00002                                                                                 
00003   Program:   gdcm
00004   Module:    $RCSfile: gdcmUtil.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/11/29 13:02:47 $
00007   Version:   $Revision: 1.66 $
00008                                                                                 
00009   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
00010   l'Image). All rights reserved. See Doc/License.txt or
00011   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
00012                                                                                 
00013      This software is distributed WITHOUT ANY WARRANTY; without even
00014      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00015      PURPOSE.  See the above copyright notices for more information.
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 // ----------------- to be removed later --------------------------     
00080 //To perform a full check of inline functions on all the platforms, 
00081 // we put here the two 'static' functions
00082 // hifpswap and  hNoifpswap in a .h
00083 // They will be remove ASAP
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 // ------------ end of functions to remove --------------------
00115 private:
00116    static std::string GetIPAddress(); //Do not expose this method
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 } // end namespace gdcm
00133 //-----------------------------------------------------------------------------
00134 #endif

Generated on Fri Jan 20 10:14:26 2006 for gdcm by  doxygen 1.4.4