93 mstream(
const std::string &myname=
"") : name(myname) {};
103 virtual bool valid(
void) {
return false; };
106 inline operator bool(
void) {
return valid(); };
109 virtual bool eof(
void) {
return true; };
112 virtual std::string
errmsg(
void) {
113 return std::string(
valid() ?
"" :
"Invalid stream");
121 virtual bool reopen(
void) {
return true; };
124 virtual bool close(
void) {
return true; };
154 virtual int getbyte(
void) {
return EOF; }
158 virtual ByteCount read(
char *buf,
size_t n) {
161 for (c = this->getbyte(); nread < n && c != EOF; nread++, c = this->getbyte()) {
164 return static_cast<ByteCount
>(nread);
172 virtual ByteCount
getline(std::string &s,
const std::string &delim=
"\n\r") {
176 for (c = this->getbyte(); c != EOF; nread++, c = this->getbyte()) {
177 s.push_back(static_cast<char>(c));
178 if (delim.find(c) != delim.npos)
break;
180 return nread ? nread : EOF;
211 virtual bool flush(
void) {
return false; };
214 virtual bool write(
const char *buf,
size_t n) {
return false; };
220 virtual bool putbyte(
unsigned char c) {
return false; };
223 virtual bool puts(
const char *s) {
return false; };
226 virtual bool puts(
const std::string &s) {
return false; };
232 virtual bool vprintf(
const char *fmt, va_list &ap);
238 inline bool printf(
const char *fmt, ...) {
241 bool rc = this->vprintf(fmt,ap);
virtual bool eof(void)
Definition: mootIO.h:105
virtual bool close(void)
Definition: mootIO.h:120
Abstract base class for output stream wrappers.
Definition: mootIO.h:194
Abstract base class for I/O stream wrappers.
Definition: mootIO.h:80
std::string name
symbolic name of this stream
Definition: mootIO.h:82
mstream(const std::string &myname="")
Definition: mootIO.h:89
moot::OffsetT ByteOffset
typedef for (byte) offsets (may be unsigned)
Definition: mootIO.h:55
Namespace for I/O stream wrappers.
Definition: mootBufferIO.h:45
virtual bool valid(void)
Definition: mootIO.h:99
virtual ByteCount getline(std::string &s, const std::string &delim="\")
Definition: mootIO.h:172
virtual bool reopen(void)
Definition: mootIO.h:117
Common typedefs and constants.
virtual std::string errmsg(void)
Definition: mootIO.h:108
int ByteCount
typedef for byte counts (should be signed, for compatibility)
Definition: mootIO.h:52
long unsigned int OffsetT
Definition: mootTypes.h:70
virtual ~mstream(void)
Definition: mootIO.h:92
Abstract base class for input stream wrappers.
Definition: mootIO.h:129