diff --git a/Stream_support/include/CGAL/IO/OFF.h b/Stream_support/include/CGAL/IO/OFF.h index bfbac4612e3..5013a9bdf71 100644 --- a/Stream_support/include/CGAL/IO/OFF.h +++ b/Stream_support/include/CGAL/IO/OFF.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include diff --git a/Stream_support/include/CGAL/IO/OFF/Scanner_OFF.h b/Stream_support/include/CGAL/IO/OFF/Scanner_OFF.h index a7a9617b850..b6cd67707bb 100644 --- a/Stream_support/include/CGAL/IO/OFF/Scanner_OFF.h +++ b/Stream_support/include/CGAL/IO/OFF/Scanner_OFF.h @@ -59,7 +59,7 @@ public: typedef File_scanner_OFF Scanner; typedef I_Scanner_OFF_vertex_iterator Self; - I_Scanner_OFF_vertex_iterator(std::size_t cnt) : m_scan(0), m_cnt(cnt+1) {} + I_Scanner_OFF_vertex_iterator(std::size_t cnt) : m_scan(nullptr), m_cnt(cnt+1) {} I_Scanner_OFF_vertex_iterator( Scanner& s, int cnt) : m_scan(&s), m_cnt(cnt) { @@ -118,7 +118,7 @@ private: public: I_Scanner_OFF_vertex_and_normals_iterator( int cnt) - : m_scan(0), m_cnt(cnt+1) {} + : m_scan(nullptr), m_cnt(cnt+1) {} I_Scanner_OFF_vertex_and_normals_iterator( Scanner& s, int cnt) : m_scan(&s), m_cnt(cnt) { @@ -184,7 +184,7 @@ public: typedef I_Scanner_OFF_facet_iterator Self; typedef value_type::iterator iterator; - I_Scanner_OFF_facet_iterator( std::size_t cnt) : m_scan(0), m_cnt(cnt+1) {} + I_Scanner_OFF_facet_iterator( std::size_t cnt) : m_scan(nullptr), m_cnt(cnt+1) {} I_Scanner_OFF_facet_iterator( Scanner& s, std::size_t cnt) : m_scan(&s), m_cnt(cnt) { diff --git a/Stream_support/include/CGAL/IO/OFF/generic_copy_OFF.h b/Stream_support/include/CGAL/IO/OFF/generic_copy_OFF.h index ba264567d68..eb19da8b328 100644 --- a/Stream_support/include/CGAL/IO/OFF/generic_copy_OFF.h +++ b/Stream_support/include/CGAL/IO/OFF/generic_copy_OFF.h @@ -52,7 +52,7 @@ generic_copy_OFF(File_scanner_OFF& scanner, writer.write_header(out, scanner.size_of_vertices(), scanner.polyhedral_surface() ? scanner.size_of_halfedges() : 0, - scanner.size_of_facets()); + scanner.size_of_facets()); // read in all vertices double x, y, z; // Point coordinates. diff --git a/Stream_support/include/CGAL/IO/OI/File_writer_inventor.h b/Stream_support/include/CGAL/IO/OI/File_writer_inventor.h index a3fe97d865c..119f0e5b71b 100644 --- a/Stream_support/include/CGAL/IO/OI/File_writer_inventor.h +++ b/Stream_support/include/CGAL/IO/OI/File_writer_inventor.h @@ -25,19 +25,19 @@ namespace CGAL { class File_writer_inventor { - Inventor_ostream_base* m_os; + Inventor_ostream_base m_os; std::size_t m_facets; public: File_writer_inventor() {} - std::ostream& out() const { return m_os->os(); } + std::ostream& out() const { return m_os.os(); } - void write_header(Inventor_ostream_base& o, + void write_header(std::ostream& o, std::size_t vertices, std::size_t halfedges, std::size_t facets) { - m_os = &o; + m_os.open(o); m_facets = facets; out() << "# " << vertices << " vertices\n"; diff --git a/Stream_support/include/CGAL/IO/OI/Inventor_ostream.h b/Stream_support/include/CGAL/IO/OI/Inventor_ostream.h index 975ea1ed542..088458d11a8 100644 --- a/Stream_support/include/CGAL/IO/OI/Inventor_ostream.h +++ b/Stream_support/include/CGAL/IO/OI/Inventor_ostream.h @@ -31,10 +31,10 @@ namespace CGAL { class Inventor_ostream_base { private: - std::ostream* m_os; + std::ostream* m_os = nullptr; public: - Inventor_ostream_base() : m_os(0) {} + Inventor_ostream_base() : m_os(nullptr) {} Inventor_ostream_base(std::ostream& o) : m_os(&o) {} ~Inventor_ostream_base() { close(); } void open(std::ostream& o) { m_os = &o; } @@ -53,13 +53,13 @@ public: return m_os && !m_os->fail(); } - std::ostream& os() + std::ostream& os() const { - // The behaviour if m_os == 0 could be changed to return + // The behaviour if m_os == nullptr could be changed to return // cerr or a file handle to /dev/null. The latter one would // mimick the behaviour that one can still use a stream with // an invalid stream, but without producing any output. - CGAL_assertion( m_os != 0 ); + CGAL_assertion( m_os != nullptr ); return *m_os; } }; diff --git a/Stream_support/include/CGAL/IO/VRML/File_writer_VRML_2.h b/Stream_support/include/CGAL/IO/VRML/File_writer_VRML_2.h index eabebd32eb9..bb637b85888 100644 --- a/Stream_support/include/CGAL/IO/VRML/File_writer_VRML_2.h +++ b/Stream_support/include/CGAL/IO/VRML/File_writer_VRML_2.h @@ -21,26 +21,27 @@ #include -#include #include +#include namespace CGAL { class File_writer_VRML_2 { - VRML_2_ostream* m_os; + VRML_2_ostream m_os; std::size_t m_facets; public: File_writer_VRML_2() {} - std::ostream& out() const { return m_os->os(); } - void write_header(VRML_2_ostream& o, + std::ostream& out() const { return m_os.os(); } + + void write_header(std::ostream& o, std::size_t vertices, std::size_t halfedges, std::size_t facets) { - m_os = &o; + m_os.open(o); m_facets = facets; out() << " #-- Begin of Polygon Mesh\n"; @@ -80,7 +81,7 @@ public: " coordIndex [" << std::endl; } - void write_facet_begin( std::size_t) { out() << " "; } + void write_facet_begin(std::size_t) { out() << " "; } void write_facet_vertex_index( std::size_t idx) { out() << idx << ',';} void write_facet_end() { out() << "-1,\n"; } }; diff --git a/Stream_support/include/CGAL/IO/VRML/VRML_2_ostream.h b/Stream_support/include/CGAL/IO/VRML/VRML_2_ostream.h index d5d3a36a37f..0f38ebebc40 100644 --- a/Stream_support/include/CGAL/IO/VRML/VRML_2_ostream.h +++ b/Stream_support/include/CGAL/IO/VRML/VRML_2_ostream.h @@ -27,7 +27,7 @@ namespace CGAL { class VRML_2_ostream { public: - VRML_2_ostream() : m_os(0) {} + VRML_2_ostream() : m_os(nullptr) {} VRML_2_ostream(std::ostream& o) : m_os(&o) { header(); } ~VRML_2_ostream() { close(); } @@ -44,13 +44,13 @@ public: explicit operator bool () { return m_os && !m_os->fail(); } - std::ostream& os() + std::ostream& os() const { - // The behaviour if m_os == 0 could be changed to return + // The behaviour if m_os == nullptr could be changed to return // cerr or a file handle to /dev/null. The latter one would // mimick the behaviour that one can still use a stream with // an invalid stream, but without producing any output. - CGAL_assertion( m_os != 0 ); + CGAL_assertion( m_os != nullptr ); return *m_os; }