Program: gdcm
Module: $RCSfile: gdcmUtil.cxx,v $
Language: C++
- Date: $Date: 2005/10/27 17:04:36 $
- Version: $Revision: 1.170 $
+ Date: $Date: 2005/11/28 15:20:34 $
+ Version: $Revision: 1.177 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmUtil.h"
#include "gdcmDebug.h"
+
#include <iostream>
+#include <stdarg.h> // for va_list
// For GetCurrentDate, GetCurrentTime
#include <time.h>
/**
* \brief Provide a better 'c++' approach for sprintf
* For example c code is:
- * char result[200]; // hope 200 is enough
+ * char result[2048]; // hope 2048 is enough
* sprintf(result, "%04x|%04x", group , elem);
*
* c++ code is
*/
std::string Util::Format(const char *format, ...)
{
- char buffer[2048];
+ char buffer[2048]; // hope 2048 is enough
va_list args;
va_start(args, format);
vsprintf(buffer, format, args); //might be a security flaw
*/
bool Util::IsCleanString(std::string const &s)
{
- std::cout<< std::endl << s << std::endl;
+ //std::cout<< std::endl << s << std::endl;
for(unsigned int i=0; i<s.size(); i++)
{
- //std::cout<< std::endl << i << " : " << (unsigned char)s[i] << std::endl;
if (!isprint((unsigned char)s[i]) )
{
return false;
std::string Util::DicomString(const char *s, size_t l)
{
std::string r(s, s+l);
- gdcmAssertMacro( !(r.size() % 2) ); // == basically 'l' is even
+ gdcmStaticAssertMacro( !(r.size() % 2) ); // == basically 'l' is even
return r;
}
l++;
}
std::string r(s, s+l);
- gdcmAssertMacro( !(r.size() % 2) );
+ gdcmStaticAssertMacro( !(r.size() % 2) );
return r;
}
case GDCM_LESSOREQUAL :
return s1_even <= s2_even;
default :
- gdcmDebugMacro(" Wrong operator : " << op);
+ gdcmStaticDebugMacro(" Wrong operator : " << op);
return false;
}
}
close(sd);
#endif
// Not implemented platforms (or no cable !)
- perror("in Get MAC Adress (internal) : There was a configuration problem on your plateform");
+ perror("in Get MAC Adress (internal) : There was a configuration problem (or no cable !) on your plateform");
memset(addr,0,6);
return -1;
#endif //__sun
}
/**
- * \brief Encode the mac address on a fixed lenght string of 15 characters.
+ * \brief Encode the mac address on a fixed length string of 15 characters.
* we save space this way.
*/
std::string Util::GetMACAddress()
}
else
{
- gdcmWarningMacro("Problem in finding the MAC Address");
+ gdcmStaticWarningMacro("Problem in finding the MAC Address");
return "";
}
}
/**
- * \brief Creates a new UID. As stipulate in the DICOM ref
- * each time a DICOM image is create it should have
+ * \brief Creates a new UID. As stipulated in the DICOM ref
+ * each time a DICOM image is created it should have
* a unique identifier (URI)
* @param root is the DICOM prefix assigned by IOS group
*/
// If append is too long we need to rehash it
if ( (prefix + append).size() > 64 )
{
- gdcmErrorMacro( "Size of UID is too long." );
+ gdcmStaticErrorMacro( "Size of UID is too long." );
// we need a hash function to truncate this number
// if only md5 was cross plateform
// MD5(append);
std::ostream &binary_write(std::ostream &os, const double &val)
{
#if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
- double swap;
+ double swap = val;
char *beg = (char *)&swap;
char *end = beg + 7;
*/
std::ostream &binary_write(std::ostream &os, const uint8_t *val, size_t len)
{
-std::cout << "binary_write " << len << std::endl;
// We are writting sizeof(char) thus no need to swap bytes
return os.write(reinterpret_cast<const char*>(val), len);
}