File: fstream.htm

package info (click to toggle)
boost 1.33.1-10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 100,948 kB
  • ctags: 145,103
  • sloc: cpp: 573,492; xml: 49,055; python: 15,626; ansic: 13,588; sh: 2,099; yacc: 858; makefile: 660; perl: 427; lex: 111; csh: 6
file content (113 lines) | stat: -rw-r--r-- 4,207 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<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>&lt;fstream&gt;</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&nbsp; <i>
const char*</i> arguments have been replaced by <i>const path&amp;</i> arguments.</p>

<p>The Filesystem Library's <i>fstream.hpp</i> header simply uses the <i>&lt;fstream&gt;</i> 
standard library components as base classes, and then redeclares constructors 
and open functions to take arguments of type <i>const path&amp;</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 &lt; class charT, class traits = std::char_traits&lt;charT&gt; &gt;
    class basic_filebuf : public std::basic_filebuf&lt;charT,traits&gt;
    {
    public:
      virtual ~basic_filebuf() {}

      std::basic_filebuf&lt;charT,traits&gt; * open( const path &amp; file_ph,
        std::ios_base::openmode mode );
    };

    typedef basic_filebuf&lt;char&gt; filebuf;
    typedef basic_filebuf&lt;wchar_t&gt; wfilebuf;

    template &lt; class charT, class traits = std::char_traits&lt;charT&gt; &gt;
    class basic_ifstream : public std::basic_ifstream&lt;charT,traits&gt;
    {
    public:
      basic_ifstream() {}
      explicit basic_ifstream( const path &amp; file_ph,
        std::ios_base::openmode mode = std::ios_base::in );
      virtual ~basic_ifstream() {}
      void open( const path &amp; file_ph,
        std::ios_base::openmode mode = std::ios_base::in );
    };

    typedef basic_ifstream&lt;char&gt; ifstream;
    typedef basic_ifstream&lt;wchar_t&gt; wifstream;

    template &lt; class charT, class traits = std::char_traits&lt;charT&gt; &gt;
    class basic_ofstream : public std::basic_ofstream&lt;charT,traits&gt;
    {
    public:
      basic_ofstream() {}
      explicit basic_ofstream( const path &amp; file_ph,
        std::ios_base::openmode mode = std::ios_base::out );
      virtual ~basic_ofstream() {}
      void open( const path &amp; file_ph,
        std::ios_base::openmode mode = std::ios_base::out );
    };

    typedef basic_ofstream&lt;char&gt; ofstream;
    typedef basic_ofstream&lt;wchar_t&gt; wofstream;

    template &lt; class charT, class traits = std::char_traits&lt;charT&gt; &gt;
    class basic_fstream : public std::basic_fstream&lt;charT,traits&gt;
    {
    public:
      basic_fstream() {}
      explicit basic_fstream( const path &amp; file_ph,
        std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out );
      virtual ~basic_fstream() {}
      void open( const path &amp; file_ph,
        std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out );
    };
 
    typedef basic_fstream&lt;char&gt; fstream;
    typedef basic_fstream&lt;wchar_t&gt; wfstream;
  } // namespace filesystem
} // namespace boost
</pre>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->12 March, 2004<!--webbot bot="Timestamp" endspan i-checksum="28865" --></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>