/usr/include/dlib/sockstreambuf/sockstreambuf_unbuffered.h is in libdlib-dev 18.18-1.
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 | // Copyright (C) 2003 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_SOCKSTrEAMBUF_UNBUFFERED_Hh_
#define DLIB_SOCKSTrEAMBUF_UNBUFFERED_Hh_
#include <iosfwd>
#include <streambuf>
#include "../sockets.h"
#include "sockstreambuf_abstract.h"
namespace dlib
{
// ----------------------------------------------------------------------------------------
class sockstreambuf_unbuffered : public std::streambuf
{
/*!
WHAT THIS OBJECT REPRESENTS
This is an implementation of the interface defined in
sockstreambuf_abstract.h except that it doesn't do any kind of buffering at
all. It just writes data directly to a connection. However, note that we
don't implement the flushes_output_on_read() routine as this object always
flushes immediately (since it isn't buffers. Moreover, it should be
pointed out that this object is deprecated and only present for backwards
compatibility with previous versions of dlib. So you really should use the
sockstreambuf object instead.
INITIAL VALUE
con == a connection
lastread_next == false
peek == EOF
CONVENTION
if (peek != EOF) then
peek == the last character read from the connection object and
is used to store the char in the event the user peeks by
calling sgetc()
if (lastread != EOF) then
lastread == the last character read and consumed by the user
if (lastread_next) then
the next character to be returned to the user is lastread because
the user put it back into the buffer
!*/
public:
sockstreambuf_unbuffered (
connection* con_
) :
con(*con_),
peek(EOF),
lastread_next(false)
{}
sockstreambuf_unbuffered (
const scoped_ptr<connection>& con_
) :
con(*con_),
peek(EOF),
lastread_next(false)
{}
connection* get_connection (
) { return &con; }
protected:
// output functions
int_type overflow (
int_type c
);
std::streamsize xsputn (
const char* s,
std::streamsize num
);
// input functions
int_type underflow(
);
int_type uflow(
);
int_type pbackfail(
int_type c
);
std::streamsize xsgetn (
char_type* s,
std::streamsize n
);
private:
// member data
connection& con;
int_type peek;
int_type lastread;
bool lastread_next;
};
// ----------------------------------------------------------------------------------------
}
#ifdef NO_MAKEFILE
#include "sockstreambuf_unbuffered.cpp"
#endif
#endif // DLIB_SOCKSTrEAMBUF_UNBUFFERED_Hh_
|