#ifndef H_CORAL_LIB_FDSTREAMBUF
#define H_CORAL_LIB_FDSTREAMBUF
// This file is part of the Coral project.
// Please read the copyright notice in the LICENSE file.

#include <streambuf>
#include <memory>

namespace coral {
	/*
	 * Usage:
	 * std::auto_ptr<std::streambuf<char> >
	 *  buf(coral::ofdstreambuf(fd));
	 * std::ostream out(buf.get());
	 */
	/**
	 * Opens an output stream for the given filedescriptor @fd
	 * Closes fd on error.
	 */
	std::auto_ptr<std::streambuf> ofdstreambuf(int fd);
	/**
	 * Opens an input stream for the given filedescriptor @fd
	 * Closes fd on error.
	 */
	std::auto_ptr<std::streambuf> ifdstreambuf(int fd);
	/**
	 * Opens an input/output stream for the given filedescriptor @fd
	 * Closes fd on error.
	 */
	std::auto_ptr<std::streambuf> iofdstreambuf(int fd);
}

#endif
