1 // Copyright (c) 1997 James Clark
2 // See the file COPYING for copying permission.
4 #ifndef OutputByteStream_INCLUDED
5 #define OutputByteStream_INCLUDED 1
12 namespace SP_NAMESPACE {
15 class SP_API OutputByteStream : public Link {
18 virtual ~OutputByteStream();
19 virtual void flush() = 0;
21 void sputn(const char *, size_t);
22 OutputByteStream &operator<<(char);
23 OutputByteStream &operator<<(unsigned char);
24 OutputByteStream &operator<<(const char *);
25 OutputByteStream &operator<<(int);
26 OutputByteStream &operator<<(unsigned);
27 OutputByteStream &operator<<(long);
28 OutputByteStream &operator<<(unsigned long);
29 OutputByteStream &operator<<(const String<char> &);
30 char *getBufferPtr() const;
31 size_t getBufferSize() const;
32 void usedBuffer(size_t);
33 virtual void flushBuf(char) = 0;
40 char *OutputByteStream::getBufferPtr() const
46 size_t OutputByteStream::getBufferSize() const
52 void OutputByteStream::usedBuffer(size_t n)
58 void OutputByteStream::sputc(char c)
67 OutputByteStream &OutputByteStream::operator<<(char c)
74 OutputByteStream &OutputByteStream::operator<<(unsigned char c)
81 OutputByteStream &OutputByteStream::operator<<(int n)
83 return *this << long(n);
87 OutputByteStream &OutputByteStream::operator<<(unsigned n)
89 return *this << (unsigned long)n;
93 OutputByteStream &OutputByteStream::operator<<(const String<char> &s)
95 sputn(s.data(), s.size());
99 class SP_API StrOutputByteStream : public OutputByteStream {
101 StrOutputByteStream();
102 virtual ~StrOutputByteStream() { /* no-op */ };
103 void extractString(String<char> &);
105 StrOutputByteStream(const StrOutputByteStream &); // undefined
106 void operator=(const StrOutputByteStream &); // undefined
112 class SP_API FileOutputByteStream : public OutputByteStream {
114 FileOutputByteStream();
115 FileOutputByteStream(int fd, Boolean closeFd = 1);
116 virtual ~FileOutputByteStream();
117 #ifdef SP_WIDE_SYSTEM
118 Boolean open(const wchar_t *);
120 Boolean open(const char *);
122 Boolean attach(int fd, Boolean closeFd = 1);
125 FileOutputByteStream(const FileOutputByteStream &); // undefined
126 void operator=(const FileOutputByteStream &); // undefined
138 #endif /* not OutputByteStream_INCLUDED */