|
10837 | 10837 | These functions enable class \tcode{path} support for systems with a wide native path character type, such as \keyword{wchar_t}.
|
10838 | 10838 | \end{note}
|
10839 | 10839 |
|
| 10840 | +\rSec2[file.native]{Native handles} |
| 10841 | + |
| 10842 | +\indexlibraryglobal{native_handle_type}% |
| 10843 | + |
| 10844 | +\pnum |
| 10845 | +Several classes described in \ref{file.streams} |
| 10846 | +have a member \tcode{native_handle_type}. |
| 10847 | + |
| 10848 | +\pnum |
| 10849 | +The type \tcode{native_handle_type} represents a platform-specific |
| 10850 | +\defnadj{native}{handle} to a file. |
| 10851 | +It is trivially copyable and models \libconcept{semiregular}. |
| 10852 | + |
| 10853 | +\begin{note} |
| 10854 | +For operating systems based on POSIX, |
| 10855 | +\tcode{native_handle_type} is \keyword{int}. |
| 10856 | +For Windows-based operating systems, |
| 10857 | +\tcode{native_handle_type} is \tcode{HANDLE}. |
| 10858 | +\end{note} |
| 10859 | + |
10840 | 10860 | \rSec2[filebuf]{Class template \tcode{basic_filebuf}}
|
10841 | 10861 |
|
10842 | 10862 | \rSec3[filebuf.general]{General}
|
|
10852 | 10872 | using pos_type = typename traits::pos_type;
|
10853 | 10873 | using off_type = typename traits::off_type;
|
10854 | 10874 | using traits_type = traits;
|
| 10875 | + using native_handle_type = @\impdefx{type of \tcode{native_handle_type}}@; // see \ref{file.native} |
10855 | 10876 |
|
10856 | 10877 | // \ref{filebuf.cons}, constructors/destructor
|
10857 | 10878 | basic_filebuf();
|
|
10874 | 10895 | basic_filebuf* open(const filesystem::path& s,
|
10875 | 10896 | ios_base::openmode mode);
|
10876 | 10897 | basic_filebuf* close();
|
| 10898 | + native_handle_type native_handle() const noexcept; |
10877 | 10899 |
|
10878 | 10900 | protected:
|
10879 | 10901 | // \ref{filebuf.virtuals}, overridden virtual functions
|
|
10933 | 10955 | \tcode{fpos<traits::\brk{}state_type>}.
|
10934 | 10956 | Otherwise the behavior is undefined.
|
10935 | 10957 |
|
| 10958 | +\pnum |
| 10959 | +The file associated with a \tcode{basic_filebuf} has |
| 10960 | +an associated value of type \tcode{native_handle_type}, |
| 10961 | +called the native handle\iref{file.native} of that file. |
| 10962 | +This native handle can be obtained by calling |
| 10963 | +the member function \tcode{native_handle}. |
| 10964 | + |
| 10965 | +\pnum |
| 10966 | +For any opened \tcode{basic_filebuf f}, |
| 10967 | +the native handle returned by \tcode{f.native_handle()} is |
| 10968 | +invalidated when \tcode{f.close()} is called, or \tcode{f} is destroyed. |
| 10969 | + |
10936 | 10970 | \pnum
|
10937 | 10971 | In order to support file I/O and multibyte/wide character conversion,
|
10938 | 10972 | conversions are performed using members of a facet, referred to as
|
|
11226 | 11260 | on success, a null pointer otherwise.
|
11227 | 11261 | \end{itemdescr}
|
11228 | 11262 |
|
| 11263 | +\indexlibrarymember{native_handle}{basic_filebuf}% |
| 11264 | +\begin{itemdecl} |
| 11265 | +native_handle_type native_handle() const noexcept; |
| 11266 | +\end{itemdecl} |
| 11267 | + |
| 11268 | +\begin{itemdescr} |
| 11269 | +\pnum |
| 11270 | +\expects |
| 11271 | +\tcode{is_open()} is \tcode{true}. |
| 11272 | + |
| 11273 | +\pnum |
| 11274 | +\returns |
| 11275 | +The native handle associated with \tcode{*this}. |
| 11276 | +\end{itemdescr} |
| 11277 | + |
11229 | 11278 | \rSec3[filebuf.virtuals]{Overridden virtual functions}
|
11230 | 11279 |
|
11231 | 11280 | \indexlibrarymember{showmanyc}{basic_filebuf}%
|
|
11624 | 11673 | using pos_type = typename traits::pos_type;
|
11625 | 11674 | using off_type = typename traits::off_type;
|
11626 | 11675 | using traits_type = traits;
|
| 11676 | + using native_handle_type = typename basic_filebuf<charT, traits>::native_handle_type; |
11627 | 11677 |
|
11628 | 11678 | // \ref{ifstream.cons}, constructors
|
11629 | 11679 | basic_ifstream();
|
|
11646 | 11696 |
|
11647 | 11697 | // \ref{ifstream.members}, members
|
11648 | 11698 | basic_filebuf<charT, traits>* rdbuf() const;
|
| 11699 | + native_handle_type native_handle() const noexcept; |
11649 | 11700 |
|
11650 | 11701 | bool is_open() const;
|
11651 | 11702 | void open(const char* s, ios_base::openmode mode = ios_base::in);
|
|
11794 | 11845 | \tcode{const_cast<basic_filebuf<charT, traits>*>(addressof(sb))}.
|
11795 | 11846 | \end{itemdescr}
|
11796 | 11847 |
|
| 11848 | +\indexlibrarymember{native_handle}{basic_ifstream}% |
| 11849 | +\begin{itemdecl} |
| 11850 | +native_handle_type native_handle() const noexcept; |
| 11851 | +\end{itemdecl} |
| 11852 | + |
| 11853 | +\begin{itemdescr} |
| 11854 | +\pnum |
| 11855 | +\effects |
| 11856 | +Equivalent to: \tcode{return rdbuf()->native_handle();} |
| 11857 | +\end{itemdescr} |
| 11858 | + |
11797 | 11859 | \indexlibrarymember{is_open}{basic_ifstream}%
|
11798 | 11860 | \begin{itemdecl}
|
11799 | 11861 | bool is_open() const;
|
|
11870 | 11932 | using pos_type = typename traits::pos_type;
|
11871 | 11933 | using off_type = typename traits::off_type;
|
11872 | 11934 | using traits_type = traits;
|
| 11935 | + using native_handle_type = typename basic_filebuf<charT, traits>::native_handle_type; |
11873 | 11936 |
|
11874 | 11937 | // \ref{ofstream.cons}, constructors
|
11875 | 11938 | basic_ofstream();
|
|
11892 | 11955 |
|
11893 | 11956 | // \ref{ofstream.members}, members
|
11894 | 11957 | basic_filebuf<charT, traits>* rdbuf() const;
|
| 11958 | + native_handle_type native_handle() const noexcept; |
11895 | 11959 |
|
11896 | 11960 | bool is_open() const;
|
11897 | 11961 | void open(const char* s, ios_base::openmode mode = ios_base::out);
|
|
12040 | 12104 | \tcode{const_cast<basic_filebuf<charT, traits>*>(addressof(sb))}.
|
12041 | 12105 | \end{itemdescr}
|
12042 | 12106 |
|
| 12107 | +\indexlibrarymember{native_handle}{basic_ofstream}% |
| 12108 | +\begin{itemdecl} |
| 12109 | +native_handle_type native_handle() const noexcept; |
| 12110 | +\end{itemdecl} |
| 12111 | + |
| 12112 | +\begin{itemdescr} |
| 12113 | +\pnum |
| 12114 | +\effects |
| 12115 | +Equivalent to: \tcode{return rdbuf()->native_handle();} |
| 12116 | +\end{itemdescr} |
| 12117 | + |
12043 | 12118 | \indexlibrarymember{is_open}{basic_ofstream}%
|
12044 | 12119 | \begin{itemdecl}
|
12045 | 12120 | bool is_open() const;
|
|
12114 | 12189 | using pos_type = typename traits::pos_type;
|
12115 | 12190 | using off_type = typename traits::off_type;
|
12116 | 12191 | using traits_type = traits;
|
| 12192 | + using native_handle_type = typename basic_filebuf<charT, traits>::native_handle_type; |
12117 | 12193 |
|
12118 | 12194 | // \ref{fstream.cons}, constructors
|
12119 | 12195 | basic_fstream();
|
|
12139 | 12215 |
|
12140 | 12216 | // \ref{fstream.members}, members
|
12141 | 12217 | basic_filebuf<charT, traits>* rdbuf() const;
|
| 12218 | + native_handle_type native_handle() const noexcept; |
| 12219 | + |
12142 | 12220 | bool is_open() const;
|
12143 | 12221 | void open(
|
12144 | 12222 | const char* s,
|
|
12297 | 12375 | \tcode{const_cast<basic_filebuf<charT, traits>*>(addressof(sb))}.
|
12298 | 12376 | \end{itemdescr}
|
12299 | 12377 |
|
| 12378 | +\indexlibrarymember{native_handle}{basic_fstream}% |
| 12379 | +\begin{itemdecl} |
| 12380 | +native_handle_type native_handle() const noexcept; |
| 12381 | +\end{itemdecl} |
| 12382 | + |
| 12383 | +\begin{itemdescr} |
| 12384 | +\pnum |
| 12385 | +\effects |
| 12386 | +Equivalent to: \tcode{return rdbuf()->native_handle();} |
| 12387 | +\end{itemdescr} |
| 12388 | + |
12300 | 12389 | \indexlibrarymember{is_open}{basic_fstream}%
|
12301 | 12390 | \begin{itemdecl}
|
12302 | 12391 | bool is_open() const;
|
|
0 commit comments