CGAL 5.1.1 - IO Streams
IO Streams Reference

io.png
Andreas Fabri, Geert-Jan Giezeman, and Lutz Kettner
All classes in the CGAL kernel provide input and output operators for IO streams. The basic task of such an operator is to produce a representation of an object that can be written as a sequence of characters on devices as a console, a file, or a pipe. In CGAL we distinguish between a raw ascii, a raw binary and a pretty printing format.
Introduced in: CGAL 1.0
BibTeX: cgal:fgk-ios-12-20b
License: LGPL

All classes in the CGAL kernel provide input and output operators for IO streams. CGAL provides three different printing mode, defined in the enum IO::Mode, as well as different functions to set and get the printing mode.

Classified Reference Pages

Enum

Functions

WKT I/O Functions

Classes

Modules

 Stream Operators
 

Classes

class  CGAL::Input_rep< T, F >
 The definition of Input_rep is completely symmetric to Output_rep. More...
 
class  CGAL::Output_rep< T, F >
 The purpose of Output_rep is to provide a way to control output formatting that works independently of the object's stream output operator. More...
 
class  CGAL::Istream_iterator< T, Stream >
 The class Istream_iterator is an input iterator adaptor for the input stream class Stream and value type T. More...
 
class  CGAL::Ostream_iterator< T, Stream >
 The class Ostream_iterator is an output iterator adaptor for the output stream class Stream and value type T. More...
 
class  CGAL::Verbose_ostream
 The class Verbose_ostream can be used as an output stream. More...
 
class  CGAL::Color
 An object of the class Color is a color available for drawing operations in many CGAL output streams. More...
 

Enumerations

enum  CGAL::IO::Mode
 All classes in the CGAL Kernel provide input and output operators for IOStreams. More...
 

Functions

IO::Mode CGAL::get_mode (std::ios &s)
 returns the printing mode of the IO stream s. More...
 
IO::Mode CGAL::set_ascii_mode (std::ios &s)
 sets the mode of the IO stream s to be the IO::ASCII mode. More...
 
IO::Mode CGAL::set_binary_mode (std::ios &s)
 
IO::Mode CGAL::set_mode (std::ios &s, IO::Mode m)
 sets the printing mode of the IO stream s. More...
 
IO::Mode CGAL::set_pretty_mode (std::ios &s)
 sets the mode of the IO stream s to be the IO::PRETTY mode. More...
 
bool CGAL::is_ascii (std::ios &s)
 checks if the IO stream s is in IO::ASCII mode. More...
 
bool CGAL::is_binary (std::ios &s)
 checks if the IO stream s is in IO::BINARY mode. More...
 
bool CGAL::is_pretty (std::ios &s)
 checks if the IO stream s is in IO::PRETTY mode. More...
 
template<class T >
Output_rep< T > CGAL::oformat (const T &t)
 Convenience function to construct an output representation (Output_rep) for type T. More...
 
template<class T >
Input_rep< T > CGAL::iformat (const T &t)
 The definition of this function is completely symmetric to oformat().
 
template<class T , typename F >
Output_rep< T, F > CGAL::oformat (const T &t, F)
 Convenience function to construct an output representation (Output_rep) for type T. More...
 
template<typename Point >
std::istream & CGAL::read_point_WKT (std::istream &in, Point &point)
 read_point_WKT() fills a Point from a WKT stream. More...
 
template<typename MultiPoint >
std::istream & CGAL::read_multi_point_WKT (std::istream &in, MultiPoint &mp)
 read_multi_point_WKT() overwrites the content of a MultiPoint with the first line starting with MULTIPOINT in the stream. More...
 
template<typename LineString >
std::istream & CGAL::read_linestring_WKT (std::istream &in, LineString &polyline)
 read_linestring_WKT() fills a Linestring from a WKT stream. More...
 
template<typename MultiLineString >
std::istream & CGAL::read_multi_linestring_WKT (std::istream &in, MultiLineString &mls)
 read_multi_linestring_WKT() overwrites the content of a MultiLineString with the first line starting with MULTILINESTRING in the stream. More...
 
template<typename Polygon >
std::istream & CGAL::read_polygon_WKT (std::istream &in, Polygon &polygon)
 read_polygon_WKT() fills polygon from a WKT stream. More...
 
template<typename MultiPolygon >
std::istream & CGAL::read_multi_polygon_WKT (std::istream &in, MultiPolygon &polygons)
 read_multi_polygon_WKT() overwrites the content of a MultiPolygon with the first line starting with MULTIPOLYGON in the stream. More...
 
template<typename Point >
std::ostream & CGAL::write_point_WKT (std::ostream &out, const Point &point)
 write_point_WKT() writes point into a WKT stream. More...
 
template<typename Polygon >
std::ostream & CGAL::write_polygon_WKT (std::ostream &out, const Polygon &poly)
 write_polygon_WKT() writes poly into a WKT stream. More...
 
template<typename LineString >
std::ostream & CGAL::write_linestring_WKT (std::ostream &out, LineString ls)
 write_linestring_WKT() writes the content of ls into a WKT stream. More...
 
template<typename MultiPoint >
std::ostream & CGAL::write_multi_point_WKT (std::ostream &out, MultiPoint &mp)
 write_multi_point_WKT() writes the content of mp into a WKT stream. More...
 
template<typename MultiPolygon >
std::ostream & CGAL::write_multi_polygon_WKT (std::ostream &out, MultiPolygon &polygons)
 write_multi_polygon_WKT() writes the content of polygons into a WKT stream. More...
 
template<typename MultiLineString >
std::ostream & CGAL::write_multi_linestring_WKT (std::ostream &out, MultiLineString &mls)
 write_multi_linestring_WKT() writes the content of mls into a WKT stream. More...
 
template<typename MultiPoint , typename MultiLineString , typename MultiPolygon >
std::istream & CGAL::read_WKT (std::istream &input, MultiPoint &points, MultiLineString &polylines, MultiPolygon &polygons)
 reads the content of a WKT stream and fills points, polylines and polygons with all the POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON and MULTIPOLYGON it finds in input. More...
 

Enumeration Type Documentation

◆ Mode

#include <CGAL/IO/io.h>

All classes in the CGAL Kernel provide input and output operators for IOStreams.

The basic task of such an operator is to produce a representation of an object that can be written as a sequence of characters on devices as a console, a file, or a pipe. The enum Mode distinguish between three different printing formats.

In ASCII mode, numbers e.g. the coordinates of a point or the coefficients of a line, are written in a machine independent format. In BINARY mode, data are written in a binary format, e.g. a double is represented as a sequence of four byte. The format depends on the machine. The mode PRETTY serves mainly for debugging as the type of the geometric object is written, as well as the data defining the object. For example for a point at the origin with Cartesian double coordinates, the output would be PointC2(0.0, 0.0). At the moment CGAL does not provide input operations for pretty printed data. By default a stream is in Ascii mode.

See also
CGAL::set_mode()
CGAL::set_ascii_mode()
CGAL::set_binary_mode()
CGAL::set_pretty_mode()
CGAL::get_mode()
CGAL::is_ascii()
CGAL::is_binary()
CGAL::is_pretty()

Function Documentation

◆ get_mode()

IO::Mode CGAL::get_mode ( std::ios &  s)

#include <CGAL/IO/io.h>

returns the printing mode of the IO stream s.

See also
CGAL::IO::Mode
CGAL::set_mode()
CGAL::set_ascii_mode()
CGAL::set_binary_mode()
CGAL::set_pretty_mode()
CGAL::is_ascii()
CGAL::is_binary()
CGAL::is_pretty()

◆ is_ascii()

bool CGAL::is_ascii ( std::ios &  s)

#include <CGAL/IO/io.h>

checks if the IO stream s is in IO::ASCII mode.

See also
CGAL::IO::Mode
CGAL::set_mode()
CGAL::set_ascii_mode()
CGAL::set_binary_mode()
CGAL::set_pretty_mode()
CGAL::get_mode()
CGAL::is_binary()
CGAL::is_pretty()

◆ is_binary()

bool CGAL::is_binary ( std::ios &  s)

#include <CGAL/IO/io.h>

checks if the IO stream s is in IO::BINARY mode.

See also
CGAL::IO::Mode
CGAL::set_mode()
CGAL::set_ascii_mode()
CGAL::set_binary_mode()
CGAL::set_pretty_mode()
CGAL::get_mode()
CGAL::is_ascii()
CGAL::is_pretty()

◆ is_pretty()

bool CGAL::is_pretty ( std::ios &  s)

#include <CGAL/IO/io.h>

checks if the IO stream s is in IO::PRETTY mode.

See also
CGAL::IO::Mode
CGAL::set_mode()
CGAL::set_ascii_mode()
CGAL::set_binary_mode()
CGAL::set_pretty_mode()
CGAL::get_mode()
CGAL::is_ascii()
CGAL::is_binary()

◆ oformat() [1/2]

template<class T >
Output_rep<T> CGAL::oformat ( const T &  t)

#include <CGAL/IO/io.h>

Convenience function to construct an output representation (Output_rep) for type T.

Generic IO for type T.

◆ oformat() [2/2]

template<class T , typename F >
Output_rep<T,F> CGAL::oformat ( const T &  t,
 
)

#include <CGAL/IO/io.h>

Convenience function to construct an output representation (Output_rep) for type T.

Generic IO for type T with formatting tag.

◆ read_linestring_WKT()

template<typename LineString >
std::istream& CGAL::read_linestring_WKT ( std::istream &  in,
LineString &  polyline 
)

#include <CGAL/IO/WKT.h>

read_linestring_WKT() fills a Linestring from a WKT stream.

The first line starting with LINESTRING in the stream will be used.

Template Parameters
Linestringmust be a model of RandomAccessRange of CGAL::Point_2, and have:
  • a function push_back() that takes a CGAL::Point_2.
  • a function clear(),
  • a function resize() that takes an size_type
  • an operator[]() that takes a size_type.
Attention
Only Cartesian Kernels with double or float as FT are supported.
This function is only available with boost versions starting at 1.56.
See also
CGAL::Point_2
Examples:
Stream_support/Linestring_WKT.cpp.

◆ read_multi_linestring_WKT()

template<typename MultiLineString >
std::istream& CGAL::read_multi_linestring_WKT ( std::istream &  in,
MultiLineString &  mls 
)

#include <CGAL/IO/WKT.h>

read_multi_linestring_WKT() overwrites the content of a MultiLineString with the first line starting with MULTILINESTRING in the stream.

Template Parameters
MultiLineStringmust be a model of RandomAccessRange of Linestring, and have:
  • a function push_back() that takes a Linestring,
  • a function clear(),
  • a function resize() that takes an size_type
  • an operator[]() that takes a size_type.
Attention
Only Cartesian Kernels with double or float as FT are supported.
This function is only available with boost versions starting at 1.56.
See also
CGAL::Point_2
Examples:
Stream_support/Linestring_WKT.cpp.

◆ read_multi_point_WKT()

template<typename MultiPoint >
std::istream& CGAL::read_multi_point_WKT ( std::istream &  in,
MultiPoint &  mp 
)

#include <CGAL/IO/WKT.h>

read_multi_point_WKT() overwrites the content of a MultiPoint with the first line starting with MULTIPOINT in the stream.

Template Parameters
MultiPointmust be a model of RandomAccessRange of CGAL::Point_2 or CGAL::Point_3, and have:
  • a function push_back() that takes the same point type,
  • a function clear(),
  • a function resize() that takes an size_type
  • an operator[]() that takes a size_type.
Attention
Only Cartesian Kernels with double or float as FT are supported.
This function is only available with boost versions starting at 1.56.
See also
CGAL::Point_2
CGAL::Point_3
Examples:
Stream_support/Point_WKT.cpp.

◆ read_multi_polygon_WKT()

template<typename MultiPolygon >
std::istream& CGAL::read_multi_polygon_WKT ( std::istream &  in,
MultiPolygon &  polygons 
)

#include <CGAL/IO/WKT.h>

read_multi_polygon_WKT() overwrites the content of a MultiPolygon with the first line starting with MULTIPOLYGON in the stream.

Template Parameters
MultiPolygonmust be a model of RandomAccessRange of CGAL::General_polygon_with_holes_2, and have:
  • a function push_back() that takes a CGAL::General_polygon_with_holes_2,
  • a function clear(),
  • a function resize() that takes an size_type
  • an operator[]() that takes a size_type.
Attention
Only Cartesian Kernels with double or float as FT are supported.
This function is only available with boost versions starting at 1.56.
See also
CGAL::General_polygon_with_holes_2
Examples:
Stream_support/Polygon_WKT.cpp.

◆ read_point_WKT()

template<typename Point >
std::istream& CGAL::read_point_WKT ( std::istream &  in,
Point &  point 
)

#include <CGAL/IO/WKT.h>

read_point_WKT() fills a Point from a WKT stream.

The first line starting with POINT in the stream will be used.

Template Parameters
Pointcan be a CGAL::Point_2 or CGAL::Point_3.
Attention
Only Cartesian Kernels with double or float as FT are supported.
This function is only available with boost versions starting at 1.56.
See also
CGAL::Point_2
CGAL::Point_3

◆ read_polygon_WKT()

template<typename Polygon >
std::istream& CGAL::read_polygon_WKT ( std::istream &  in,
Polygon &  polygon 
)

#include <CGAL/IO/WKT.h>

read_polygon_WKT() fills polygon from a WKT stream.

The first line starting with POLYGON in the stream will be used.

Template Parameters
Polygonis a CGAL::General_polygon_with_holes_2.
Attention
Only Cartesian Kernels with double or float as FT are supported.
This function is only available with boost versions starting at 1.56.
See also
CGAL::General_polygon_with_holes_2
Examples:
Stream_support/Polygon_WKT.cpp.

◆ read_WKT()

template<typename MultiPoint , typename MultiLineString , typename MultiPolygon >
std::istream& CGAL::read_WKT ( std::istream &  input,
MultiPoint &  points,
MultiLineString &  polylines,
MultiPolygon &  polygons 
)

#include <CGAL/IO/WKT.h>

reads the content of a WKT stream and fills points, polylines and polygons with all the POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON and MULTIPOLYGON it finds in input.

Template Parameters
MultiPointmust be a model of RandomAccessRange of CGAL::Point_2 or CGAL::Point_3.
MultiLineStringmust be a RandomAccessRange of Linestring.
MultiPolygonmust be a model of RandomAccessRange of CGAL::General_polygon_with_holes_2.
Attention
Only Cartesian Kernels with double or float as FT are supported.
This function is only available with boost versions starting at 1.56.
See also
CGAL::read_linestring_WKT()

◆ set_ascii_mode()

IO::Mode CGAL::set_ascii_mode ( std::ios &  s)

#include <CGAL/IO/io.h>

sets the mode of the IO stream s to be the IO::ASCII mode.

Returns the previous mode of s.

See also
CGAL::IO::Mode
CGAL::set_mode()
CGAL::set_binary_mode()
CGAL::set_pretty_mode()
CGAL::get_mode()
CGAL::is_ascii()
CGAL::is_binary()
CGAL::is_pretty()

◆ set_binary_mode()

IO::Mode CGAL::set_binary_mode ( std::ios &  s)

#include <CGAL/IO/io.h>

See also
CGAL::IO::Mode
CGAL::set_mode()
CGAL::set_ascii_mode()
CGAL::set_pretty_mode()
CGAL::get_mode()
CGAL::is_ascii()
CGAL::is_binary()
CGAL::is_pretty()

sets the mode of the IO stream s to be the IO::BINARY mode. Returns the previous mode of s.

◆ set_mode()

IO::Mode CGAL::set_mode ( std::ios &  s,
IO::Mode  m 
)

#include <CGAL/IO/io.h>

sets the printing mode of the IO stream s.

See also
CGAL::IO::Mode
CGAL::set_ascii_mode()
CGAL::set_binary_mode()
CGAL::set_pretty_mode()
CGAL::get_mode()
CGAL::is_ascii()
CGAL::is_binary()
CGAL::is_pretty()

◆ set_pretty_mode()

IO::Mode CGAL::set_pretty_mode ( std::ios &  s)

#include <CGAL/IO/io.h>

sets the mode of the IO stream s to be the IO::PRETTY mode.

Returns the previous mode of s.

See also
CGAL::IO::Mode
CGAL::set_mode()
CGAL::set_ascii_mode()
CGAL::set_binary_mode()
CGAL::get_mode()
CGAL::is_ascii()
CGAL::is_binary()
CGAL::is_pretty()

◆ write_linestring_WKT()

template<typename LineString >
std::ostream& CGAL::write_linestring_WKT ( std::ostream &  out,
LineString  ls 
)

#include <CGAL/IO/WKT.h>

write_linestring_WKT() writes the content of ls into a WKT stream.

Template Parameters
LineStringmust be a RandomAccessRange of CGAL::Point_2.
Attention
Only Cartesian Kernels with double or float as FT are supported.
This function is only available with boost versions starting at 1.56.
See also
CGAL::Point_2

◆ write_multi_linestring_WKT()

template<typename MultiLineString >
std::ostream& CGAL::write_multi_linestring_WKT ( std::ostream &  out,
MultiLineString &  mls 
)

#include <CGAL/IO/WKT.h>

write_multi_linestring_WKT() writes the content of mls into a WKT stream.

Template Parameters
MultiLineStringmust be a RandomAccessRange of LineString.
Attention
Only Cartesian Kernels with double or float as FT are supported.
This function is only available with boost versions starting at 1.56.
See also
CGAL::write_linestring_WKT()

◆ write_multi_point_WKT()

template<typename MultiPoint >
std::ostream& CGAL::write_multi_point_WKT ( std::ostream &  out,
MultiPoint &  mp 
)

#include <CGAL/IO/WKT.h>

write_multi_point_WKT() writes the content of mp into a WKT stream.

Template Parameters
MultiPointmust be a RandomAccessRange of CGAL::Point_2.
Attention
Only Cartesian Kernels with double or float as FT are supported.
This function is only available with boost versions starting at 1.56.
See also
CGAL::Point_2

◆ write_multi_polygon_WKT()

template<typename MultiPolygon >
std::ostream& CGAL::write_multi_polygon_WKT ( std::ostream &  out,
MultiPolygon &  polygons 
)

#include <CGAL/IO/WKT.h>

write_multi_polygon_WKT() writes the content of polygons into a WKT stream.

Template Parameters
MultiPolygonmust be a RandomAccessRange of CGAL::General_polygon_with_holes_2.
Attention
Only Cartesian Kernels with double or float as FT are supported.
This function is only available with boost versions starting at 1.56.
See also
CGAL::General_polygon_with_holes_2

◆ write_point_WKT()

template<typename Point >
std::ostream& CGAL::write_point_WKT ( std::ostream &  out,
const Point &  point 
)

#include <CGAL/IO/WKT.h>

write_point_WKT() writes point into a WKT stream.

Template Parameters
Pointis a CGAL::Point_2
Attention
Only Cartesian Kernels with double or float as FT are supported.
This function is only available with boost versions starting at 1.56.
See also
CGAL::Point_2

◆ write_polygon_WKT()

template<typename Polygon >
std::ostream& CGAL::write_polygon_WKT ( std::ostream &  out,
const Polygon &  poly 
)

#include <CGAL/IO/WKT.h>

write_polygon_WKT() writes poly into a WKT stream.

Template Parameters
Polygonmust be a CGAL::General_polygon_with_holes_2
Attention
Only Cartesian Kernels with double or float as FT are supported.
This function is only available with boost versions starting at 1.56.
See also
CGAL::General_polygon_with_holes_2