mirror of https://github.com/CGAL/cgal
105 lines
2.7 KiB
C++
105 lines
2.7 KiB
C++
// ============================================================================
|
|
//
|
|
// Copyright (c) 1997 The CGAL Consortium
|
|
//
|
|
// This software and related documentation is part of an INTERNAL release
|
|
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
|
// intended for general use.
|
|
//
|
|
// ----------------------------------------------------------------------------
|
|
//
|
|
// release : $CGAL_Revision: $
|
|
// release_date : $CGAL_Date: $
|
|
//
|
|
// file : binary_file_io.h
|
|
// chapter : $CGAL_Chapter: Support Library ... $
|
|
// package : $CGAL_Package: Polyhedron_IO 2.11 (04 Feb 2000) $
|
|
// source : polyhedron_io.fw
|
|
// revision : $Revision$
|
|
// revision_date : $Date$
|
|
// author(s) : Lutz Kettner <kettner@inf.ethz.ch>
|
|
//
|
|
// coordinator : Herve Bronnimann <Herve.Bronnimann@sophia.inria.fr>
|
|
//
|
|
// Binary read and write on streams for Integer32 and float
|
|
// ============================================================================
|
|
|
|
#ifndef CGAL_IO_BINARY_FILE_IO_H
|
|
#define CGAL_IO_BINARY_FILE_IO_H 1
|
|
#ifndef CGAL_BASIC_H
|
|
#include <CGAL/basic.h>
|
|
#endif
|
|
#ifndef CGAL_KNOWN_BIT_SIZE_INTEGERS_H
|
|
#include <CGAL/known_bit_size_integers.h>
|
|
#endif
|
|
#ifndef CGAL_PROTECT_IOSTREAM
|
|
#include <iostream>
|
|
#define CGAL_PROTECT_IOSTREAM
|
|
#endif
|
|
|
|
CGAL_BEGIN_NAMESPACE
|
|
|
|
inline void
|
|
I_Binary_write_integer32(std::ostream& out, Integer32 i) {
|
|
out.write( (char*)(&i), 4);
|
|
}
|
|
inline void
|
|
I_Binary_write_float32(std::ostream& out, float f) {
|
|
out.write( (char*)(&f), 4);
|
|
}
|
|
|
|
inline void
|
|
I_Binary_read_integer32(std::istream& in, Integer32& i) {
|
|
in.read( (char*)(&i), 4);
|
|
}
|
|
inline void
|
|
I_Binary_read_float32(std::istream& in, float& f) {
|
|
in.read( (char*)(&f), 4);
|
|
}
|
|
|
|
inline void
|
|
I_swap_to_big_endian( UInteger32& u) {
|
|
(void)u;
|
|
#ifdef CGAL_LITTLE_ENDIAN
|
|
u = ((u >> 24) | (u << 24) | ((u >> 8) & 0xff00) | ((u << 8) & 0xff0000));
|
|
#endif
|
|
}
|
|
|
|
inline void
|
|
I_swap_to_big_endian( Integer32& i) {
|
|
UInteger32& u = (UInteger32&)i;
|
|
I_swap_to_big_endian( u);
|
|
}
|
|
|
|
inline void
|
|
I_swap_to_big_endian( float& f) {
|
|
UInteger32& u = (UInteger32&)f;
|
|
I_swap_to_big_endian( u);
|
|
}
|
|
|
|
inline void
|
|
I_Binary_write_big_endian_integer32(std::ostream& out, Integer32 i) {
|
|
I_swap_to_big_endian( i);
|
|
out.write( (char*)(&i), 4);
|
|
}
|
|
inline void
|
|
I_Binary_write_big_endian_float32(std::ostream& out, float f) {
|
|
I_swap_to_big_endian( f);
|
|
out.write( (char*)(&f), 4);
|
|
}
|
|
|
|
inline void
|
|
I_Binary_read_big_endian_integer32(std::istream& in, Integer32& i) {
|
|
in.read( (char*)(&i), 4);
|
|
I_swap_to_big_endian( i);
|
|
}
|
|
inline void
|
|
I_Binary_read_big_endian_float32(std::istream& in, float& f) {
|
|
in.read( (char*)(&f), 4);
|
|
I_swap_to_big_endian( f);
|
|
}
|
|
|
|
CGAL_END_NAMESPACE
|
|
#endif // CGAL_IO_BINARY_FILE_IO_H //
|
|
// EOF //
|