/* Copyright (c) 1997-2006
   Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
   http://www.math.tu-berlin.de/polymake,  mailto:polymake@math.tu-berlin.de

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version: http://www.gnu.org/licenses/gpl.txt.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
*/

#ifndef _POLYMAKE_FSTREAM_H
#define _POLYMAKE_FSTREAM_H "$Project: polymake $$Id: fstream 6931 2006-02-02 11:44:13Z gawrilow $"

#include_next <fstream>

namespace pm {

class FileBuffer : public std::filebuf {
private:
   // never create
   FileBuffer();
   ~FileBuffer();
public:
   static int get_fd(std::filebuf *_buf)
   {
      FileBuffer *buf=static_cast<FileBuffer*>(_buf);
#if defined(__GNUC__) || defined(__COMO__)
      return buf->_M_file.fd();
#elif defined(__INTEL_COMPILER)
      return buf->fd();
#else
# error "don't know how to query the file descriptor"
#endif
   }
};

} // end namespace pm

#endif // _POLYMAKE_FSTREAM_H

// Local Variables:
// mode:C++
// End:
