📄 file.3
字号:
File(3) File(3)NNAAMMEE File - Wrapper for stdio streamsSSYYNNOOPPSSIISS ##iinncclluuddee <<FFiillee..hh>>DDEESSCCRRIIPPTTIIOONN The FFiillee class provides a simple wrapper around stdio streams for use with C++. It provides two kinds of conve- nience: Firstly, constructors and destructors manage open- ing and closing of the stream. The stream is checked for errors on closing, and the default behavior is to exit() with an error message if a problem was found. Secondly, the getline() method can be used for line-oriented input. It strips comments and keeps track of input line numbers for error reporting.CCLLAASSSS MMEEMMBBEERRSS FFiillee((ccoonnsstt cchhaarr **_n_a_m_e,, ccoonnsstt cchhaarr **_m_o_d_e,, iinntt _e_x_i_t_O_n_E_r_r_o_r == 11)) FFiillee((FFIILLEE **_f_p == 00,, iinntt _e_x_i_t_O_n_E_r_r_o_r == 11)) A File object can be initialized with either a filename or an existing stdio stream. In the first case, the file is opened according to _m_o_d_e (as if by ffooppeenn(3)). The _e_x_i_t_O_n_E_r_r_o_r flag determines whether I/O errors should be treated as fatal. ~~FFiillee(()) Destroying a File object implies closing the asso- ciated stream. cchhaarr **ggeettlliinnee(()) Returns the next line from the input, stored in a static buffer of up to mmaaxxLLiinneeLLeennggtthh characters. Empty lines and lines starting with ## are skipped. iinntt cclloossee(()) Closes the stream without destroying the File object. Returns non-zero is an error condition occurs. iinntt eerrrroorr(()) Returns a non-zero value if an error condition occurred on the stream. ooppeerraattoorr FFIILLEE **(()) A File object can be cast to FFIILLEE ** to access the underlying stdio stream. oossttrreeaamm &&ppoossiittiioonn((oossttrreeaamm &&_s_t_r_e_a_m == cceerrrr)) Outputs the current line number on _s_t_r_e_a_m. The _s_t_r_e_a_m is returned so it can be used as the left operand of the <<<< operator. ccoonnsstt cchhaarr **nnaammee The filename used in creating the File object. ccoonnsstt uunnssiiggnneedd lliinneennoo The current line number as maintained by ggeettlliinnee(()). iinntt eexxiittOOnnEErrrroorr When set to ttrruuee this causes errors on the stream to be handled by program termination (after print- ing an error message).SSEEEE AALLSSOO stdio(3)BBUUGGSS Many other potentially useful functions are not provided (yet).AAUUTTHHOORR Andreas Stolcke <stolcke@speech.sri.com>. Copyright 1995, 1996 SRI InternationalSRILM $Date: 1996/07/17 01:39:25 $ File(3)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -