LSSTApplications
20.0.0
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
22 #ifndef ASTSHIM_SOURCESINK_H
23 #define ASTSHIM_SOURCESINK_H
112 (*_ostreamPtr) << cstr;
116 return static_cast<bool>(*_ostreamPtr);
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");
188 _istringstreamPtr = std::make_shared<std::istringstream>(
data);
189 _ostringstreamPtr = std::make_shared<std::ostringstream>();
204 _istringstreamPtr->
clear();
206 _ostringstreamPtr->
str(
"");
225 auto ssptr =
reinterpret_cast<Stream *
>(astChannelData);
239 inline void sink(
const char *cstr) {
240 auto ssptr =
reinterpret_cast<Stream *
>(astChannelData);
242 auto isok = ssptr->
sink(cstr);
244 astSetStatus(AST__ATGER);
File-based source or sink (not both) for channels.
char const * source()
Source (read) from the stream.
std::string _sourceStr
string containing a local copy of sourced data, so source can return a char * that won't disappear ri...
Stream(std::istream *istreamPtr, std::ostream *ostreamPtr)
Construct a Stream from input and output std::streams.
std::string getSinkData() const
Get a copy of the text from the sink/output stream, without changing the stream.
void setIsFits(bool isFits)
set isFits
bool sink(char const *cstr)
Sink (write) to the stream.
Channel provides input/output of AST objects.
A stream for ast::Channel.
std::string getSourceData() const
Get a copy of the text from the sink/output stream, without changing the stream.
const char * source()
Source function that allows astChannel to source from a Stream.
Stream & operator=(Stream &&)=default
Stream(Stream const &)=default
Stream & operator=(Stream const &)=default
String-based source and sink for channels.
Stream(Stream &&)=default
AST wrapper classes and functions.
bool hasStdStream()
Return true if this Stream has an input or output std::stream.
void sinkToSource()
Move output/sink data to input/source.
std::string getPath() const
Get the path to the file, as a string.
std::shared_ptr< std::istream > _istreamPtr
input stream
bool _isFits
is this a FITS stream?
FileStream(std::string const &path, bool doWrite=false)
Construct a FileStream for reading or writing, but not both.
std::shared_ptr< std::ostream > _ostreamPtr
output stream
void sink(const char *cstr)
Sink function that allows astChannel to sink to a Stream.
StringStream(std::string const &data="")
Construct a StringStream.
bool getIsFits() const
get isfits