1 | <html> |
---|
2 | |
---|
3 | <head> |
---|
4 | <meta http-equiv="Content-Language" content="en-us"> |
---|
5 | <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> |
---|
6 | <meta name="ProgId" content="FrontPage.Editor.Document"> |
---|
7 | <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> |
---|
8 | <title>Boost Filesystem fstream Header</title> |
---|
9 | </head> |
---|
10 | |
---|
11 | <body bgcolor="#FFFFFF"> |
---|
12 | |
---|
13 | <h1> |
---|
14 | <img border="0" src="../../../boost.png" align="center" width="277" height="86"><a href="../../../boost/filesystem/fstream.hpp">boost/filesystem/fstream.hpp</a></h1> |
---|
15 | |
---|
16 | <h2><a name="Introduction">Introduction</a></h2> |
---|
17 | |
---|
18 | <p>The C++ Standard Library's <i><fstream></i> header uses <i>const char*</i> to |
---|
19 | pass arguments representing file names, with that usage occurring seven |
---|
20 | times.</p> |
---|
21 | |
---|
22 | <p>The Filesystem Library's <i>fstream.hpp</i> header provides equivalent |
---|
23 | components, in namespace <i> |
---|
24 | boost::filesystem</i>, except that the seven <i> |
---|
25 | const char*</i> arguments have been replaced by <i>const path&</i> arguments.</p> |
---|
26 | |
---|
27 | <p>The Filesystem Library's <i>fstream.hpp</i> header simply uses the <i><fstream></i> |
---|
28 | standard library components as base classes, and then redeclares constructors |
---|
29 | and open functions to take arguments of type <i>const path&</i> instead of <i> |
---|
30 | const char*</i>.</p> |
---|
31 | |
---|
32 | <p>For documentation beyond the synopsis, see the |
---|
33 | <a href="index.htm#tutorial">tutorial</a> and <a href="index.htm#Examples"> |
---|
34 | examples</a>.</p> |
---|
35 | |
---|
36 | <h2><a name="Synopsis">Synopsis</a></h2> |
---|
37 | <pre>namespace boost |
---|
38 | { |
---|
39 | namespace filesystem |
---|
40 | { |
---|
41 | template < class charT, class traits = std::char_traits<charT> > |
---|
42 | class basic_filebuf : public std::basic_filebuf<charT,traits> |
---|
43 | { |
---|
44 | public: |
---|
45 | virtual ~basic_filebuf() {} |
---|
46 | |
---|
47 | std::basic_filebuf<charT,traits> * open( const path & file_ph, |
---|
48 | std::ios_base::openmode mode ); |
---|
49 | }; |
---|
50 | |
---|
51 | typedef basic_filebuf<char> filebuf; |
---|
52 | typedef basic_filebuf<wchar_t> wfilebuf; |
---|
53 | |
---|
54 | template < class charT, class traits = std::char_traits<charT> > |
---|
55 | class basic_ifstream : public std::basic_ifstream<charT,traits> |
---|
56 | { |
---|
57 | public: |
---|
58 | basic_ifstream() {} |
---|
59 | explicit basic_ifstream( const path & file_ph, |
---|
60 | std::ios_base::openmode mode = std::ios_base::in ); |
---|
61 | virtual ~basic_ifstream() {} |
---|
62 | void open( const path & file_ph, |
---|
63 | std::ios_base::openmode mode = std::ios_base::in ); |
---|
64 | }; |
---|
65 | |
---|
66 | typedef basic_ifstream<char> ifstream; |
---|
67 | typedef basic_ifstream<wchar_t> wifstream; |
---|
68 | |
---|
69 | template < class charT, class traits = std::char_traits<charT> > |
---|
70 | class basic_ofstream : public std::basic_ofstream<charT,traits> |
---|
71 | { |
---|
72 | public: |
---|
73 | basic_ofstream() {} |
---|
74 | explicit basic_ofstream( const path & file_ph, |
---|
75 | std::ios_base::openmode mode = std::ios_base::out ); |
---|
76 | virtual ~basic_ofstream() {} |
---|
77 | void open( const path & file_ph, |
---|
78 | std::ios_base::openmode mode = std::ios_base::out ); |
---|
79 | }; |
---|
80 | |
---|
81 | typedef basic_ofstream<char> ofstream; |
---|
82 | typedef basic_ofstream<wchar_t> wofstream; |
---|
83 | |
---|
84 | template < class charT, class traits = std::char_traits<charT> > |
---|
85 | class basic_fstream : public std::basic_fstream<charT,traits> |
---|
86 | { |
---|
87 | public: |
---|
88 | basic_fstream() {} |
---|
89 | explicit basic_fstream( const path & file_ph, |
---|
90 | std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out ); |
---|
91 | virtual ~basic_fstream() {} |
---|
92 | void open( const path & file_ph, |
---|
93 | std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out ); |
---|
94 | }; |
---|
95 | |
---|
96 | typedef basic_fstream<char> fstream; |
---|
97 | typedef basic_fstream<wchar_t> wfstream; |
---|
98 | } // namespace filesystem |
---|
99 | } // namespace boost |
---|
100 | </pre> |
---|
101 | <hr> |
---|
102 | <p>Revised |
---|
103 | <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->12 March, 2004<!--webbot bot="Timestamp" endspan i-checksum="28865" --></p> |
---|
104 | |
---|
105 | <p>© Copyright Beman Dawes, 2002</p> |
---|
106 | <p> Use, modification, and distribution are subject to the Boost Software |
---|
107 | License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt"> |
---|
108 | LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt"> |
---|
109 | www.boost.org/LICENSE_1_0.txt</a>)</p> |
---|
110 | |
---|
111 | </body> |
---|
112 | |
---|
113 | </html> |
---|