Evo C++ Library v0.5.1
|
#include <evo/file.h>
File I/O stream.
Public Types | |
typedef Stream< IoFile > | Base |
Base class alias. More... | |
typedef IoFile ::ExceptionInT | ExceptionInT |
Stream input exception type More... | |
typedef IoFile ::ExceptionOutT | ExceptionOutT |
Stream output exception type More... | |
typedef StreamFormatter< This > | Format |
Stream output formatter with state. More... | |
typedef IoFile ::Handle | Handle |
Low-level handle type (OS dependent) More... | |
typedef This | Out |
Type returned by write_out() More... | |
typedef ulong | Size |
Data size type (ulong) More... | |
typedef Stream< IoFile > | This |
This stream type. More... | |
Public Member Functions | |
File (Newline nl=NL_SYS, bool exceptions=1) | |
Constructor. More... | |
File (const char *path, Open mode=oREAD, bool flushlines=false, Newline nl=NL_SYS, bool exceptions=1) | |
Constructor to open file. More... | |
File (const char *path, Open mode, Newline nl, bool exceptions=1) | |
Constructor to open file and set default newline. More... | |
void | attach (Open mode, Handle handle, bool owned=true, bool flushlines=false) |
Attach existing stream. More... | |
RawBuffer & | bufread () |
Advanced: Access primary read buffer. More... | |
IoWriter & | bufwrite () |
Advanced: Access primary write buffer. More... | |
bool | close () |
Close stream. More... | |
Handle | detach () |
Detach current stream. More... | |
Error | error () const |
Get error code from last operation. More... | |
bool | excep () const |
Get whether exceptions are enabled. More... | |
void | excep (bool val) |
Set whether exceptions are enabled. More... | |
bool | flush () |
Flush any pending output in stream write buffer, if buffered. More... | |
Handle | handle () const |
Get stream handle for low-level calls. More... | |
bool | isopen () const |
Get whether stream is open. More... | |
bool | open (const char *path, Open mode=oREAD, bool flushlines=false) |
Open file for read and/or writing. More... | |
operator SafeBoolType () const | |
Safe (explicit) evaluation as bool type. More... | |
bool | operator! () const |
Negation operator checks whether an error was set by a previous operation. More... | |
This & | operator<< (This &) |
No-op used by formatting helpers. More... | |
This & | operator<< (Newline nl) |
Write an explicit newline and flush stream. More... | |
This & | operator<< (NewlineDefault nl) |
Write default newline and flush stream. More... | |
This & | operator<< (const NewlineValue &nl) |
Write newline value and flush stream. More... | |
This & | operator<< (Flush) |
Flush buffer by writing to stream. More... | |
This & | operator<< (bool val) |
Append a bool value to stream. More... | |
This & | operator<< (char ch) |
Write character to stream. More... | |
This & | operator<< (const char *str) |
Write terminated string to stream. More... | |
This & | operator<< (const SubString &str) |
Write substring to stream. More... | |
This & | operator<< (const ListBase< char, TSize > &str) |
Write substring to stream. More... | |
This & | operator<< (int num) |
Write formatted number to stream. More... | |
This & | operator<< (long num) |
Write formatted number to stream. More... | |
This & | operator<< (longl num) |
Write formatted number to stream. More... | |
This & | operator<< (uint num) |
Write formatted number to stream. More... | |
This & | operator<< (ulong num) |
Write formatted number to stream. More... | |
This & | operator<< (ulongl num) |
Write formatted number to stream. More... | |
This & | operator<< (const IntegerT< U > &num) |
Write formatted class number to stream. More... | |
This & | operator<< (float num) |
Write formatted floating-point number to stream. More... | |
This & | operator<< (double num) |
Write formatted floating-point number to stream. More... | |
This & | operator<< (ldouble num) |
Write formatted floating-point number to stream. More... | |
This & | operator<< (const FloatT< U > &num) |
Write formatted class floating-point number to stream. More... | |
This & | operator<< (const FmtChar &fmt) |
Write repeated character to stream. More... | |
This & | operator<< (const FmtString &fmt) |
Write formatted string field to stream. More... | |
This & | operator<< (const FmtShort &fmt) |
Write formatted number field to stream. More... | |
This & | operator<< (const FmtInt &fmt) |
Write formatted number field to stream. More... | |
This & | operator<< (const FmtLong &fmt) |
Write formatted number field to stream. More... | |
This & | operator<< (const FmtLongL &fmt) |
Write formatted number field to stream. More... | |
This & | operator<< (const FmtUShort &fmt) |
Write formatted number field to stream. More... | |
This & | operator<< (const FmtUInt &fmt) |
Write formatted number field to stream. More... | |
This & | operator<< (const FmtULong &fmt) |
Write formatted number field to stream. More... | |
This & | operator<< (const FmtULongL &fmt) |
Write formatted number field to stream. More... | |
This & | operator<< (const FmtFloat &fmt) |
Write formatted number field to stream. More... | |
This & | operator<< (const FmtFloatD &fmt) |
Write formatted number field to stream. More... | |
This & | operator<< (const FmtFloatL &fmt) |
Write formatted number field to stream. More... | |
This & | operator<< (const FmtFieldNum< U > &fmt) |
Write formatted number field to stream. More... | |
This & | operator<< (const FmtFieldFloat< U > &fmt) |
Write formatted number field to stream. More... | |
This & | operator<< (const FmtPtr &fmtptr) |
Writer formatted pointer field to stream. More... | |
This & | operator<< (const FmtDump &fmt) |
Write formatted data dump to stream. More... | |
ulongl | pos () |
Get current file position. More... | |
ulong | readbin (void *buf, ulong size) |
Read binary input from stream. More... | |
bool | readline (String &str, ulong maxlen=0) |
Read text line input from stream. More... | |
ulong | readtext (char *buf, ulong size) |
Read text input from stream. More... | |
ulongl | seek (ulongl offset, Seek start=sBegin) |
Seek to file position. More... | |
char * | write_direct (Size size) |
Get pointer for writing directly to buffer to append data. More... | |
bool | write_direct_finish (Size size) |
Finish writing directly to buffer. More... | |
char * | write_direct_flush (Size &available, Size written_size, Size reserve_size) |
char * | write_direct_multi (Size &available, Size reserve_size) |
Out & | write_out () |
ulong | writebin (const void *buf, ulong size) |
Write binary output to stream. More... | |
ulong | writechar (char ch, ulong count=1) |
Write repeat character as text output to stream. More... | |
bool | writefmtchar (char ch, ulong count, const FmtSetField &field) |
Write formatted and/or repeated character. More... | |
bool | writefmtdump (const FmtDump &fmt) |
Write formatted data dump. More... | |
bool | writefmtdump (const FmtDump &fmt, Newline nl) |
Write formatted data dump with explicit newline type. More... | |
bool | writefmtnum (TNum num, const FmtSetInt &fmt, const FmtSetField *field=NULL) |
Write formatted signed number with field alignment. More... | |
bool | writefmtnumf (TNum num, const FmtSetFloat &fmt, const FmtSetField *field=NULL) |
Write formatted floating point number with field alignment. More... | |
bool | writefmtnumu (TNum num, const FmtSetInt &fmt, const FmtSetField *field=NULL) |
Write formatted unsigned number with field alignment. More... | |
bool | writefmtstr (const char *buf, ulong size, const FmtSetField &field) |
Write text with field alignment. More... | |
ulong | writeline (const char *buf, ulong size) |
Write text line output to stream. More... | |
bool | writenum (TNum num, int base=fDEC) |
Write formatted signed number. More... | |
bool | writenumf (TNum num, int precision=fPREC_AUTO) |
Write formatted floating-point number. More... | |
bool | writenumu (TNum num, int base=fDEC) |
Write formatted unsigned number. More... | |
Size | writequoted (const char *buf, Size size, char delim, bool optional=false) |
Write quoted text output to string. More... | |
ulong | writetext (const char *buf, ulong size) |
Write text output to stream. More... | |
Protected Types | |
enum | RwLast |
Current read/write mode. More... | |
Protected Member Functions | |
void | init (Open mode, bool flushlines=false) |
Initialize and reset buffers for a new stream. More... | |
Protected Attributes | |
IoReader | bufrd_ |
Buffered reader. More... | |
IoWriter | bufwr_ |
Buffered writer. More... | |
IoFile | device_ |
I/O device. More... | |
Error | error_ |
Last error code. More... | |
bool | excep_ |
Whether to throw exceptions. More... | |
bool | owned_ |
Whether handle is owned (to be closed here) More... | |
RwLast | rwlast_ |
Read/Write: Used to track last operation when switching between read/write. More... | |
ulongl | savepos_ |
Read/Write: Used to save buffered read position when switching between read/write. More... | |
|
inherited |
Stream input exception type
|
inherited |
Stream output exception type
|
inherited |
Stream output formatter with state.
Example using File:
Example using Console (stdout):
For more examples see: Stream Formatting
Type returned by write_out()
|
inherited |
Data size type (ulong)
|
protectedinherited |
Current read/write mode.
Constructor.
nl | Default newline value to use for text reads/writes |
exceptions | Whether to enable exceptions on error, default set by Evo config: EVO_EXCEPTIONS |
|
inline |
Constructor to open file.
path | File path to use |
mode | Access mode to use |
flushlines | Whether to flush text output on newlines (line buffering) |
nl | Default newline value to use for text reads/writes |
exceptions | Whether to enable exceptions on error, default set by Evo config: EVO_EXCEPTIONS |
Constructor to open file and set default newline.
path | File path to use |
mode | Access mode to use |
nl | Default newline value to use for text reads/writes |
exceptions | Whether to enable exceptions on error, default set by Evo config: EVO_EXCEPTIONS |
|
inlineinherited |
Attach existing stream.
mode | Access mode to use (oREAD, oREAD_WRITE, or oWRITE), must be correct for handle |
handle | Handle to attach, must be valid |
owned | Whether to take ownership and close handle, false detaches on close() |
flushlines | Whether to flush text output on newlines (line buffering) |
|
inlineinherited |
Advanced: Access primary read buffer.
|
inlineinherited |
Advanced: Access primary write buffer.
|
inlineinherited |
Close stream.
|
inlineinherited |
Detach current stream.
|
inlineinherited |
Get error code from last operation.
|
inlineinherited |
Get whether exceptions are enabled.
|
inlineinherited |
Set whether exceptions are enabled.
val | Whether to enable exceptions |
|
inlinevirtualinherited |
|
inlineinherited |
Get stream handle for low-level calls.
|
inlineprotectedinherited |
Initialize and reset buffers for a new stream.
|
inlinevirtualinherited |
Open file for read and/or writing.
path | File path to use |
mode | Access mode to use |
flushlines | Whether to flush text output on newlines (line buffering) |
|
inlineinherited |
Safe (explicit) evaluation as bool type.
|
inlineinherited |
|
inlineinherited |
Write default newline and flush stream.
nl | Default newline value (NL), where default is set by the stream |
|
inlineinherited |
Write newline value and flush stream.
nl | Newline value to use, use current stream default if null |
Flush buffer by writing to stream.
|
inlineinherited |
Append a bool value to stream.
val | Bool value to append |
|
inlineinherited |
|
inlineinherited |
Write terminated string to stream.
str | String to write, must be terminated |
Write substring to stream.
TSize | List size type (inferred from parameter) |
str | Substring to write |
|
inlineinherited |
Write formatted number to stream.
num | Number to format and write |
|
inlineinherited |
Write formatted number to stream.
num | Number to format and write |
|
inlineinherited |
Write formatted number to stream.
num | Number to format and write |
|
inlineinherited |
Write formatted number to stream.
num | Number to format and write |
|
inlineinherited |
Write formatted number to stream.
num | Number to format and write |
|
inlineinherited |
Write formatted number to stream.
num | Number to format and write |
Write formatted class number to stream.
U | Number class type (Int, Uint, etc) |
num | Number to format and write, no-op if null |
|
inlineinherited |
Write formatted floating-point number to stream.
num | Number to format and write |
|
inlineinherited |
Write formatted floating-point number to stream.
num | Number to format and write |
|
inlineinherited |
Write formatted floating-point number to stream.
num | Number to format and write |
Write formatted class floating-point number to stream.
U | Number class type (Float, FloatD, etc) |
num | Number to format and write, no-op if null |
Write repeated character to stream.
fmt | Character info |
Write formatted string field to stream.
fmt | String info |
Write formatted number field to stream.
fmt | Number info |
Write formatted number field to stream.
fmt | Number info |
Write formatted number field to stream.
fmt | Number info |
Write formatted number field to stream.
fmt | Number info |
Write formatted number field to stream.
fmt | Number info |
Write formatted number field to stream.
fmt | Number info |
Write formatted number field to stream.
fmt | Number info |
Write formatted number field to stream.
fmt | Number info |
Write formatted number field to stream.
fmt | Number info |
Write formatted number field to stream.
fmt | Number info |
Write formatted number field to stream.
fmt | Number info |
|
inlineinherited |
Write formatted number field to stream.
fmt | Number info |
|
inlineinherited |
Write formatted number field to stream.
fmt | Number info |
Writer formatted pointer field to stream.
fmtptr | Pointer info |
Write formatted data dump to stream.
fmt | Dump info |
|
inline |
|
inlinevirtualinherited |
Read binary input from stream.
buf | Buffer to store data read |
size | Size to read |
Reimplemented from IoBase.
|
inlinevirtualinherited |
Read text line input from stream.
str | String to store line (cleared first) [out] |
maxlen | Maximum line length, 0 for no limit |
Reimplemented from StreamBase.
|
inlinevirtualinherited |
Read text input from stream.
buf | Buffer to store data read |
size | Size in bytes to read from file (must be positive) |
Reimplemented from StreamBase.
Seek to file position.
offset | Offset from start to seek to |
start | Start position to seek from |
|
inlinevirtualinherited |
Get pointer for writing directly to buffer to append data.
size | Requred size in bytes to reserve |
Reimplemented from StreamBase.
|
inlinevirtualinherited |
Finish writing directly to buffer.
size | Size written in bytes, must not be greater than size passed to write_direct() |
Reimplemented from StreamBase.
|
inlineinherited |
|
inlinevirtualinherited |
Write binary output to stream.
buf | Data to write |
size | Size to write |
Reimplemented from IoBase.
|
inlinevirtualinherited |
Write repeat character as text output to stream.
ch | Character to write |
count | Character count to write, must be positive |
Reimplemented from StreamBase.
|
inlineinherited |
Write formatted and/or repeated character.
ch | Character to write |
count | Character repeat count to use |
field | Field attributes to use |
|
inlineinherited |
Write formatted data dump.
fmt | Format data, including buffer to dump |
Write formatted data dump with explicit newline type.
fmt | Format data, including buffer to dump |
nl | Newline type to use, NL for current default or NL_SYS for system default |
|
inlineinherited |
Write formatted signed number with field alignment.
TNum | Number type, inferred by param |
num | Number to write |
fmt | Integer formatting attributes to use |
field | Field formatting attributes to use, NULL for none |
|
inlineinherited |
Write formatted floating point number with field alignment.
TNum | Number type, inferred by param |
num | Number to write |
fmt | Floating point formatting attributes to use |
field | Field formatting attributes to use, NULL for none |
|
inlineinherited |
Write formatted unsigned number with field alignment.
TNum | Number type, inferred by param |
num | Number to write |
fmt | Integer formatting attributes to use |
field | Field formatting attributes to use, NULL for none |
|
inlineinherited |
Write text with field alignment.
buf | Buffer to write from |
size | Size to write in bytes |
field | Field attributes to use |
|
inlinevirtualinherited |
Write text line output to stream.
buf | Data buffer to write from |
size | Data size to write in bytes, must be positive |
Reimplemented from StreamBase.
|
inlineinherited |
Write formatted signed number.
TNum | Number type, inferred by param |
num | Number to write |
base | Base to use for formatting |
|
inlineinherited |
Write formatted floating-point number.
TNum | Number type, inferred by param |
num | Number to write |
precision | Formatting precision (number of fractional digits), 0 for none, fPREC_AUTO for automatic |
|
inlineinherited |
Write formatted unsigned number.
TNum | Number type, inferred by param |
num | Number to write |
base | Base to use for formatting |
|
inlinevirtualinherited |
Write quoted text output to string.
buf | Data to quote and write |
size | Data size to write |
delim | Delimiter for next field to escape via quoting |
optional | Whether quoting is optional, true to avoid quoting if possible |
Reimplemented from StreamBase.
|
inlinevirtualinherited |
Write text output to stream.
buf | Data to write |
size | Size to write |
Reimplemented from StreamBase.
|
protectedinherited |
Buffered reader.
|
protectedinherited |
Buffered writer.
|
protectedinherited |
I/O device.
|
protectedinherited |
Last error code.
|
protectedinherited |
Whether to throw exceptions.
|
protectedinherited |
Whether handle is owned (to be closed here)
|
protectedinherited |
Read/Write: Used to track last operation when switching between read/write.
|
protectedinherited |
Read/Write: Used to save buffered read position when switching between read/write.