1 /*=========================================================================
4 Module: $RCSfile: gdcmUtil.h,v $
6 Date: $Date: 2005/08/22 16:17:54 $
7 Version: $Revision: 1.61 $
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.
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.
17 =========================================================================*/
22 #include "gdcmCommon.h"
29 * \brief Here are some utility functions, belonging to the gdcm::Util class,
30 * dealing with strings, file names... that can be called
31 * from anywhere by whomsoever they can help.
34 //-----------------------------------------------------------------------------
36 class GDCM_EXPORT Util
39 static std::string Format(const char *format, ...);
40 static void Tokenize (const std::string &str,
41 std::vector<std::string> &tokens,
42 const std::string &delimiters = " ");
43 static int CountSubstring (const std::string &str,
44 const std::string &subStr);
46 static std::string CreateCleanString(std::string const &s);
47 static std::string NormalizePath(std::string const &name);
48 static std::string GetPath(std::string const &fullName);
49 static std::string GetName(std::string const &fullName);
50 static std::string GetCurrentDate();
51 static std::string GetCurrentTime();
52 static std::string GetCurrentDateTime();
53 /// Provides a simple static GetVersion() function
54 static std::string GetVersion()
55 { return GDCM_VERSION;}
56 static unsigned int GetCurrentThreadID();
57 static unsigned int GetCurrentProcessID();
58 static bool IsCurrentProcessorBigEndian();
60 static std::string DicomString(const char *s, size_t l);
61 static std::string DicomString(const char *s);
62 static bool DicomStringEqual(const std::string &s1, const char *s2);
63 static bool CompareDicomString(const std::string &s1,
64 const char *s2, int op);
65 static std::string GetMACAddress();
67 static std::string CreateUniqueUID(const std::string &root = "");
68 static void SetRootUID(const std::string &root = "");
69 static const std::string &GetRootUID();
71 static const uint8_t *GetFileMetaInformationVersion()
72 { return FileMetaInformationVersion;}
73 static void SetFileMetaInformationVersion( uint16_t fmiv )
74 { FileMetaInformationVersion = (uint8_t *)&fmiv; }
77 static std::string GetIPAddress(); //Do not expose this method
79 static std::string RootUID;
80 static const std::string GDCM_UID;
81 static uint8_t *FileMetaInformationVersion;
82 static const uint16_t FMIV;
83 static std::string GDCM_MAC_ADRESS;
86 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint16_t &val);
87 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint32_t &val);
88 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const char *val);
89 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, std::string const &val);
90 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint8_t *val, size_t len);
91 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint16_t *val, size_t len);
92 } // end namespace gdcm
93 //-----------------------------------------------------------------------------