2005-04-27 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Files related to io should be re-written so they are temporary
commented.
* oln/io/gz_stream.hh: Comment contents.
* oln/io/write_image_2d_pnm.hh: Likewise.
* oln/io/write_image.hh: Likewise.
* oln/io/read_image_2d_pnm.hh: Likewise.
* oln/io/read_image.hh: Likewise.
* oln/io/utils.hh: Likewise.
* tests/io/loadsave.hh: Update.
Index: tests/io/loadsave.hh
===================================================================
--- tests/io/loadsave.hh (revision 166)
+++ tests/io/loadsave.hh (working copy)
@@ -40,10 +40,11 @@
im1 = oln::io::read(name);
- oln::io::write(im1, savename);
+// oln::io::write(im1, savename);
- im2 = oln::io::read(savename);
+// im2 = oln::io::read(savename);
+ im2 = oln::io::read(name);
if (compare(im1, im2) == true)
std::cout << "OK" << std::endl;
Index: oln/io/gz_stream.hh
===================================================================
--- oln/io/gz_stream.hh (revision 166)
+++ oln/io/gz_stream.hh (working copy)
@@ -28,455 +28,455 @@
#ifndef OLN_IO_GZ_STREAM_HH
# define OLN_IO_GZ_STREAM_HH
-# include <oln/config/system.hh>
+// # include <oln/config/system.hh>
-#if defined HAVE_ZLIB && HAVE_ZLIB == 1
-# include <cassert>
-# include <fstream>
-# include <string>
-# include <zlib.h>
+// #if defined HAVE_ZLIB && HAVE_ZLIB == 1
+// # include <cassert>
+// # include <fstream>
+// # include <string>
+// # include <zlib.h>
-namespace oln {
+// namespace oln {
- namespace io {
+// namespace io {
- /// Functions for gz files
- namespace gz {
+// /// Functions for gz files
+// namespace gz {
- ///Performs operation on compressed files.
- class zfilebuf : public std::streambuf
- {
- public:
+// ///Performs operation on compressed files.
+// class zfilebuf : public std::streambuf
+// {
+// public:
- zfilebuf() : file(0), mode(0), own_file_descriptor(0)
- {
- inbuf = new char[lenbuf];
- outbuf = new char[lenbuf];
- setg(0, 0, 0);
- setp(outbuf, outbuf + lenbuf);
- }
+// zfilebuf() : file(0), mode(0), own_file_descriptor(0)
+// {
+// inbuf = new char[lenbuf];
+// outbuf = new char[lenbuf];
+// setg(0, 0, 0);
+// setp(outbuf, outbuf + lenbuf);
+// }
- virtual ~zfilebuf()
- {
- sync();
- delete[] inbuf;
- delete[] outbuf;
- if (own_file_descriptor)
- close();
- }
+// virtual ~zfilebuf()
+// {
+// sync();
+// delete[] inbuf;
+// delete[] outbuf;
+// if (own_file_descriptor)
+// close();
+// }
- /*! \brief Return a stream on the file \a name regarding
- ** the opening mode: \a io_mode.
- */
- zfilebuf*
- open(const char *name, int io_mode)
- {
- if (is_open())
- return 0;
+// /*! \brief Return a stream on the file \a name regarding
+// ** the opening mode: \a io_mode.
+// */
+// zfilebuf*
+// open(const char *name, int io_mode)
+// {
+// if (is_open())
+// return 0;
- char char_mode[10];
- char *p;
- memset(char_mode,'\0',10);
- p = char_mode;
+// char char_mode[10];
+// char *p;
+// memset(char_mode,'\0',10);
+// p = char_mode;
- if (io_mode & std::ios::in)
- {
- mode = std::ios::in;
- *p++ = 'r';
- }
- else
- if (io_mode & std::ios::app)
- {
- mode = std::ios::app;
- *p++ = 'a';
- }
- else
- {
- mode = std::ios::out;
- *p++ = 'w';
- }
- if (io_mode & std::ios::binary)
- {
- mode |= std::ios::binary;
- *p++ = 'b';
- }
+// if (io_mode & std::ios::in)
+// {
+// mode = std::ios::in;
+// *p++ = 'r';
+// }
+// else
+// if (io_mode & std::ios::app)
+// {
+// mode = std::ios::app;
+// *p++ = 'a';
+// }
+// else
+// {
+// mode = std::ios::out;
+// *p++ = 'w';
+// }
+// if (io_mode & std::ios::binary)
+// {
+// mode |= std::ios::binary;
+// *p++ = 'b';
+// }
- // Hard code the compression level
- if (io_mode & (std::ios::out|std::ios::app))
- *p++ = '9';
+// // Hard code the compression level
+// if (io_mode & (std::ios::out|std::ios::app))
+// *p++ = '9';
- if ((file = gzopen(name, char_mode)) == 0)
- return 0;
+// if ((file = gzopen(name, char_mode)) == 0)
+// return 0;
- name_ = name;
- own_file_descriptor = 1;
- return this;
- }
+// name_ = name;
+// own_file_descriptor = 1;
+// return this;
+// }
- /*! \brief Attach a stream on \a file_descriptor regarding
- ** the opening mode: \a io_mode.
- */
- zfilebuf*
- attach(int file_descriptor, int io_mode)
- {
- if (is_open())
- return 0;
+// /*! \brief Attach a stream on \a file_descriptor regarding
+// ** the opening mode: \a io_mode.
+// */
+// zfilebuf*
+// attach(int file_descriptor, int io_mode)
+// {
+// if (is_open())
+// return 0;
- char char_mode[10];
- char *p;
- memset(char_mode,'\0',10);
- p = char_mode;
+// char char_mode[10];
+// char *p;
+// memset(char_mode,'\0',10);
+// p = char_mode;
- if (io_mode & std::ios::in)
- {
- mode = std::ios::in;
- *p++ = 'r';
- }
- else
- if (io_mode & std::ios::app)
- {
- mode = std::ios::app;
- *p++ = 'a';
- }
- else
- {
- mode = std::ios::out;
- *p++ = 'w';
- }
+// if (io_mode & std::ios::in)
+// {
+// mode = std::ios::in;
+// *p++ = 'r';
+// }
+// else
+// if (io_mode & std::ios::app)
+// {
+// mode = std::ios::app;
+// *p++ = 'a';
+// }
+// else
+// {
+// mode = std::ios::out;
+// *p++ = 'w';
+// }
- if (io_mode & std::ios::binary)
- {
- mode |= std::ios::binary;
- *p++ = 'b';
- }
+// if (io_mode & std::ios::binary)
+// {
+// mode |= std::ios::binary;
+// *p++ = 'b';
+// }
- // Hard code the compression level
- if (io_mode & (std::ios::out|std::ios::app))
- *p++ = '9';
+// // Hard code the compression level
+// if (io_mode & (std::ios::out|std::ios::app))
+// *p++ = '9';
- if ((file = gzdopen(file_descriptor, char_mode)) == 0)
- return 0;
+// if ((file = gzdopen(file_descriptor, char_mode)) == 0)
+// return 0;
- own_file_descriptor = 0;
- return this;
- }
+// own_file_descriptor = 0;
+// return this;
+// }
- /// Close the stream.
- zfilebuf*
- close()
- {
- if (is_open())
- {
- sync();
- gzclose(file);
- file = 0;
- }
- return this;
- }
+// /// Close the stream.
+// zfilebuf*
+// close()
+// {
+// if (is_open())
+// {
+// sync();
+// gzclose(file);
+// file = 0;
+// }
+// return this;
+// }
- int
- setcompressionlevel(short comp_level)
- {
- return gzsetparams(file, comp_level, -2);
- }
+// int
+// setcompressionlevel(short comp_level)
+// {
+// return gzsetparams(file, comp_level, -2);
+// }
- int
- setcompressionstrategy(short comp_strategy)
- {
- return gzsetparams(file, -2, comp_strategy);
- }
+// int
+// setcompressionstrategy(short comp_strategy)
+// {
+// return gzsetparams(file, -2, comp_strategy);
+// }
- /// Return true if the stream is open, false otherwise.
- inline int
- is_open() const
- { return (file != 0); }
+// /// Return true if the stream is open, false otherwise.
+// inline int
+// is_open() const
+// { return (file != 0); }
- virtual std::streampos
- seekoff(std::streamoff off, std::ios::seekdir dir, int) // which)
- {
- return std::streampos(gzseek(file, off, dir));
- }
+// virtual std::streampos
+// seekoff(std::streamoff off, std::ios::seekdir dir, int) // which)
+// {
+// return std::streampos(gzseek(file, off, dir));
+// }
- /// Flush the buffer associated to the stream.
- virtual int
- sync()
- {
- if (!is_open())
- return EOF;
- return flushbuf();
- }
+// /// Flush the buffer associated to the stream.
+// virtual int
+// sync()
+// {
+// if (!is_open())
+// return EOF;
+// return flushbuf();
+// }
- protected:
+// protected:
- /*! \brief Return the next character in the stream.
- ** On failure, \a EOF is returned.
- */
- virtual int
- underflow()
- {
- // If the file hasn't been opened for reading, error.
- if (!is_open() || !(mode & std::ios::in))
- return EOF;
+// /*! \brief Return the next character in the stream.
+// ** On failure, \a EOF is returned.
+// */
+// virtual int
+// underflow()
+// {
+// // If the file hasn't been opened for reading, error.
+// if (!is_open() || !(mode & std::ios::in))
+// return EOF;
- if (in_avail())
- return (unsigned char) *gptr();
+// if (in_avail())
+// return (unsigned char) *gptr();
- if (flushbuf() == EOF)
- return EOF;
+// if (flushbuf() == EOF)
+// return EOF;
- // Attempt to fill the buffer.
- if (fillbuf() == EOF)
- return EOF;
+// // Attempt to fill the buffer.
+// if (fillbuf() == EOF)
+// return EOF;
- assert (eback());
+// assert (eback());
- return (unsigned char) *gptr();
- }
+// return (unsigned char) *gptr();
+// }
- /*! \brief Flush the output buffer associated to the stream
- ** then write \a c. On failure, \a EOF is returned.
- */
+// /*! \brief Flush the output buffer associated to the stream
+// ** then write \a c. On failure, \a EOF is returned.
+// */
- virtual int
- overflow(int c = EOF)
- {
- if (!is_open() || !(mode & std::ios::out))
- return EOF;
+// virtual int
+// overflow(int c = EOF)
+// {
+// if (!is_open() || !(mode & std::ios::out))
+// return EOF;
- assert (pbase());
+// assert (pbase());
- if (flushbuf() == EOF)
- return EOF;
+// if (flushbuf() == EOF)
+// return EOF;
- if (c != EOF)
- {
- *pptr() = c;
- pbump(1);
- }
- return 0;
- }
+// if (c != EOF)
+// {
+// *pptr() = c;
+// pbump(1);
+// }
+// return 0;
+// }
- private:
+// private:
- gzFile file;
- short mode;
- short own_file_descriptor;
- std::string name_;
- char *inbuf;
- char *outbuf;
- static const int lenbuf = 16 * 1024;
+// gzFile file;
+// short mode;
+// short own_file_descriptor;
+// std::string name_;
+// char *inbuf;
+// char *outbuf;
+// static const int lenbuf = 16 * 1024;
- /// Flush the output buffer
- int
- flushbuf()
- {
- int n = pptr() - outbuf;
+// /// Flush the output buffer
+// int
+// flushbuf()
+// {
+// int n = pptr() - outbuf;
- if (n == 0)
- return 0;
+// if (n == 0)
+// return 0;
- if (gzwrite(file, outbuf, n) < n)
- return EOF;
+// if (gzwrite(file, outbuf, n) < n)
+// return EOF;
- setp(outbuf, outbuf + lenbuf);
- return 0;
- }
- /// Fill the input buffer.
- int
- fillbuf()
- {
- int t = gzread(file, inbuf, lenbuf);
- if (t <= 0) return EOF;
- setg(inbuf, inbuf, inbuf + t);
- return t;
- }
+// setp(outbuf, outbuf + lenbuf);
+// return 0;
+// }
+// /// Fill the input buffer.
+// int
+// fillbuf()
+// {
+// int t = gzread(file, inbuf, lenbuf);
+// if (t <= 0) return EOF;
+// setg(inbuf, inbuf, inbuf + t);
+// return t;
+// }
- };
+// };
- ///Define an interface for compressed file stream manipulation.
- class zfilestream_common : virtual public std::ios
- {
- friend class zifstream;
- friend class zofstream;
- friend zofstream &setcompressionlevel(zofstream &, int);
- friend zofstream &setcompressionstrategy(zofstream &, int);
+// ///Define an interface for compressed file stream manipulation.
+// class zfilestream_common : virtual public std::ios
+// {
+// friend class zifstream;
+// friend class zofstream;
+// friend zofstream &setcompressionlevel(zofstream &, int);
+// friend zofstream &setcompressionstrategy(zofstream &, int);
- public:
- virtual ~zfilestream_common() {}
+// public:
+// virtual ~zfilestream_common() {}
- /*! \brief Open the stream on the file descriptor:
- ** \a fd regarding the opening mode.
- */
- void
- attach(int fd, int io_mode)
- {
- if (!buffer.attach(fd, io_mode))
- clear(std::ios::failbit | std::ios::badbit);
- else
- clear();
- }
+// /*! \brief Open the stream on the file descriptor:
+// ** \a fd regarding the opening mode.
+// */
+// void
+// attach(int fd, int io_mode)
+// {
+// if (!buffer.attach(fd, io_mode))
+// clear(std::ios::failbit | std::ios::badbit);
+// else
+// clear();
+// }
- /*! \brief Open the stream on the file named \a name
- ** regarding the opening mode.
- */
- void
- open(const char *name, int io_mode)
- {
- if (!buffer.open(name, io_mode))
- clear(std::ios::failbit | std::ios::badbit);
- else
- clear();
- }
+// /*! \brief Open the stream on the file named \a name
+// ** regarding the opening mode.
+// */
+// void
+// open(const char *name, int io_mode)
+// {
+// if (!buffer.open(name, io_mode))
+// clear(std::ios::failbit | std::ios::badbit);
+// else
+// clear();
+// }
- /// Close the current stream.
- void
- close()
- {
- if (!buffer.close())
- clear(std::ios::failbit | std::ios::badbit);
- }
+// /// Close the current stream.
+// void
+// close()
+// {
+// if (!buffer.close())
+// clear(std::ios::failbit | std::ios::badbit);
+// }
- bool
- is_open()
- {
- return buffer.is_open();
- }
+// bool
+// is_open()
+// {
+// return buffer.is_open();
+// }
- protected:
- /// Prevent instantiation.
- zfilestream_common() : std::ios(zfilestream_common::rdbuf())
- { }
+// protected:
+// /// Prevent instantiation.
+// zfilestream_common() : std::ios(zfilestream_common::rdbuf())
+// { }
- private:
- zfilebuf*
- rdbuf()
- {
- return &buffer;
- }
+// private:
+// zfilebuf*
+// rdbuf()
+// {
+// return &buffer;
+// }
- zfilebuf buffer;
- };
+// zfilebuf buffer;
+// };
- /// Read only zstream.
- class zifstream : public zfilestream_common, public std::istream
- {
- public:
+// /// Read only zstream.
+// class zifstream : public zfilestream_common, public std::istream
+// {
+// public:
- zifstream() : std::istream(zfilestream_common::rdbuf())
- {
- clear(std::ios::badbit);
- }
+// zifstream() : std::istream(zfilestream_common::rdbuf())
+// {
+// clear(std::ios::badbit);
+// }
- /// Open a read only stream on the file named \a name.
- zifstream(const char *name, int io_mode = std::ios::in) :
- std::istream(zfilestream_common::rdbuf())
- {
- zfilestream_common::open(name, io_mode);
- }
+// /// Open a read only stream on the file named \a name.
+// zifstream(const char *name, int io_mode = std::ios::in) :
+// std::istream(zfilestream_common::rdbuf())
+// {
+// zfilestream_common::open(name, io_mode);
+// }
- /// Open a read only stream on the file descriptor \a fd.
- zifstream(int fd, int io_mode = std::ios::in) :
- std::istream(zfilestream_common::rdbuf())
- {
- zfilestream_common::attach(fd, io_mode);
- }
+// /// Open a read only stream on the file descriptor \a fd.
+// zifstream(int fd, int io_mode = std::ios::in) :
+// std::istream(zfilestream_common::rdbuf())
+// {
+// zfilestream_common::attach(fd, io_mode);
+// }
- virtual ~zifstream() {}
- };
+// virtual ~zifstream() {}
+// };
- class zofstream : public zfilestream_common, public std::ostream {
+// class zofstream : public zfilestream_common, public std::ostream {
- public:
+// public:
- zofstream() : std::ostream(zfilestream_common::rdbuf())
- {
- clear(std::ios::badbit);
- }
+// zofstream() : std::ostream(zfilestream_common::rdbuf())
+// {
+// clear(std::ios::badbit);
+// }
- /// Open a write only stream on the file named \a name.
- zofstream(const char *name, int io_mode = std::ios::out) :
- std::ostream(zfilestream_common::rdbuf())
- {
- zfilestream_common::open(name, io_mode);
- }
+// /// Open a write only stream on the file named \a name.
+// zofstream(const char *name, int io_mode = std::ios::out) :
+// std::ostream(zfilestream_common::rdbuf())
+// {
+// zfilestream_common::open(name, io_mode);
+// }
- /// Open a write only stream on the file descriptor \a fd.
- zofstream(int fd, int io_mode = std::ios::out) :
- std::ostream(zfilestream_common::rdbuf())
- {
- zfilestream_common::attach(fd, io_mode);
- }
+// /// Open a write only stream on the file descriptor \a fd.
+// zofstream(int fd, int io_mode = std::ios::out) :
+// std::ostream(zfilestream_common::rdbuf())
+// {
+// zfilestream_common::attach(fd, io_mode);
+// }
- virtual ~zofstream() {}
+// virtual ~zofstream() {}
- };
+// };
- // Forward declaration.
- template <class T>
- class zomanip;
+// // Forward declaration.
+// template <class T>
+// class zomanip;
- /// Apply a function on \a s via the operator <<.
- template <class T>
- zofstream&
- operator<<(zofstream &s, const zomanip<T> &m) {
- return (*m.func)(s, m.val);
- }
+// /// Apply a function on \a s via the operator <<.
+// template <class T>
+// zofstream&
+// operator<<(zofstream &s, const zomanip<T> &m) {
+// return (*m.func)(s, m.val);
+// }
- /// Define a pair func / val to perform manipulation on zofstream.
- template<class T> class zomanip
- {
- friend zofstream &operator<< <T>(zofstream &, const zomanip<T>
&);
- public:
- zomanip(zofstream &(*f)(zofstream &, T), T v) : func(f), val(v) { }
- private:
- zofstream &(*func)(zofstream &, T);
- T val;
- };
+// /// Define a pair func / val to perform manipulation on zofstream.
+// template<class T> class zomanip
+// {
+// friend zofstream &operator<< <T>(zofstream &, const
zomanip<T> &);
+// public:
+// zomanip(zofstream &(*f)(zofstream &, T), T v) : func(f), val(v) { }
+// private:
+// zofstream &(*func)(zofstream &, T);
+// T val;
+// };
- /// Set the compression level of \a s to \a l.
- inline zofstream&
- setcompressionlevel(zofstream &s, int l) {
- (s.rdbuf())->setcompressionlevel(l);
- return s;
- }
+// /// Set the compression level of \a s to \a l.
+// inline zofstream&
+// setcompressionlevel(zofstream &s, int l) {
+// (s.rdbuf())->setcompressionlevel(l);
+// return s;
+// }
- /// Set the compression strategy of \a s to \a l.
- inline zofstream&
- setcompressionstrategy(zofstream &s, int l)
- {
- (s.rdbuf())->setcompressionstrategy(l);
- return s;
- }
+// /// Set the compression strategy of \a s to \a l.
+// inline zofstream&
+// setcompressionstrategy(zofstream &s, int l)
+// {
+// (s.rdbuf())->setcompressionstrategy(l);
+// return s;
+// }
- /// Specialized version for zomanip<int>
- inline zomanip<int>
- setcompressionlevel(int l)
- {
- return zomanip<int>(&setcompressionlevel,l);
- }
+// /// Specialized version for zomanip<int>
+// inline zomanip<int>
+// setcompressionlevel(int l)
+// {
+// return zomanip<int>(&setcompressionlevel,l);
+// }
- /// Specialized version for zomanip<int>
- inline zomanip<int>
- setcompressionstrategy(int l)
- {
- return zomanip<int>(&setcompressionstrategy,l);
- }
+// /// Specialized version for zomanip<int>
+// inline zomanip<int>
+// setcompressionstrategy(int l)
+// {
+// return zomanip<int>(&setcompressionstrategy,l);
+// }
- } // end of namespace gz
+// } // end of namespace gz
- } // end of namespace io
+// } // end of namespace io
-} // end of namespace oln
+// } // end of namespace oln
-# endif // ! HAVE_ZLIB
+// # endif // ! HAVE_ZLIB
#endif // ! OLN_IO_GZ_STREAM_HH
Index: oln/io/write_image_2d_pnm.hh
===================================================================
--- oln/io/write_image_2d_pnm.hh (revision 166)
+++ oln/io/write_image_2d_pnm.hh (working copy)
@@ -29,196 +29,196 @@
#ifndef OLN_IO_WRITE_IMAGE_2D_PNM_HH
# define OLN_IO_WRITE_IMAGE_2D_PNM_HH
-# include <iostream>
-# include <string>
+// # include <iostream>
+// # include <string>
-# include <mlc/box.hh>
+// # include <mlc/box.hh>
-# include <ntg/all.hh>
+// # include <ntg/all.hh>
-# include <oln/core/2d/image2d.hh>
+// # include <oln/core/2d/image2d.hh>
-// commented cause 'void_op' was removed
-//# include <oln/core/abstract/op.hh>
+// // commented cause 'void_op' was removed
+// //# include <oln/core/abstract/op.hh>
-# include <oln/io/utils.hh>
+// # include <oln/io/utils.hh>
-namespace oln {
+// namespace oln {
- namespace io {
+// namespace io {
- namespace impl {
+// namespace impl {
- template <typename I>
- struct write_image_2d_raw
- // commented below cause 'void_op' was removed
-// : public oln::abstract::void_op<write_image_2d_raw<I> >
- {
- typedef oln_type_of(I, value) value_type;
+// template <typename I>
+// struct write_image_2d_raw
+// // commented below cause 'void_op' was removed
+// // : public oln::abstract::void_op<write_image_2d_raw<I> >
+// {
+// typedef oln_type_of(I, value) value_type;
- const I& to_write_;
- std::ostream& ostr_;
- int bin_offset;
- char bin_v;
+// const I& to_write_;
+// std::ostream& ostr_;
+// int bin_offset;
+// char bin_v;
- write_image_2d_raw(const I& to_write, std::ostream& ostr):
- to_write_(to_write),
- ostr_(ostr)
- {
- bin_offset = 7;
- bin_v = 0;
- }
+// write_image_2d_raw(const I& to_write, std::ostream& ostr):
+// to_write_(to_write),
+// ostr_(ostr)
+// {
+// bin_offset = 7;
+// bin_v = 0;
+// }
- void run()
- {
- point2d p;
- value_type c;
+// void run()
+// {
+// point2d p;
+// value_type c;
- for (p.row() = 0; p.row() < to_write_.size().nrows(); ++p.row())
- {
- for (p.col() = 0; p.col() < to_write_.size().ncols(); ++p.col())
- // FIXME: SHOULD NOT BE .value() !!!
- write_value_type(to_write_[p].value());
- write_padding(c);
- }
- }
+// for (p.row() = 0; p.row() < to_write_.size().nrows(); ++p.row())
+// {
+// for (p.col() = 0; p.col() < to_write_.size().ncols(); ++p.col())
+// // FIXME: SHOULD NOT BE .value() !!!
+// write_value_type(to_write_[p].value());
+// write_padding(c);
+// }
+// }
- template <typename E>
- void write_padding(const ntg::value<E>&) {}
+// template <typename E>
+// void write_padding(const ntg::value<E>&) {}
- void write_padding(const ntg::bin&)
- {
- if (bin_offset != 7)
- {
- ostr_.write(&bin_v, 1);
- bin_offset = 7;
- bin_v = 0;
- }
- }
+// void write_padding(const ntg::bin&)
+// {
+// if (bin_offset != 7)
+// {
+// ostr_.write(&bin_v, 1);
+// bin_offset = 7;
+// bin_v = 0;
+// }
+// }
- //FIXME: Should work with builtin types.
+// //FIXME: Should work with builtin types.
- template <typename E>
- void write_value_type(const ntg::real_value<E> &c)
- {
- typedef oln_io_type(ntg_nbits(E)) v_type;
+// template <typename E>
+// void write_value_type(const ntg::real_value<E> &c)
+// {
+// typedef oln_io_type(ntg_nbits(E)) v_type;
- v_type v;
- v = ntg::cast::bound<E, v_type>(c.exact());
- ostr_.write((char*)&v, sizeof (v_type));
- }
+// v_type v;
+// v = ntg::cast::bound<E, v_type>(c.exact());
+// ostr_.write((char*)&v, sizeof (v_type));
+// }
- template <typename E>
- void write_value_type(const ntg::vect_value<E> &c)
- {
- for (unsigned i = 0; i < 3; i++)
- {
- typedef oln_io_type(ntg_nbits(ntg_comp_type(value_type))) v_type;
+// template <typename E>
+// void write_value_type(const ntg::vect_value<E> &c)
+// {
+// for (unsigned i = 0; i < 3; i++)
+// {
+// typedef oln_io_type(ntg_nbits(ntg_comp_type(value_type))) v_type;
- v_type v;
- v = c[i];
- ostr_.write((char*)&v, sizeof (v_type));
- }
- }
+// v_type v;
+// v = c[i];
+// ostr_.write((char*)&v, sizeof (v_type));
+// }
+// }
- void write_value_type(const ntg::bin &c)
- {
- if (bin_offset == -1)
- {
- ostr_.write(&bin_v, 1);
- bin_offset = 7;
- bin_v = 0;
- }
- if (c == value_type(1))
- bin_v |= 1 << bin_offset;
- bin_offset--;
- }
- };
+// void write_value_type(const ntg::bin &c)
+// {
+// if (bin_offset == -1)
+// {
+// ostr_.write(&bin_v, 1);
+// bin_offset = 7;
+// bin_v = 0;
+// }
+// if (c == value_type(1))
+// bin_v |= 1 << bin_offset;
+// bin_offset--;
+// }
+// };
- template <typename I, typename T>
- void write(const abstract::image2d<I>& to_write,
- const ntg::real_value<T>&,
- std::ostream& ostr,
- const std::string& ext)
- {
+// template <typename I, typename T>
+// void write(const abstract::image2d<I>& to_write,
+// const ntg::real_value<T>&,
+// std::ostream& ostr,
+// const std::string& ext)
+// {
- point2d p;
- size2d s = to_write.size();
+// point2d p;
+// size2d s = to_write.size();
- precondition(ntg_nbits(T) <= 16);
- if (ext == "pgm")
- if (internal::write_pnm_header(ostr, "P5",
- s.ncols(), s.nrows(),
- ntg_max_val(T)))
- {
- write_image_2d_raw<I> tmp(to_write.exact(), ostr);
- tmp.run();
- }
- else
- std::cerr << "error: unable to write file header" <<
std::endl;
- else
- std::cerr << "error: image data type (`integer') does not match"
- << " file extension (`" << ext << "')"
<< std::endl;
- }
+// precondition(ntg_nbits(T) <= 16);
+// if (ext == "pgm")
+// if (internal::write_pnm_header(ostr, "P5",
+// s.ncols(), s.nrows(),
+// ntg_max_val(T)))
+// {
+// write_image_2d_raw<I> tmp(to_write.exact(), ostr);
+// tmp.run();
+// }
+// else
+// std::cerr << "error: unable to write file header" <<
std::endl;
+// else
+// std::cerr << "error: image data type (`integer') does not
match"
+// << " file extension (`" << ext << "')"
<< std::endl;
+// }
- template <typename I, typename T>
- void write(const abstract::image2d<I>& to_write,
- const ntg::color_value<T>&,
- std::ostream& ostr,
- const std::string& ext)
- {
+// template <typename I, typename T>
+// void write(const abstract::image2d<I>& to_write,
+// const ntg::color_value<T>&,
+// std::ostream& ostr,
+// const std::string& ext)
+// {
- point2d p;
- size2d s = to_write.size();
+// point2d p;
+// size2d s = to_write.size();
- precondition(ntg_nbits(ntg_comp_type(T)) <= 16);
- precondition(ntg_nb_comp(T) == 3);
- if (ext == "ppm")
- if (internal::write_pnm_header(ostr, "P6",
- s.ncols(), s.nrows(),
- ntg_max_val(ntg_comp_type(T))))
- {
- write_image_2d_raw<I> tmp(to_write.exact(), ostr);
- tmp.run();
- }
- else
- std::cerr << "error: unable to write header" << std::endl;
- else
- std::cerr << "error: image data type (`color') does not match"
- << " file extension (`" << ext << "')"
<< std::endl;
- }
+// precondition(ntg_nbits(ntg_comp_type(T)) <= 16);
+// precondition(ntg_nb_comp(T) == 3);
+// if (ext == "ppm")
+// if (internal::write_pnm_header(ostr, "P6",
+// s.ncols(), s.nrows(),
+// ntg_max_val(ntg_comp_type(T))))
+// {
+// write_image_2d_raw<I> tmp(to_write.exact(), ostr);
+// tmp.run();
+// }
+// else
+// std::cerr << "error: unable to write header" << std::endl;
+// else
+// std::cerr << "error: image data type (`color') does not match"
+// << " file extension (`" << ext << "')"
<< std::endl;
+// }
- template <typename I>
- void write(const abstract::image2d<I>& to_write,
- const ntg::bin&,
- std::ostream& ostr,
- const std::string& ext)
- {
- point2d p;
- size2d s = to_write.size();
+// template <typename I>
+// void write(const abstract::image2d<I>& to_write,
+// const ntg::bin&,
+// std::ostream& ostr,
+// const std::string& ext)
+// {
+// point2d p;
+// size2d s = to_write.size();
- if (ext == "pbm")
- if (internal::write_pnm_header(ostr, "P4",
- s.ncols(), s.nrows(),
- 1))
- {
- write_image_2d_raw<I> tmp(to_write.exact(), ostr);
- tmp.run();
- }
- else
- std::cerr << "error: unable to write header" << std::endl;
- else
- std::cerr << "error: image data type (`enum_value') does not
match"
- << " file extension (`" << ext << "')"
<< std::endl;
- }
+// if (ext == "pbm")
+// if (internal::write_pnm_header(ostr, "P4",
+// s.ncols(), s.nrows(),
+// 1))
+// {
+// write_image_2d_raw<I> tmp(to_write.exact(), ostr);
+// tmp.run();
+// }
+// else
+// std::cerr << "error: unable to write header" << std::endl;
+// else
+// std::cerr << "error: image data type (`enum_value') does not
match"
+// << " file extension (`" << ext << "')"
<< std::endl;
+// }
- }
+// }
- }
+// }
-}
+// }
Index: oln/io/read_image_2d_pnm.hh
===================================================================
--- oln/io/read_image_2d_pnm.hh (revision 166)
+++ oln/io/read_image_2d_pnm.hh (working copy)
@@ -28,160 +28,160 @@
#ifndef OLN_IO_READ_IMAGE_2D_PNM_HH
# define OLN_IO_READ_IMAGE_2D_PNM_HH
-# include <iostream>
-# include <string>
+// # include <iostream>
+// # include <string>
-# include <mlc/box.hh>
-# include <mlc/math.hh>
+// # include <mlc/box.hh>
+// # include <mlc/math.hh>
-# include <ntg/all.hh>
+// # include <ntg/all.hh>
-# include <oln/core/2d/image2d.hh>
+// # include <oln/core/2d/image2d.hh>
-# include <oln/core/abstract/image_operator.hh>
+// # include <oln/core/abstract/image_operator.hh>
-# include <oln/io/utils.hh>
+// # include <oln/io/utils.hh>
-namespace oln {
+// namespace oln {
- template <typename I>
- struct image2d;
+// template <typename I>
+// struct image2d;
- // fwd decl
- namespace io {
- namespace impl {
- template <typename I> struct read_image_2d_raw;
- }
- }
+// // fwd decl
+// namespace io {
+// namespace impl {
+// template <typename I> struct read_image_2d_raw;
+// }
+// }
- // super_type
- template <typename I>
- struct set_super_type < io::impl::read_image_2d_raw<I> >
- {
- typedef abstract::image_operator<I, io::impl::read_image_2d_raw<I> >
ret;
- };
+// // super_type
+// template <typename I>
+// struct set_super_type < io::impl::read_image_2d_raw<I> >
+// {
+// typedef abstract::image_operator<I, io::impl::read_image_2d_raw<I> >
ret;
+// };
- namespace io {
+// namespace io {
- namespace impl {
+// namespace impl {
- template <typename I>
- struct read_image_2d_raw :
- public oln::abstract::image_operator<I, read_image_2d_raw<I> >
- {
- typedef oln::abstract::image_operator<I, read_image_2d_raw<I> >
- super_type;
- typedef oln_type_of(I, value) value_type;
+// template <typename I>
+// struct read_image_2d_raw :
+// public oln::abstract::image_operator<I, read_image_2d_raw<I> >
+// {
+// typedef oln::abstract::image_operator<I, read_image_2d_raw<I> >
+// super_type;
+// typedef oln_type_of(I, value) value_type;
- std::istream& istr_;
- internal::pnm_info& info_;
- char v;
- int offset;
+// std::istream& istr_;
+// internal::pnm_info& info_;
+// char v;
+// int offset;
- read_image_2d_raw(std::istream &istr,
- internal::pnm_info &info) :
- super_type(),
- istr_(istr),
- info_(info),
- offset(-1)
- {
- }
+// read_image_2d_raw(std::istream &istr,
+// internal::pnm_info &info) :
+// super_type(),
+// istr_(istr),
+// info_(info),
+// offset(-1)
+// {
+// }
- template <typename E>
- void precond(ntg::real_value<E>& c)
- {
- precondition(ntg_max_val(value_type) <= info_.max_val);
- precondition(info_.type == "P5");
- }
+// template <typename E>
+// void precond(ntg::real_value<E>& c)
+// {
+// precondition(ntg_max_val(value_type) <= info_.max_val);
+// precondition(info_.type == "P5");
+// }
- template <typename E>
- void precond(ntg::vect_value<E>& c)
- {
- precondition(ntg_max_val(ntg_comp_type(value_type)) <=
- info_.max_val);
- precondition(info_.type == "P6");
- precondition(ntg_nb_comp(value_type) == 3);
- }
+// template <typename E>
+// void precond(ntg::vect_value<E>& c)
+// {
+// precondition(ntg_max_val(ntg_comp_type(value_type)) <=
+// info_.max_val);
+// precondition(info_.type == "P6");
+// precondition(ntg_nb_comp(value_type) == 3);
+// }
- void precond(ntg::bin& c)
- {
- precondition(info_.type == "P4");
- }
+// void precond(ntg::bin& c)
+// {
+// precondition(info_.type == "P4");
+// }
- void impl_run()
- {
- value_type c;
- point2d p;
- oln::image2d<value_type> tmp(info_.rows, info_.cols);
+// void impl_run()
+// {
+// value_type c;
+// point2d p;
+// oln::image2d<value_type> tmp(info_.rows, info_.cols);
- precond(c);
+// precond(c);
- for (p.row() = 0; p.row() < info_.rows && !istr_.eof(); ++p.row())
- {
- offset = -1;
- for (p.col() = 0; p.col() < info_.cols && !istr_.eof(); ++p.col())
- {
- read_value_type(c);
- tmp[p] = c;
- }
- }
- this->output = tmp;
- }
+// for (p.row() = 0; p.row() < info_.rows && !istr_.eof(); ++p.row())
+// {
+// offset = -1;
+// for (p.col() = 0; p.col() < info_.cols && !istr_.eof(); ++p.col())
+// {
+// read_value_type(c);
+// tmp[p] = c;
+// }
+// }
+// this->output = tmp;
+// }
- //FIXME: Should work with builtin types.
+// //FIXME: Should work with builtin types.
- template <typename E>
- void read_value_type(ntg::real_value<E> &c)
- {
- typedef oln_io_type(ntg_nbits(E)) v_type;
- v_type v;
- istr_.read((char*)&v, sizeof (v_type));
- c = ntg::cast::force<E, v_type>(v);
- }
+// template <typename E>
+// void read_value_type(ntg::real_value<E> &c)
+// {
+// typedef oln_io_type(ntg_nbits(E)) v_type;
+// v_type v;
+// istr_.read((char*)&v, sizeof (v_type));
+// c = ntg::cast::force<E, v_type>(v);
+// }
- template <typename E>
- void read_value_type(ntg::vect_value<E> &c)
- {
- for (unsigned i = 0; i < ntg_nb_comp(E); i++)
- {
- typedef oln_io_type(ntg_nbits(ntg_comp_type(E))) v_type;
- v_type v;
- istr_.read((char*)&v, sizeof (v_type));
- c[i] = ntg::cast::force<ntg_comp_type(E), v_type>(v);
- }
- }
+// template <typename E>
+// void read_value_type(ntg::vect_value<E> &c)
+// {
+// for (unsigned i = 0; i < ntg_nb_comp(E); i++)
+// {
+// typedef oln_io_type(ntg_nbits(ntg_comp_type(E))) v_type;
+// v_type v;
+// istr_.read((char*)&v, sizeof (v_type));
+// c[i] = ntg::cast::force<ntg_comp_type(E), v_type>(v);
+// }
+// }
- void read_value_type(ntg::bin &c)
- {
+// void read_value_type(ntg::bin &c)
+// {
- if (offset == -1)
- {
- istr_.read(&v, 1);
- offset = 7;
- }
- if ((int)(v & (1<<offset--)) == 0)
- c = 0;
- else
- c = 1;
- }
- };
+// if (offset == -1)
+// {
+// istr_.read(&v, 1);
+// offset = 7;
+// }
+// if ((int)(v & (1<<offset--)) == 0)
+// c = 0;
+// else
+// c = 1;
+// }
+// };
- template <typename I>
- read_image_2d_raw<I>
- read(std::istream& istr, internal::pnm_info info)
- {
- read_image_2d_raw<I> tmp(istr, info);
- tmp.run();
- return tmp;
- }
+// template <typename I>
+// read_image_2d_raw<I>
+// read(std::istream& istr, internal::pnm_info info)
+// {
+// read_image_2d_raw<I> tmp(istr, info);
+// tmp.run();
+// return tmp;
+// }
- }
+// }
- }
+// }
-}
+// }
#endif // ! OLN_IO_READ_IMAGE_2D_PNM_HH
Index: oln/io/write_image.hh
===================================================================
--- oln/io/write_image.hh (revision 166)
+++ oln/io/write_image.hh (working copy)
@@ -28,84 +28,84 @@
#ifndef OLN_IO_WRITE_IMAGE_HH
# define OLN_IO_WRITE_IMAGE_HH
-# include <string>
+// # include <string>
-# include <oln/io/gz_stream.hh>
-# include <oln/io/utils.hh>
-# include <oln/io/write_image_2d_pnm.hh>
+// # include <oln/io/gz_stream.hh>
+// # include <oln/io/utils.hh>
+// # include <oln/io/write_image_2d_pnm.hh>
-namespace oln {
+// namespace oln {
- namespace io {
+// namespace io {
- template <typename I>
- void do_write(const abstract::image<I>& ima,
- std::ostream& ostr,
- const std::string& ext)
- {
- typedef oln_type_of(I, value) value_type;
- value_type t;
+// template <typename I>
+// void do_write(const abstract::image<I>& ima,
+// std::ostream& ostr,
+// const std::string& ext)
+// {
+// typedef oln_type_of(I, value) value_type;
+// value_type t;
- impl::write(ima.exact(), t, ostr, ext);
- }
+// impl::write(ima.exact(), t, ostr, ext);
+// }
-#if defined HAVE_ZLIB && HAVE_ZLIB == 1
- template <typename I>
- void write_gz(const abstract::image<I>& ima, const std::string& name)
- {
- gz::zofstream zostr(name.c_str(), std::ios::out);
+// #if defined HAVE_ZLIB && HAVE_ZLIB == 1
+// template <typename I>
+// void write_gz(const abstract::image<I>& ima, const std::string&
name)
+// {
+// gz::zofstream zostr(name.c_str(), std::ios::out);
- if (zostr.is_open() == false)
- std::cerr << "error: couldn't open " << name <<
std::endl;
- else
- {
- std::string ext;
+// if (zostr.is_open() == false)
+// std::cerr << "error: couldn't open " << name <<
std::endl;
+// else
+// {
+// std::string ext;
- ext = internal::utils::extension(name.substr(0, name.size() - 3));
- do_write(ima, zostr, ext);
- }
- zostr.close();
- }
+// ext = internal::utils::extension(name.substr(0, name.size() - 3));
+// do_write(ima, zostr, ext);
+// }
+// zostr.close();
+// }
-#endif // ! HAVE_ZLIB
+// #endif // ! HAVE_ZLIB
- template <typename I>
- void write_non_gz(const abstract::image<I>& ima,
- const std::string& name,
- const std::string& ext)
- {
- std::ofstream ostr;
+// template <typename I>
+// void write_non_gz(const abstract::image<I>& ima,
+// const std::string& name,
+// const std::string& ext)
+// {
+// std::ofstream ostr;
- ostr.open(name.c_str(), std::ifstream::out);
+// ostr.open(name.c_str(), std::ifstream::out);
- if (ostr.is_open() == false)
- std::cerr << "error: couldn't open " << name <<
std::endl;
- else
- do_write(ima, ostr, ext);
- ostr.close();
- }
+// if (ostr.is_open() == false)
+// std::cerr << "error: couldn't open " << name <<
std::endl;
+// else
+// do_write(ima, ostr, ext);
+// ostr.close();
+// }
- template <typename I>
- void write(const abstract::image<I>& ima, const std::string& name)
- {
- std::string ext;
- // FIXME: Unused?
- // oln_type_of(I, value) t;
+// template <typename I>
+// void write(const abstract::image<I>& ima, const std::string& name)
+// {
+// std::string ext;
+// // FIXME: Unused?
+// // oln_type_of(I, value) t;
- ext = internal::utils::extension(name);
+// ext = internal::utils::extension(name);
-#if defined HAVE_ZLIB && HAVE_ZLIB == 1
- if (ext == "gz")
- write_gz(ima, name);
- else
- write_non_gz(ima, name, ext);
-# else
- write_non_gz(ima, name, ext);
-#endif // ! HAVE_ZLIB
- }
+// #if defined HAVE_ZLIB && HAVE_ZLIB == 1
+// if (ext == "gz")
+// write_gz(ima, name);
+// else
+// write_non_gz(ima, name, ext);
+// # else
+// write_non_gz(ima, name, ext);
+// #endif // ! HAVE_ZLIB
+// }
- }
+// }
-}
+// }
#endif // ! OLN_IO_WRITE_IMAGE_HH
Index: oln/io/read_image.hh
===================================================================
--- oln/io/read_image.hh (revision 166)
+++ oln/io/read_image.hh (working copy)
@@ -63,99 +63,99 @@
}
- template <typename I>
- void read_dispatch_ext(abstract::image<I>& ima,
- std::istream& istr,
- const std::string& ext)
+// template <typename I>
+// void read_dispatch_ext(abstract::image<I>& ima,
+// std::istream& istr,
+// const std::string& ext)
- {
- if (ext == "pgm" || ext == "pbm" || ext == "ppm" ||
- ext == "pnm")
- {
- internal::pnm_info info;
+// {
+// if (ext == "pgm" || ext == "pbm" || ext == "ppm"
||
+// ext == "pnm")
+// {
+// internal::pnm_info info;
- if (internal::read_pnm_header(istr, info))
- if ((ext == "ppm" || ext == "pnm") && info.type ==
"P6")
- ima.exact() = impl::read<I>(istr, info);
- else if ((ext == "ppm" || ext == "pnm") && info.type ==
"P3")
- std::cerr << "error: read_image_2d_ppm_ascii not implemented"
- << std::endl;
- else if ((ext == "pbm" || ext == "pnm") && info.type ==
"P4")
- ima.exact() = impl::read<I>(istr, info);
- else if ((ext == "pbm" || ext == "pnm") && info.type ==
"P1")
- std::cerr << "error: read_image_2d_ppm_ascii not implemented"
- << std::endl;
- else if ((ext == "pgm" || ext == "pnm") && info.type ==
"P5")
- ima.exact() = impl::read<I>(istr, info);
- else if ((ext == "pgm" || ext == "pnm") && info.type ==
"P2")
- std::cerr << "error: read_image_2d_ppm_ascii not implemented"
- << std::endl;
- else
- std::cerr << "error: file header (`" << info.type
- << "') does not match file extension (`"
- << ext << "')" << std::endl;
- else
- std::cerr << "error: unable to get a valid header" <<
std::endl;
- }
- else
- std::cout << "no input method for '"
- << ext << "' file extension"
- << std::endl;
- }
+// if (internal::read_pnm_header(istr, info))
+// if ((ext == "ppm" || ext == "pnm") && info.type ==
"P6")
+// ima.exact() = impl::read<I>(istr, info);
+// else if ((ext == "ppm" || ext == "pnm") && info.type
== "P3")
+// std::cerr << "error: read_image_2d_ppm_ascii not implemented"
+// << std::endl;
+// else if ((ext == "pbm" || ext == "pnm") && info.type
== "P4")
+// ima.exact() = impl::read<I>(istr, info);
+// else if ((ext == "pbm" || ext == "pnm") && info.type
== "P1")
+// std::cerr << "error: read_image_2d_ppm_ascii not implemented"
+// << std::endl;
+// else if ((ext == "pgm" || ext == "pnm") && info.type
== "P5")
+// ima.exact() = impl::read<I>(istr, info);
+// else if ((ext == "pgm" || ext == "pnm") && info.type
== "P2")
+// std::cerr << "error: read_image_2d_ppm_ascii not implemented"
+// << std::endl;
+// else
+// std::cerr << "error: file header (`" << info.type
+// << "') does not match file extension (`"
+// << ext << "')" << std::endl;
+// else
+// std::cerr << "error: unable to get a valid header" <<
std::endl;
+// }
+// else
+// std::cout << "no input method for '"
+// << ext << "' file extension"
+// << std::endl;
+// }
-#if defined HAVE_ZLIB && HAVE_ZLIB == 1
- template <typename I>
- void do_read_gz(abstract::image<I>& ima, const std::string& name)
- {
- gz::zifstream zistr(name.c_str(), std::ios::in);
+// #if defined HAVE_ZLIB && HAVE_ZLIB == 1
+// template <typename I>
+// void do_read_gz(abstract::image<I>& ima, const std::string& name)
+// {
+// gz::zifstream zistr(name.c_str(), std::ios::in);
- if (zistr.is_open() == false)
- std::cerr << "error: couldn't open " << name <<
std::endl;
- else
- {
- std::string ext;
+// if (zistr.is_open() == false)
+// std::cerr << "error: couldn't open " << name <<
std::endl;
+// else
+// {
+// std::string ext;
- ext = internal::utils::extension(name.substr(0, name.size() - 3));
- read_dispatch_ext(ima, zistr, ext);
- }
- zistr.close();
- }
+// ext = internal::utils::extension(name.substr(0, name.size() - 3));
+// read_dispatch_ext(ima, zistr, ext);
+// }
+// zistr.close();
+// }
-#endif // ! HAVE_ZLIB
+// #endif // ! HAVE_ZLIB
- template <typename I>
- void do_read_non_gz(abstract::image<I>& ima,
- const std::string& name,
- const std::string& ext)
- {
- std::ifstream istr;
+// template <typename I>
+// void do_read_non_gz(abstract::image<I>& ima,
+// const std::string& name,
+// const std::string& ext)
+// {
+// std::ifstream istr;
- istr.open(name.c_str(), std::ifstream::in);
+// istr.open(name.c_str(), std::ifstream::in);
- if (istr.is_open() == false)
- std::cerr << "error: couldn't open " << name <<
std::endl;
- else
- read_dispatch_ext(ima, istr, ext);
- istr.close();
- }
+// if (istr.is_open() == false)
+// std::cerr << "error: couldn't open " << name <<
std::endl;
+// else
+// read_dispatch_ext(ima, istr, ext);
+// istr.close();
+// }
- template <typename I>
- void do_read(abstract::image<I>& ima, const filename& name)
- {
- std::string ext;
+// template <typename I>
+// void do_read(abstract::image<I>& ima, const filename& name)
+// {
+// std::string ext;
- ext = internal::utils::extension(name.get());
+// ext = internal::utils::extension(name.get());
-#if defined HAVE_ZLIB && HAVE_ZLIB == 1
+// #if defined HAVE_ZLIB && HAVE_ZLIB == 1
- if (ext == "gz")
- do_read_gz(ima, name.get());
- else
- do_read_non_gz(ima, name.get(), ext);
-#else
- do_read_non_gz(ima, name.get(), ext);
-#endif // ! HAVE_ZLIB
- }
+// if (ext == "gz")
+// do_read_gz(ima, name.get());
+// else
+// do_read_non_gz(ima, name.get(), ext);
+// #else
+// do_read_non_gz(ima, name.get(), ext);
+// #endif // ! HAVE_ZLIB
+// }
}
Index: oln/io/utils.hh
===================================================================
--- oln/io/utils.hh (revision 166)
+++ oln/io/utils.hh (working copy)
@@ -28,153 +28,153 @@
#ifndef OLENA_IO_UTILS_HH
# define OLENA_IO_UTILS_HH
-# include <oln/config/system.hh>
+// # include <oln/config/system.hh>
-# include <iostream>
-# include <fstream>
-# include <string>
+// # include <iostream>
+// # include <fstream>
+// # include <string>
-namespace oln {
+// namespace oln {
- namespace io {
+// namespace io {
- namespace internal {
+// namespace internal {
- /*!
- ** \brief Utils for io (get extension of a file).
- */
- struct utils
- {
+// /*!
+// ** \brief Utils for io (get extension of a file).
+// */
+// struct utils
+// {
- /*!
- ** \brief Return the extension of a filename.
- ** \arg name The filename.
- ** \return The extension (lower case).
- */
- static std::string
- extension(const std::string& name)
- {
- std::string ext;
- int pos = name.rfind('.');
- if (pos > 0)
- {
- ext.assign(name, pos + 1, name.size() - pos);
- for (std::string::iterator i = ext.begin(); i != ext.end(); ++i)
- *i = tolower(*i);
- }
- return ext;
- }
+// /*!
+// ** \brief Return the extension of a filename.
+// ** \arg name The filename.
+// ** \return The extension (lower case).
+// */
+// static std::string
+// extension(const std::string& name)
+// {
+// std::string ext;
+// int pos = name.rfind('.');
+// if (pos > 0)
+// {
+// ext.assign(name, pos + 1, name.size() - pos);
+// for (std::string::iterator i = ext.begin(); i != ext.end(); ++i)
+// *i = tolower(*i);
+// }
+// return ext;
+// }
- };
+// };
- struct pnm_info
- {
- int max_val;
- int rows;
- int cols;
- std::string type;
- };
+// struct pnm_info
+// {
+// int max_val;
+// int rows;
+// int cols;
+// std::string type;
+// };
- bool read_pnm_header(std::istream& istr,
- internal::pnm_info& info)
- {
- std::getline(istr, info.type);
+// bool read_pnm_header(std::istream& istr,
+// internal::pnm_info& info)
+// {
+// std::getline(istr, info.type);
- info.max_val = 1;
+// info.max_val = 1;
- // skip comments
- while (istr.peek() == '#')
- {
- std::string line;
- std::getline(istr, line);
- }
+// // skip comments
+// while (istr.peek() == '#')
+// {
+// std::string line;
+// std::getline(istr, line);
+// }
- // read size
- istr >> info.cols;
- // skip comments
- while (istr.peek() == '#')
- {
- std::string line;
- std::getline(istr, line);
- }
+// // read size
+// istr >> info.cols;
+// // skip comments
+// while (istr.peek() == '#')
+// {
+// std::string line;
+// std::getline(istr, line);
+// }
- istr >> info.rows;
- // skip comments
- while (istr.peek() == '#')
- {
- std::string line;
- std::getline(istr, line);
- }
+// istr >> info.rows;
+// // skip comments
+// while (istr.peek() == '#')
+// {
+// std::string line;
+// std::getline(istr, line);
+// }
- if (info.cols <= 0 || info.rows <= 0) return false;
+// if (info.cols <= 0 || info.rows <= 0) return false;
- // skip comments
- while (istr.peek() == '#')
- {
- std::string line;
- std::getline(istr, line);
- }
+// // skip comments
+// while (istr.peek() == '#')
+// {
+// std::string line;
+// std::getline(istr, line);
+// }
- // FIXME: it can be either '\n', 'whitespace', ..., not only
'\n'!
- if (istr.get() != '\n') return false;
- // extract or skip maxvalue
- if (info.type != "P1" && info.type != "P4")
- {
- istr >> info.max_val;
- if (info.max_val > 65535 ||
- istr.get() != '\n' ||
- info.max_val <= 0)
- return false;
- }
- return true;
- }
+// // FIXME: it can be either '\n', 'whitespace', ..., not only
'\n'!
+// if (istr.get() != '\n') return false;
+// // extract or skip maxvalue
+// if (info.type != "P1" && info.type != "P4")
+// {
+// istr >> info.max_val;
+// if (info.max_val > 65535 ||
+// istr.get() != '\n' ||
+// info.max_val <= 0)
+// return false;
+// }
+// return true;
+// }
- bool write_pnm_header(std::ostream& ostr,
- const std::string& type,
- int ncols,
- int nrows,
- int max_val)
- {
- if (max_val > 65535)
- return false;
+// bool write_pnm_header(std::ostream& ostr,
+// const std::string& type,
+// int ncols,
+// int nrows,
+// int max_val)
+// {
+// if (max_val > 65535)
+// return false;
- ostr << type << std::endl
- << "# Olena 1.0" << std::endl
- << ncols << " " << nrows << std::endl;
- if (type != "P1" && type != "P4")
- ostr << max_val << std::endl;
- return true;
- }
+// ostr << type << std::endl
+// << "# Olena 1.0" << std::endl
+// << ncols << " " << nrows << std::endl;
+// if (type != "P1" && type != "P4")
+// ostr << max_val << std::endl;
+// return true;
+// }
- template <bool b>
- struct pnm_io_helper_bool
- {
- typedef unsigned char type;
- };
+// template <bool b>
+// struct pnm_io_helper_bool
+// {
+// typedef unsigned char type;
+// };
- template <>
- struct pnm_io_helper_bool<false>
- {
- typedef unsigned short type;
- };
+// template <>
+// struct pnm_io_helper_bool<false>
+// {
+// typedef unsigned short type;
+// };
- template <unsigned N>
- struct pnm_io_helper
- {
- typedef typename pnm_io_helper_bool<N <= 8>::type type;
- };
+// template <unsigned N>
+// struct pnm_io_helper
+// {
+// typedef typename pnm_io_helper_bool<N <= 8>::type type;
+// };
- } // end of namespace internal
+// } // end of namespace internal
- } // end of namespace io
+// } // end of namespace io
-} // end of namespace oln
+// } // end of namespace oln
-# define oln_io_type(N) typename oln::io::internal::pnm_io_helper<N>::type
-# define oln_io_type_(N) oln::io::internal::pnm_io_helper<N>::type
+// # define oln_io_type(N) typename oln::io::internal::pnm_io_helper<N>::type
+// # define oln_io_type_(N) oln::io::internal::pnm_io_helper<N>::type
#endif // ! OLENA_IO_UTILS_HH