📄 file.3
字号:
.\" $Id: File.3,v 1.1 1996/07/17 01:39:25 stolcke Exp $.TH File 3 "$Date: 1996/07/17 01:39:25 $" SRILM.SH NAMEFile \- Wrapper for stdio streams.SH SYNOPSIS.B "#include <File.h>".SH DESCRIPTIONThe.B Fileclass provides a simple wrapper around stdio streams for usewith C++.It provides two kinds of convenience:Firstly, constructors and destructors manage opening and closing of the stream.The stream is checked for errors on closing, and the default behavioris 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 linenumbers for error reporting..SH "CLASS MEMBERS".TP.B "File(const char *\fIname\fP, const char *\fImode\fP, int \fIexitOnError\fP = 1)".TP.B "File(FILE *\fIfp\fP = 0, int \fIexitOnError\fP = 1)"A File object can be initialized with either a filename or an existingstdio stream.In the first case, the file is opened according to \fImode\fP(as if by.BR fopen (3)).The \fIexitOnError\fP flag determines whether I/O errors should be treatedas fatal..TP.B ~File()Destroying a File object implies closing the associated stream..TP.B "char *getline()"Returns the next line from the input, stored in a static buffer of up to \fBmaxLineLength\fP characters.Empty lines and lines starting with \fB#\fP are skipped..TP.B "int close()"Closes the stream without destroying the File object.Returns non-zero is an error condition occurs..TP.B "int error()"Returns a non-zero value if an error condition occurred on the stream..TP.B "operator FILE *()"A File object can be cast to \fBFILE *\fP to access the underlying stdiostream..TP.B "ostream &position(ostream &\fIstream\fP = cerr)"Outputs the current line number on \fIstream\fP.The \fIstream\fP is returned so it can be used as the left operandof the \fB<<\fP operator..TP.B "const char *name"The filename used in creating the File object..TP.B "const unsigned lineno"The current line number as maintained by \fBgetline()\fP..TP.B "int exitOnError"When set to \fBtrue\fP this causes errors on thestream to be handled by program termination (after printing anerror message)..SH "SEE ALSO"stdio(3).SH BUGSMany other potentially useful functions are not provided (yet)..SH AUTHORAndreas Stolcke <stolcke@speech.sri.com>..brCopyright 1995, 1996 SRI International
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -