File-based source or sink (not both) for channels.
More...
#include <Stream.h>
File-based source or sink (not both) for channels.
Definition at line 142 of file Stream.h.
◆ FileStream()
ast::FileStream::FileStream |
( |
std::string const & |
path, |
|
|
bool |
doWrite = false |
|
) |
| |
|
inlineexplicit |
Construct a FileStream for reading or writing, but not both.
- Parameters
-
[in] | path | Path to file as a string |
[in] | doWrite | If true then write to the file, otherwise read from the file |
Definition at line 150 of file Stream.h.
151 auto mode = doWrite ? std::ios_base::out : std::ios_base::in;
152 auto fstreamPtr = std::make_shared<std::fstream>(path, mode);
155 os <<
"Failed to open file \"" << path <<
"\" for " << (doWrite ?
"writing" :
"reading");
◆ ~FileStream()
virtual ast::FileStream::~FileStream |
( |
| ) |
|
|
inlinevirtual |
◆ getIsFits()
bool ast::Stream::getIsFits |
( |
| ) |
const |
|
inlineinherited |
◆ getPath()
Get the path to the file, as a string.
Definition at line 168 of file Stream.h.
◆ hasStdStream()
bool ast::Stream::hasStdStream |
( |
| ) |
|
|
inlineinherited |
Return true if this Stream has an input or output std::stream.
Definition at line 73 of file Stream.h.
◆ setIsFits()
void ast::Stream::setIsFits |
( |
bool |
isFits | ) |
|
|
inlineprotectedinherited |
◆ sink()
bool ast::Stream::sink |
( |
char const * |
cstr | ) |
|
|
inlineinherited |
Sink (write) to the stream.
- Parameters
-
[in] | cstr | data to write; a newline is then written if _isFits false |
- Returns
- true on success or if there is no stream pointer (a normal mode), false if the stream pointer is in a bad state after writing
- Note
- this function is not virtual because of type slicing: this function is called from code that casts a void pointer to a Stream pointer without knowing which kind of Stream it is.
Definition at line 110 of file Stream.h.
112 (*_ostreamPtr) << cstr;
116 return static_cast<bool>(*_ostreamPtr);
◆ source()
char const* ast::Stream::source |
( |
| ) |
|
|
inlineinherited |
Source (read) from the stream.
- Returns
- the data read as a C string, or nullptr if there is no source stream or the source stream is empty or in an error state. The Stream owns the string buffer, and it will be invalidated on the next call to this function.
Definition at line 84 of file Stream.h.
◆ _isFits
bool ast::Stream::_isFits |
|
protectedinherited |
is this a FITS stream?
Definition at line 136 of file Stream.h.
◆ _istreamPtr
◆ _ostreamPtr
◆ _sourceStr
string containing a local copy of sourced data, so source can return a char *
that won't disappear right away
Definition at line 135 of file Stream.h.
The documentation for this class was generated from the following file:
- /j/snowflake/release/lsstsw/stack/1a1d771/Linux64/astshim/20.0.0/include/astshim/Stream.h