OpendTect
6.6
|
OD base class for stream read/write. More...
Public Types | |
typedef od_stream_Count | Count |
typedef od_stream_Pos | Pos |
enum | Ref { Abs , Rel , End } |
Public Member Functions | |
virtual | ~od_stream () |
void | addErrMsgTo (BufferString &) const |
void | addErrMsgTo (uiRetVal &) const |
void | addErrMsgTo (uiString &) const |
void | close () |
uiString | errMsg () const |
see also below. More... | |
const char * | fileName () const |
bool | forRead () const |
bool | forWrite () const |
bool | isBad () const |
eof is not Bad More... | |
bool | isLocal () const |
bool | isOK () const |
eof is not OK More... | |
Pos | position () const |
void | setFileName (const char *) |
void | setNoClose (bool yn=true) |
void | setPosition (Pos, Ref r=Abs) |
StreamData & | streamData () |
const StreamData & | streamData () const |
Static Public Member Functions | |
static od_stream * | create (const char *, bool forread, BufferString &errmsg) |
returns null on failure, never a bad stream More... | |
static od_stream * | create (const char *, bool forread, uiString &errmsg) |
returns null on failure, never a bad stream More... | |
static const char * | sStdErr () |
pass this as filename to get cerr More... | |
static const char * | sStdIO () |
pass this as filename to get cin or cout More... | |
Protected Member Functions | |
od_stream () | |
od_stream (const char *, bool, bool editmode=false) | |
od_stream (const FilePath &, bool, bool editmode=false) | |
od_stream (const OS::MachineCommand &, const char *workdir, bool editmode=false) | |
od_stream (std::istream &) | |
od_stream (std::istream *) | |
od_stream (std::ostream &) | |
od_stream (std::ostream *) | |
BufferString | noStdStreamPErrMsg () const |
od_stream & | operator= (const od_stream &)=delete |
Protected Attributes | |
uiString | errmsg_ |
bool | mine_ = true |
bool | noclose_ = false |
StreamData | sd_ |
Private Member Functions | |
bool | setFromCommand (const OS::MachineCommand &, const char *workdir, bool editmode) |
OD base class for stream read/write.
If the stream is owner of the std stream, then it will close it automatically when it goes out of scope (or is deleted). That means: except when you construct it with a std::[io]stream& . With that construction the od_stream is merely an adaptor. In all cases, the close() function is called automatically on destruction, but you can do it 'earlier' if you want.
As a result, copying a stream will transfer the stream to the copy, if the od_stream is owner. So unlike StreamData, you will then not have 2 od_streams pointing to the same std stream. In this way you can for example return an od_stream from a function.
Note the usage of the stream checking functions. There are only two left:
The difference is with end-of-file when reading. eof will not give you isBad(), but it will make the stream !isOK(). There is no difference for write.
Therefore, rule of thumb is: use isOK() for loop control, isBad() as a return value. If you know that the file should contain more data than the last read, then isOK() will be your choice anyway.
<>
typedef od_stream_Count od_stream::Count |
typedef od_stream_Pos od_stream::Pos |
enum od_stream::Ref |
|
virtual |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
void od_stream::addErrMsgTo | ( | BufferString & | ) | const |
void od_stream::addErrMsgTo | ( | uiRetVal & | ) | const |
void od_stream::addErrMsgTo | ( | uiString & | ) | const |
void od_stream::close | ( | ) |
|
static |
returns null on failure, never a bad stream
returns null on failure, never a bad stream
uiString od_stream::errMsg | ( | ) | const |
see also below.
const char* od_stream::fileName | ( | ) | const |
bool od_stream::forRead | ( | ) | const |
bool od_stream::forWrite | ( | ) | const |
bool od_stream::isBad | ( | ) | const |
eof is not Bad
bool od_stream::isLocal | ( | ) | const |
bool od_stream::isOK | ( | ) | const |
eof is not OK
|
protected |
Pos od_stream::position | ( | ) | const |
void od_stream::setFileName | ( | const char * | ) |
|
private |
|
inline |
|
static |
pass this as filename to get cerr
|
static |
pass this as filename to get cin or cout
|
inline |
|
inline |
|
mutableprotected |
|
protected |
|
protected |
|
protected |
Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2022