Program: gdcm
Module: $RCSfile: gdcmUtil.cxx,v $
Language: C++
- Date: $Date: 2004/10/25 04:47:43 $
- Version: $Revision: 1.55 $
+ Date: $Date: 2004/10/28 22:21:57 $
+ Version: $Revision: 1.57 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \brief Add a SEPARATOR to the end of the name is necessary
* @param name file/directory name to normalize
*/
-void Util::NormalizePath(std::string &name)
+std::string Util::NormalizePath(std::string const & pathname)
{
const char SEPARATOR_X = '/';
const char SEPARATOR_WIN = '\\';
const std::string SEPARATOR = "/";
+ std::string name = pathname;
int size = name.size();
if( name[size-1] != SEPARATOR_X && name[size-1] != SEPARATOR_WIN )
{
name += SEPARATOR;
}
+ return name;
}
/**
}
}
+
+template <class T>
+std::ostream& binary_write(std::ostream& os, const T& val)
+{
+ return os.write(reinterpret_cast<const char*>(&val), sizeof val);
+}
+
+std::ostream& binary_write(std::ostream& os, const uint16_t& val)
+{
+#ifdef GDCM_WORDS_BIGENDIAN
+ uint16_t *swap;
+ swap = (((*val>>8)&0xff) | ((*val&0xff)<<8));
+ return os.write(reinterpret_cast<const char*>(swap), 2);
+#else
+ return os.write(reinterpret_cast<const char*>(&val), 2);
+#endif //GDCM_WORDS_BIGENDIAN
+}
+
+std::ostream& binary_write(std::ostream& os, const uint32_t& val)
+{
+#ifdef GDCM_WORDS_BIGENDIAN
+ uint32_t *swap;
+ swap = ( ((val<<24) & 0xff000000) | ((val<<8) & 0x00ff0000) |
+ ((val>>8) & 0x0000ff00) | ((val>>24) & 0x000000ff) );
+ return os.write(reinterpret_cast<const char*>(swap), 4);
+#else
+ return os.write(reinterpret_cast<const char*>(&val), 4);
+#endif //GDCM_WORDS_BIGENDIAN
+}
+
+//template <>
+std::ostream& binary_write(std::ostream& os, const char* val)
+{
+ return os.write(val, strlen(val));
+}
+
+
} // end namespace gdcm