/usr/include/sp/OutputCharStream.h is in libsp1-dev 1.3.4-1.2.1-47.3ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | // Copyright (c) 1994 James Clark
// See the file COPYING for copying permission.
#ifndef OutputCharStream_INCLUDED
#define OutputCharStream_INCLUDED 1
#include "types.h"
#include <stddef.h>
#include "StringC.h"
#include "Owner.h"
#include "CodingSystem.h"
#include "OutputByteStream.h"
#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif
class SP_API OutputCharStream {
public:
enum Newline { newline };
typedef void (*Escaper)(OutputCharStream &, Char);
OutputCharStream();
virtual ~OutputCharStream();
OutputCharStream &put(Char);
OutputCharStream &write(const Char *, size_t);
virtual void flush() = 0;
virtual void setEscaper(Escaper);
OutputCharStream &operator<<(char);
OutputCharStream &operator<<(const char *);
OutputCharStream &operator<<(const StringC &);
OutputCharStream &operator<<(unsigned long);
OutputCharStream &operator<<(int);
OutputCharStream &operator<<(Newline);
private:
OutputCharStream(const OutputCharStream &); // undefined
void operator=(const OutputCharStream &); // undefined
virtual void flushBuf(Char) = 0;
protected:
Char *ptr_;
Char *end_;
};
class SP_API EncodeOutputCharStream : public OutputCharStream,
private Encoder::Handler {
public:
EncodeOutputCharStream();
// the OutputByteStream will not be deleted
EncodeOutputCharStream(OutputByteStream *, const OutputCodingSystem *);
~EncodeOutputCharStream();
void open(OutputByteStream *, const OutputCodingSystem *);
void flush();
void setEscaper(Escaper);
private:
EncodeOutputCharStream(const EncodeOutputCharStream &); // undefined
void operator=(const EncodeOutputCharStream &); // undefined
EncodeOutputCharStream(OutputByteStream *, Encoder *);
void allocBuf(int bytesPerChar);
void flushBuf(Char);
void handleUnencodable(Char c, OutputByteStream *);
Char *buf_;
OutputByteStream *byteStream_;
Encoder *encoder_;
Owner<Encoder> ownedEncoder_;
Escaper escaper_;
};
class SP_API StrOutputCharStream : public OutputCharStream {
public:
StrOutputCharStream();
~StrOutputCharStream();
void extractString(StringC &);
void flush();
private:
void flushBuf(Char);
void sync(size_t);
StrOutputCharStream(const StrOutputCharStream &); // undefined
void operator=(const StrOutputCharStream &); // undefined
Char *buf_;
size_t bufSize_;
};
class SP_API RecordOutputCharStream : public OutputCharStream {
public:
RecordOutputCharStream(OutputCharStream *);
~RecordOutputCharStream();
void flush();
void setEscaper(Escaper);
private:
RecordOutputCharStream(const RecordOutputCharStream &); // undefined
void operator=(const RecordOutputCharStream &); // undefined
void flushBuf(Char);
void outputBuf();
OutputCharStream *os_;
enum { bufSize_ = 1024 };
Char buf_[bufSize_];
};
inline
OutputCharStream &OutputCharStream::put(Char c)
{
if (ptr_ < end_)
*ptr_++ = c;
else
flushBuf(c);
return *this;
}
inline
OutputCharStream &OutputCharStream::operator<<(char c)
{
return put(Char(c));
}
inline
OutputCharStream &OutputCharStream::operator<<(Newline)
{
put(Char(SP_LINE_TERM1));
#ifdef SP_LINE_TERM2
put(Char(SP_LINE_TERM2));
#endif
return *this;
}
inline
OutputCharStream &OutputCharStream::operator<<(const StringC &str)
{
return write(str.data(), str.size());
}
#ifdef SP_NAMESPACE
}
#endif
#endif /* not OutputCharStream_INCLUDED */
|