Base: Add C++ iostate methods to Writer class

This commit is contained in:
wmayer
2025-03-12 18:47:50 +01:00
committed by Ladislav Michl
parent 2c2cdbfe7f
commit 2c3d9e2bb7
2 changed files with 53 additions and 0 deletions

View File

@@ -92,6 +92,31 @@ Writer::Writer()
Writer::~Writer() = default;
void Writer::clear()
{
Stream().clear();
}
bool Writer::isGood() const
{
return Stream().good();
}
bool Writer::hasFailed() const
{
return Stream().fail();
}
bool Writer::isBad() const
{
return Stream().bad();
}
bool Writer::isEof() const
{
return Stream().eof();
}
std::ostream& Writer::beginCharStream(CharStreamFormat format)
{
if (CharStream) {

View File

@@ -136,7 +136,22 @@ public:
void decInd();
//@}
/** @name C++ streams */
//@{
/// get the current indentation
virtual std::ostream& Stream() = 0;
virtual const std::ostream& Stream() const = 0;
/// Set error state flags
void clear();
/// Check whether state of stream is good
bool isGood() const;
/// Check whether either failbit or badbit is set
bool hasFailed() const;
/// Check whether badbit is set
bool isBad() const;
/// Check whether eofbit is set
bool isEof() const;
//@}
/** Create an output stream for storing character content
* The input is assumed to be valid character with
@@ -215,6 +230,11 @@ public:
return ZipStream;
}
const std::ostream& Stream() const override
{
return ZipStream;
}
void setComment(const char* str)
{
ZipStream.setComment(str);
@@ -248,6 +268,10 @@ public:
{
return StrStream;
}
const std::ostream& Stream() const override
{
return StrStream;
}
std::string getString() const
{
return StrStream.str();
@@ -277,6 +301,10 @@ public:
{
return FileStream;
}
const std::ostream& Stream() const override
{
return FileStream;
}
void close()
{
FileStream.close();