diff --git a/Stream_support/include/CGAL/IO/io.h b/Stream_support/include/CGAL/IO/io.h index 7b4de07476e..96f8641ed64 100644 --- a/Stream_support/include/CGAL/IO/io.h +++ b/Stream_support/include/CGAL/IO/io.h @@ -298,21 +298,156 @@ Benchmark_rep bmformat( const T& t) { return Benchmark_rep(t); } template Benchmark_rep bmformat( const T& t, F) { return Benchmark_rep(t); } -CGAL_EXPORT IO::Mode get_mode(std::ios& i); +/*! +\ingroup PkgStreamSupportRef -CGAL_EXPORT IO::Mode set_ascii_mode(std::ios& i); +returns the printing mode of the %IO stream `s`. -CGAL_EXPORT IO::Mode set_binary_mode(std::ios& i); +\sa `CGAL::IO::Mode` +\sa `CGAL::set_mode()` +\sa `CGAL::set_ascii_mode()` +\sa `CGAL::set_binary_mode()` +\sa `CGAL::set_pretty_mode()` +\sa `CGAL::is_ascii()` +\sa `CGAL::is_binary()` +\sa `CGAL::is_pretty()` +*/ +IO::Mode get_mode(std::ios& i) { return static_cast(i.iword(IO::Static::get_mode())); } -CGAL_EXPORT IO::Mode set_pretty_mode(std::ios& i); +/*! +\ingroup PkgStreamSupportRef -CGAL_EXPORT IO::Mode set_mode(std::ios& i, IO::Mode m); +sets the mode of the %IO stream `s` to be the `IO::ASCII` mode. +Returns the previous mode of `s`. -CGAL_EXPORT bool is_pretty(std::ios& i); +\sa `CGAL::IO::Mode` +\sa `CGAL::set_mode()` +\sa `CGAL::set_binary_mode()` +\sa `CGAL::set_pretty_mode()` +\sa `CGAL::get_mode()` +\sa `CGAL::is_ascii()` +\sa `CGAL::is_binary()` +\sa `CGAL::is_pretty()` +*/ +IO::Mode set_ascii_mode(std::ios& i) +{ + IO::Mode m = get_mode(i); + i.iword(IO::Static::get_mode()) = IO::ASCII; + return m; +} -CGAL_EXPORT bool is_ascii(std::ios& i); +/*! +\ingroup PkgStreamSupportRef -CGAL_EXPORT bool is_binary(std::ios& i); +sets the mode of the %IO stream `s` to be the `IO::BINARY` mode. +Returns the previous mode of `s`. + +\sa `CGAL::IO::Mode` +\sa `CGAL::set_mode()` +\sa `CGAL::set_ascii_mode()` +\sa `CGAL::set_pretty_mode()` +\sa `CGAL::get_mode()` +\sa `CGAL::is_ascii()` +\sa `CGAL::is_binary()` +\sa `CGAL::is_pretty()` +*/ +IO::Mode set_binary_mode(std::ios& i) +{ + IO::Mode m = get_mode(i); + i.iword(IO::Static::get_mode()) = IO::BINARY; + return m; +} + +/*! +\ingroup PkgStreamSupportRef + +sets the mode of the %IO stream `s` to be the `IO::PRETTY` mode. +Returns the previous mode of `s`. + +\sa `CGAL::IO::Mode` +\sa `CGAL::set_mode()` +\sa `CGAL::set_ascii_mode()` +\sa `CGAL::set_binary_mode()` +\sa `CGAL::get_mode()` +\sa `CGAL::is_ascii()` +\sa `CGAL::is_binary()` +\sa `CGAL::is_pretty()` +*/ +IO::Mode set_pretty_mode(std::ios& i) +{ + IO::Mode m = get_mode(i); + i.iword(IO::Static::get_mode()) = IO::PRETTY; + return m; +} + +/*! +\ingroup PkgStreamSupportRef + +sets the printing mode of the %IO stream `s`. + +\sa `CGAL::IO::Mode` +\sa `CGAL::set_ascii_mode()` +\sa `CGAL::set_binary_mode()` +\sa `CGAL::set_pretty_mode()` +\sa `CGAL::get_mode()` +\sa `CGAL::is_ascii()` +\sa `CGAL::is_binary()` +\sa `CGAL::is_pretty()` +*/ +IO::Mode set_mode(std::ios& i, IO::Mode m) +{ + IO::Mode old = get_mode(i); + i.iword(IO::Static::get_mode()) = m; + return old; +} + +/*! +\ingroup PkgStreamSupportRef + +checks if the %IO stream `s` is in `IO::PRETTY` mode. + +\sa `CGAL::IO::Mode` +\sa `CGAL::set_mode()` +\sa `CGAL::set_ascii_mode()` +\sa `CGAL::set_binary_mode()` +\sa `CGAL::set_pretty_mode()` +\sa `CGAL::get_mode()` +\sa `CGAL::is_ascii()` +\sa `CGAL::is_binary()` +*/ +bool is_pretty(std::ios& i) { return i.iword(IO::Static::get_mode()) == IO::PRETTY; } + +/*! +\ingroup PkgStreamSupportRef + +checks if the %IO stream `s` is in `IO::ASCII` mode. + +\sa `CGAL::IO::Mode` +\sa `CGAL::set_mode()` +\sa `CGAL::set_ascii_mode()` +\sa `CGAL::set_binary_mode()` +\sa `CGAL::set_pretty_mode()` +\sa `CGAL::get_mode()` +\sa `CGAL::is_binary()` +\sa `CGAL::is_pretty()` +*/ +bool is_ascii(std::ios& i) { return i.iword(IO::Static::get_mode()) == IO::BINARY; } + +/*! +\ingroup PkgStreamSupportRef + +checks if the %IO stream `s` is in `IO::BINARY` mode. + +\sa `CGAL::IO::Mode` +\sa `CGAL::set_mode()` +\sa `CGAL::set_ascii_mode()` +\sa `CGAL::set_binary_mode()` +\sa `CGAL::set_pretty_mode()` +\sa `CGAL::get_mode()` +\sa `CGAL::is_ascii()` +\sa `CGAL::is_pretty()` +*/ +bool is_binary(std::ios& i) { return i.iword(IO::Static::get_mode()) == IO::BINARY; } template < class T > inline void write(std::ostream& os, const T& t, const io_Read_write&) @@ -412,12 +547,37 @@ inline std::istream &operator>>(std::istream &is, Color& col) return is; } -CGAL_EXPORT const char* mode_name( IO::Mode m ); +const char* mode_name( IO::Mode m ) +{ + static const char* const names[] = {"ASCII", "PRETTY", "BINARY" }; + CGAL_assertion( IO::ASCII <= m && m <= IO::BINARY ); + return names[m]; +} // From polynomial.h TODO: Where to put this? -CGAL_EXPORT void swallow(std::istream &is, char d); +void swallow(std::istream &is, char d) +{ + char c; + do { is.get(c); } while(isspace(c)); + if(c != d) + { + std::stringstream msg; + msg << "input error: expected '" << d << "' but got '" << c << "'"; + CGAL_error_msg( msg.str().c_str() ); + } +} -CGAL_EXPORT void swallow(std::istream &is, const std::string& s ); +void swallow(std::istream &is, const std::string& s) +{ + std::string t; + is >> t; + if(s != t) + { + std::stringstream msg; + msg << "input error: expected '" << s << "' but got '" << t << "'"; + CGAL_error_msg( msg.str().c_str() ); + } +} namespace internal { @@ -427,7 +587,7 @@ inline void eat_white_space(std::istream &is) do { c = is.peek(); - if(c== std::istream::traits_type::eof()) + if(c == std::istream::traits_type::eof()) { return; } @@ -465,7 +625,7 @@ inline bool is_digit(const std::istream& /*is*/, std::istream::int_type c) { CGAL_assertion(c != std::istream::traits_type::eof()); return std::isdigit(static_cast(c), - std::locale::classic() ); + std::locale::classic()); } inline std::istream::int_type peek(std::istream& is) @@ -515,7 +675,7 @@ inline void read_float_or_quotient(std::istream& is, Rat &z) is.get(); negative = (c == '-'); internal::eat_white_space(is); - c=internal::peek(is); + c = internal::peek(is); } // read n (could be empty) @@ -552,7 +712,7 @@ inline void read_float_or_quotient(std::istream& is, Rat &z) is >> d; is.flags(old_flags); if(!is.fail()) - z = negative? compose(-n,d): compose(n,d); + z = negative? compose(-n,d) : compose(n,d); return; } @@ -603,10 +763,6 @@ inline void read_float_or_quotient(std::istream& is, Rat &z) } // namespace CGAL -#ifdef CGAL_HEADER_ONLY -#include -#endif // CGAL_HEADER_ONLY - #include #endif // CGAL_IO_H diff --git a/Stream_support/include/CGAL/IO/io_impl.h b/Stream_support/include/CGAL/IO/io_impl.h deleted file mode 100644 index 60a8e427af1..00000000000 --- a/Stream_support/include/CGAL/IO/io_impl.h +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) 1997 -// Utrecht University (The Netherlands), -// ETH Zurich (Switzerland), -// INRIA Sophia-Antipolis (France), -// Max-Planck-Institute Saarbruecken (Germany), -// and Tel-Aviv University (Israel). All rights reserved. -// -// This file is part of CGAL (www.cgal.org) -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial -// -// -// Author(s) : Andreas Fabri - -#ifdef CGAL_HEADER_ONLY -#define CGAL_INLINE_FUNCTION inline -#else -#define CGAL_INLINE_FUNCTION -#endif - -#include - -#include -#include - -namespace CGAL { - -CGAL_INLINE_FUNCTION -IO::Mode -get_mode(std::ios& i) -{ - return static_cast(i.iword(IO::Static::get_mode())); -} - -CGAL_INLINE_FUNCTION -IO::Mode -set_ascii_mode(std::ios& i) -{ - IO::Mode m = get_mode(i); - i.iword(IO::Static::get_mode()) = IO::ASCII; - return m; -} - -CGAL_INLINE_FUNCTION -IO::Mode -set_binary_mode(std::ios& i) -{ - IO::Mode m = get_mode(i); - i.iword(IO::Static::get_mode()) = IO::BINARY; - return m; -} - - -CGAL_INLINE_FUNCTION -IO::Mode -set_pretty_mode(std::ios& i) -{ - IO::Mode m = get_mode(i); - i.iword(IO::Static::get_mode()) = IO::PRETTY; - return m; -} - -CGAL_INLINE_FUNCTION -IO::Mode -set_mode(std::ios& i, IO::Mode m) -{ - IO::Mode old = get_mode(i); - i.iword(IO::Static::get_mode()) = m; - return old; -} - -CGAL_INLINE_FUNCTION -bool -is_pretty(std::ios& i) -{ - return i.iword(IO::Static::get_mode()) == IO::PRETTY; -} - -CGAL_INLINE_FUNCTION -bool -is_ascii(std::ios& i) -{ - return i.iword(IO::Static::get_mode()) == IO::ASCII; -} - -CGAL_INLINE_FUNCTION -bool -is_binary(std::ios& i) -{ - return i.iword(IO::Static::get_mode()) == IO::BINARY; -} - -CGAL_INLINE_FUNCTION -const char* -mode_name( IO::Mode m) { - static const char* const names[] = {"ASCII", "PRETTY", "BINARY" }; - CGAL_assertion( IO::ASCII <= m && m <= IO::BINARY ); - return names[m]; -} - -CGAL_INLINE_FUNCTION -void -swallow(std::istream &is, char d) { - char c; - do is.get(c); while (isspace(c)); - if (c != d) { - std::stringstream msg; - msg << "input error: expected '" << d << "' but got '" << c << "'"; - CGAL_error_msg( msg.str().c_str() ); - } -} - -CGAL_INLINE_FUNCTION -void -swallow(std::istream &is, const std::string& s ) { - std::string t; - is >> t; - if (s != t) { - std::stringstream msg; - msg << "input error: expected '" << s << "' but got '" << t << "'"; - CGAL_error_msg( msg.str().c_str() ); - } -} - -} //namespace CGAL diff --git a/Stream_support/src/CGAL/io.cpp b/Stream_support/src/CGAL/io.cpp deleted file mode 100644 index 6cdf861abc4..00000000000 --- a/Stream_support/src/CGAL/io.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 1997 -// Utrecht University (The Netherlands), -// ETH Zurich (Switzerland), -// INRIA Sophia-Antipolis (France), -// Max-Planck-Institute Saarbruecken (Germany), -// and Tel-Aviv University (Israel). All rights reserved. -// -// This file is part of CGAL (www.cgal.org) -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial -// -// -// Author(s) : Andreas Fabri - -#ifndef CGAL_HEADER_ONLY - -#include -#include - -#endif