X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmUtil.h;h=9ef1c976134b930cd8cedb05fbc496b12c9d9dfe;hb=c2975ffb8c79fa4d745368d8d1c317c5a313dd0a;hp=dcc1068c516012b043028c48615f04f12eedd63f;hpb=4e6834393e47fa42e6419f8151812fbb02e0e711;p=gdcm.git diff --git a/src/gdcmUtil.h b/src/gdcmUtil.h index dcc1068c..9ef1c976 100644 --- a/src/gdcmUtil.h +++ b/src/gdcmUtil.h @@ -1,79 +1,134 @@ -// gdcmUtil.h -//----------------------------------------------------------------------------- +/*========================================================================= + + Program: gdcm + Module: $RCSfile: gdcmUtil.h,v $ + Language: C++ + Date: $Date: 2005/11/29 13:02:47 $ + Version: $Revision: 1.66 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + #ifndef GDCMUTIL_H #define GDCMUTIL_H #include "gdcmCommon.h" -#include "gdcmVR.h" -#include "gdcmTS.h" -#include "gdcmDictSet.h" -#include "gdcmDicomDirElement.h" -#include #include #include -//----------------------------------------------------------------------------- -/* - * gdcmDebug is an object for debugging in program. - * It has 2 debugging modes : - * - error : for bad library use - * - debug : for debugging messages - * - * A debugging message has a level of priority and is - * Shown only when the debug level is higher than the - * message level. +namespace gdcm +{ +/** + * \brief Here are some utility functions, belonging to the gdcm::Util class, + * dealing with strings, file names... that can be called + * from anywhere by whomsoever they can help. */ -class gdcmDebug { -public: - gdcmDebug(int level = GDCM_DEBUG); - - void SetDebug (int i) {DebugLevel = i;} - - void Verbose(int, const char*, const char* =""); - void Error(bool, const char*, const char* =""); - void Error(const char*, const char* ="", const char* =""); - - void Assert(int, bool, const char*, const char*); - void Exit(int); - -private: - int DebugLevel; -}; //----------------------------------------------------------------------------- -/* - * This class contains all globals elements that might be - * instanciated only one time - */ -class GDCM_EXPORT gdcmGlobal { + +class GDCM_EXPORT Util +{ public: - gdcmGlobal(void); - ~gdcmGlobal(); + static std::string Format(const char *format, ...); + static void Tokenize (const std::string &str, + std::vector &tokens, + const std::string &delimiters = " "); + static int CountSubstring (const std::string &str, + const std::string &subStr); - static gdcmDictSet *GetDicts(void); - static gdcmVR *GetVR(void); - static gdcmTS *GetTS(void); - static gdcmDicomDirElement *GetDicomDirElements(void); + static std::string CreateCleanString(std::string const &s); + static std::string CreateCleanString(uint8_t *s, int l); + static bool IsCleanString(std::string const &s); + static bool IsCleanArea(uint8_t *s, int l); + static std::string NormalizePath(std::string const &name); + static std::string GetPath(std::string const &fullName); + static std::string GetName(std::string const &fullName); + static std::string GetCurrentDate(); + static std::string GetCurrentTime(); + static std::string GetCurrentDateTime(); + /// Provides a simple static GetVersion() function + static std::string GetVersion() + { return GDCM_VERSION;} + static unsigned int GetCurrentThreadID(); + static unsigned int GetCurrentProcessID(); + static bool IsCurrentProcessorBigEndian(); -private: - static gdcmDictSet *Dicts; - static gdcmVR *VR; - static gdcmTS *TS; - static gdcmDicomDirElement *ddElem; -}; + static std::string DicomString(const char *s, size_t l); + static std::string DicomString(const char *s); + static bool DicomStringEqual(const std::string &s1, const char *s2); + static bool CompareDicomString(const std::string &s1, + const char *s2, int op); + static std::string GetMACAddress(); -//----------------------------------------------------------------------------- -std::istream & eatwhite(std::istream & is); + static std::string CreateUniqueUID(const std::string &root = ""); + static void SetRootUID(const std::string &root = ""); + static const std::string &GetRootUID(); -void Tokenize (const std::string& str, - std::vector& tokens, - const std::string& delimiters = " "); + static const uint8_t *GetFileMetaInformationVersion() + { return FileMetaInformationVersion;} + static void SetFileMetaInformationVersion( uint16_t fmiv ) + { FileMetaInformationVersion = (uint8_t *)&fmiv; } -extern gdcmDebug dbg; +// ----------------- to be removed later -------------------------- +//To perform a full check of inline functions on all the platforms, +// we put here the two 'static' functions +// hifpswap and hNoifpswap in a .h +// They will be remove ASAP -char *_cleanString(char *v); -std::string _CreateCleanString(std::string s); + inline void hifpswap(double *a, double *b) + { + double tmp; + tmp = *a; + *a = *b; + *b = tmp; + } + void hNoifpswap(double *a, double *b) + { + double tmp; + tmp = *a; + *a = *b; + *b = tmp; + } + void hfpswap(double *a, double *b); + static inline void sthifpswap(double *a, double *b) + { + double tmp; + tmp = *a; + *a = *b; + *b = tmp; + } + static void sthNoifpswap(double *a, double *b) + { + double tmp; + tmp = *a; + *a = *b; + *b = tmp; + } +// ------------ end of functions to remove -------------------- +private: + static std::string GetIPAddress(); //Do not expose this method + + static std::string RootUID; + static const std::string GDCM_UID; + static uint8_t *FileMetaInformationVersion; + static const uint16_t FMIV; + static std::string GDCM_MAC_ADRESS; +}; +GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint16_t &val); +GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint32_t &val); +GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const double &val); +GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const char *val); +GDCM_EXPORT std::ostream &binary_write(std::ostream &os, std::string const &val); +GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint8_t *val, size_t len); +GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint16_t *val, size_t len); +} // end namespace gdcm //----------------------------------------------------------------------------- #endif -