38 #ifndef RTSTREAMBUFS_HPP 39 #define RTSTREAMBUFS_HPP 58 virtual int sgetc() = 0;
59 virtual streamsize sgetn(
char* s, streamsize n ) = 0;
60 virtual int sputc(
char c) = 0;
61 virtual streamsize sputn(
const char* s, streamsize n ) = 0;
76 static const streamsize buf_size = 512;
78 stringbufs(
const std::string& c=
"") : _s(c), ptr(0), end(0) { _s.reserve( buf_size ); }
84 if ( _s.empty() || ptr == _s.length() )
return EOF;
88 virtual streamsize
sgetn(
char* s, streamsize n )
90 if ( _s.empty() || ptr == _s.length() )
return 0;
91 streamsize len = (n <= _s.length() ? n : _s.length() );
101 if ( ptr == _s.capacity() )
107 virtual streamsize
sputn(
const char* s, streamsize n )
110 if ( ptr == _s.capacity() )
118 return _s.substr(ptr, _s.length() - ptr);
121 void str( std::string& new_str )
137 void cleanup(
int free = 1)
139 if (ptr == _s.length() && !_s.empty() )
141 if ( ptr != 0 && _s.length() + free >= _s.capacity() )
164 virtual streamsize
sgetn(
char* , streamsize )
175 virtual streamsize
sputn(
const char* s, streamsize n )
streambufs::streamsize streamsize
virtual streamsize sgetn(char *, streamsize)
virtual int sputc(char c)
A base class for all stream buffer operations.
void str(std::string &new_str)
stringbufs(const std::string &c="")
streambufs::streamsize streamsize
virtual int sputc(char c)
virtual streamsize sputn(const char *s, streamsize n)
virtual streamsize sgetn(char *s, streamsize n)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
virtual streamsize sputn(const char *s, streamsize n)
A streambufs implementation based on strings.