1 /*=========================================================================
4 Module: $RCSfile: gdcmUtil.h,v $
6 Date: $Date: 2005/02/17 10:56:20 $
7 Version: $Revision: 1.56 $
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 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 static unsigned int GetCurrentThreadID();
54 static unsigned int GetCurrentProcessID();
55 static bool IsCurrentProcessorBigEndian();
57 static std::string DicomString(const char *s, size_t l);
58 static std::string DicomString(const char *s);
59 static bool DicomStringEqual(const std::string &s1, const char *s2);
61 static std::string GetMACAddress();
63 static std::string CreateUniqueUID(const std::string &root = "");
64 static void SetRootUID(const std::string &root = "");
65 static const std::string &GetRootUID();
67 static const uint8_t *GetFileMetaInformationVersion()
68 { return FileMetaInformationVersion;};
69 static void SetFileMetaInformationVersion( uint16_t fmiv)
70 { FileMetaInformationVersion = (uint8_t *)&fmiv; };
73 static std::string GetIPAddress(); //Do not expose this method
75 static std::string RootUID;
76 static const std::string GDCM_UID;
77 static uint8_t *FileMetaInformationVersion;
78 static const uint16_t FMIV;
81 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint16_t &val);
82 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint32_t &val);
83 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const char *val);
84 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, std::string const &val);
85 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint8_t *val, size_t len);
86 GDCM_EXPORT std::ostream &binary_write(std::ostream &os, const uint16_t *val, size_t len);
87 } // end namespace gdcm
88 //-----------------------------------------------------------------------------