mirror of https://github.com/CGAL/cgal
Get rid of io_impl.h
This commit is contained in:
parent
0e82e7f9ee
commit
75581cad76
|
|
@ -298,21 +298,156 @@ Benchmark_rep<T> bmformat( const T& t) { return Benchmark_rep<T>(t); }
|
|||
template <class T, class F>
|
||||
Benchmark_rep<T,F> bmformat( const T& t, F) { return Benchmark_rep<T,F>(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<IO::Mode>(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 {
|
||||
|
||||
|
|
@ -603,10 +763,6 @@ inline void read_float_or_quotient(std::istream& is, Rat &z)
|
|||
|
||||
} // namespace CGAL
|
||||
|
||||
#ifdef CGAL_HEADER_ONLY
|
||||
#include <CGAL/IO/io_impl.h>
|
||||
#endif // CGAL_HEADER_ONLY
|
||||
|
||||
#include <CGAL/enable_warnings.h>
|
||||
|
||||
#endif // CGAL_IO_H
|
||||
|
|
|
|||
|
|
@ -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 <CGAL/assertions.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
CGAL_INLINE_FUNCTION
|
||||
IO::Mode
|
||||
get_mode(std::ios& i)
|
||||
{
|
||||
return static_cast<IO::Mode>(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
|
||||
|
|
@ -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 <CGAL/IO/io.h>
|
||||
#include <CGAL/IO/io_impl.h>
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue