mirror of
https://github.com/boostorg/filesystem.git
synced 2026-01-29 19:42:08 +00:00
134 lines
4.7 KiB
HTML
134 lines
4.7 KiB
HTML
<html>
|
|
|
|
<head>
|
|
<meta http-equiv="Content-Language" content="en-us">
|
|
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
|
|
<meta name="ProgId" content="FrontPage.Editor.Document">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
|
<title>Boost Filesystem fstream Header</title>
|
|
</head>
|
|
|
|
<body bgcolor="#FFFFFF">
|
|
|
|
<h1>
|
|
<img border="0" src="../../../boost.png" align="center" width="277" height="86"><a href="../../../boost/filesystem/fstream.hpp">boost/filesystem/fstream.hpp</a></h1>
|
|
|
|
<h2><a name="Introduction">Introduction</a></h2>
|
|
|
|
<p>The C++ Standard Library's <i><fstream></i> header uses <i>const char*</i> to
|
|
pass arguments representing file names, with that usage occurring seven
|
|
times.</p>
|
|
|
|
<p>The Filesystem Library's <i>fstream.hpp</i> header provides equivalent
|
|
components, in namespace <i>
|
|
boost::filesystem</i>, except that the seven functions taking <i>
|
|
const char*</i> arguments have been replaced by functions with
|
|
<a href="path.htm#basic_path">basic_path</a> arguments. A
|
|
<a href="operations.htm#Do-the-right-thing">"do-the-right-thing" rule</a>
|
|
applies, so that <i>path</i>, <i>wpath</i>, and user-defined <i>basic_path</i>'s
|
|
work appropriately. For ease of exposition, only the templated form is shown in
|
|
the following synopsis and documentation.</p>
|
|
|
|
<p>The Filesystem Library's <i>fstream.hpp</i> header simply uses the <i><fstream></i>
|
|
standard library components as base classes, and then redeclares constructors
|
|
and open functions to take arguments of type <i>const path&</i> instead of <i>
|
|
const char*</i>.</p>
|
|
|
|
<p>For documentation beyond the synopsis, see the
|
|
<a href="index.htm#tutorial">tutorial</a> and <a href="index.htm#Examples">
|
|
examples</a>.</p>
|
|
|
|
<h2><a name="Synopsis">Synopsis</a></h2>
|
|
<pre>namespace boost
|
|
{
|
|
namespace filesystem
|
|
{
|
|
template < class charT, class traits = std::char_traits<charT> >
|
|
class basic_filebuf : public std::basic_filebuf<charT,traits>
|
|
{
|
|
public:
|
|
virtual ~basic_filebuf() {}
|
|
|
|
template<class Path>
|
|
std::basic_filebuf<charT,traits> * open( const Path & file_ph,
|
|
std::ios_base::openmode mode );
|
|
};
|
|
|
|
typedef basic_filebuf<char> filebuf;
|
|
typedef basic_filebuf<wchar_t> wfilebuf;
|
|
|
|
template < class charT, class traits = std::char_traits<charT> >
|
|
class basic_ifstream : public std::basic_ifstream<charT,traits>
|
|
{
|
|
public:
|
|
basic_ifstream() {}
|
|
|
|
template<class Path>
|
|
explicit basic_ifstream( const Path & file_ph,
|
|
std::ios_base::openmode mode = std::ios_base::in );
|
|
|
|
virtual ~basic_ifstream() {}
|
|
|
|
template<class Path>
|
|
void open( const Path & file_ph,
|
|
std::ios_base::openmode mode = std::ios_base::in );
|
|
};
|
|
|
|
typedef basic_ifstream<char> ifstream;
|
|
typedef basic_ifstream<wchar_t> wifstream;
|
|
|
|
template < class charT, class traits = std::char_traits<charT> >
|
|
class basic_ofstream : public std::basic_ofstream<charT,traits>
|
|
{
|
|
public:
|
|
basic_ofstream() {}
|
|
|
|
template<class Path>
|
|
explicit basic_ofstream( const Path & file_ph,
|
|
std::ios_base::openmode mode = std::ios_base::out );
|
|
|
|
virtual ~basic_ofstream() {}
|
|
|
|
template<class Path>
|
|
void open( const Path & file_ph,
|
|
std::ios_base::openmode mode = std::ios_base::out );
|
|
};
|
|
|
|
typedef basic_ofstream<char> ofstream;
|
|
typedef basic_ofstream<wchar_t> wofstream;
|
|
|
|
template < class charT, class traits = std::char_traits<charT> >
|
|
class basic_fstream : public std::basic_fstream<charT,traits>
|
|
{
|
|
public:
|
|
basic_fstream() {}
|
|
|
|
template<class Path>
|
|
explicit basic_fstream( const Path & file_ph,
|
|
std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out );
|
|
|
|
virtual ~basic_fstream() {}
|
|
|
|
template<class Path>
|
|
void open( const Path & file_ph,
|
|
std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out );
|
|
};
|
|
|
|
typedef basic_fstream<char> fstream;
|
|
typedef basic_fstream<wchar_t> wfstream;
|
|
} // namespace filesystem
|
|
} // namespace boost
|
|
</pre>
|
|
<hr>
|
|
<p>Revised
|
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->27 June, 2005<!--webbot bot="Timestamp" endspan i-checksum="19924" --></p>
|
|
|
|
<p>© Copyright Beman Dawes, 2002</p>
|
|
<p> Use, modification, and distribution are subject to the Boost Software
|
|
License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt">
|
|
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
|
|
www.boost.org/LICENSE_1_0.txt</a>)</p>
|
|
|
|
</body>
|
|
|
|
</html> |