diff --git a/dlib/all/source.cpp b/dlib/all/source.cpp index 41f85436b..b769649a8 100644 --- a/dlib/all/source.cpp +++ b/dlib/all/source.cpp @@ -36,8 +36,8 @@ #include "../misc_api/misc_api_kernel_2.cpp" #include "../sockets/sockets_extensions.cpp" #include "../sockets/sockets_kernel_2.cpp" -#include "../sockstreambuf/sockstreambuf_kernel_1.cpp" -#include "../sockstreambuf/sockstreambuf_kernel_2.cpp" +#include "../sockstreambuf/sockstreambuf.cpp" +#include "../sockstreambuf/sockstreambuf_unbuffered.cpp" #include "../server/server_kernel.cpp" #include "../server/server_iostream.cpp" #include "../server/server_http.cpp" diff --git a/dlib/sockstreambuf.h b/dlib/sockstreambuf.h index ae830f626..b938018db 100644 --- a/dlib/sockstreambuf.h +++ b/dlib/sockstreambuf.h @@ -1,36 +1,11 @@ // Copyright (C) 2003 Davis E. King (davis@dlib.net) // License: Boost Software License See LICENSE.txt for the full license. -#ifndef _SOCKSTREAMBUf_ -#define _SOCKSTREAMBUf_ +#ifndef DLIB_SOCKSTREAMBUf_H___ +#define DLIB_SOCKSTREAMBUf_H___ -#include "sockstreambuf/sockstreambuf_kernel_1.h" -#include "sockstreambuf/sockstreambuf_kernel_2.h" +#include "sockstreambuf/sockstreambuf.h" +#include "sockstreambuf/sockstreambuf_unbuffered.h" -namespace dlib -{ - - - class sockstreambuf - { - sockstreambuf() {} - - - public: - - //----------- kernels --------------- - - // kernel_1a - typedef sockstreambuf_kernel_1 - kernel_1a; - - // kernel_2a - typedef sockstreambuf_kernel_2 - kernel_2a; - - - }; -} - -#endif +#endif // DLIB_SOCKSTREAMBUf_H___ diff --git a/dlib/sockstreambuf/sockstreambuf_kernel_2.cpp b/dlib/sockstreambuf/sockstreambuf.cpp similarity index 92% rename from dlib/sockstreambuf/sockstreambuf_kernel_2.cpp rename to dlib/sockstreambuf/sockstreambuf.cpp index 0d5ef84d1..8740725c4 100644 --- a/dlib/sockstreambuf/sockstreambuf_kernel_2.cpp +++ b/dlib/sockstreambuf/sockstreambuf.cpp @@ -1,8 +1,9 @@ // Copyright (C) 2003 Davis E. King (davis@dlib.net) // License: Boost Software License See LICENSE.txt for the full license. -#ifndef DLIB_SOCKSTREAMBUF_KERNEL_2_CPp_ -#define DLIB_SOCKSTREAMBUF_KERNEL_2_CPp_ -#include "sockstreambuf_kernel_2.h" +#ifndef DLIB_SOCKStREAMBUF_CPp_ +#define DLIB_SOCKStREAMBUF_CPp_ + +#include "sockstreambuf.h" #include "../assert.h" #include @@ -14,7 +15,7 @@ namespace dlib // output functions // ---------------------------------------------------------------------------------------- - sockstreambuf_kernel_2::int_type sockstreambuf_kernel_2:: + sockstreambuf::int_type sockstreambuf:: overflow ( int_type c ) @@ -34,7 +35,7 @@ namespace dlib // ---------------------------------------------------------------------------------------- - std::streamsize sockstreambuf_kernel_2:: + std::streamsize sockstreambuf:: xsputn ( const char* s, std::streamsize num @@ -90,7 +91,7 @@ namespace dlib // input functions // ---------------------------------------------------------------------------------------- - sockstreambuf_kernel_2::int_type sockstreambuf_kernel_2:: + sockstreambuf::int_type sockstreambuf:: underflow( ) { @@ -125,7 +126,7 @@ namespace dlib // ---------------------------------------------------------------------------------------- - std::streamsize sockstreambuf_kernel_2:: + std::streamsize sockstreambuf:: xsgetn ( char_type* s, std::streamsize n @@ -163,5 +164,5 @@ namespace dlib // ---------------------------------------------------------------------------------------- } -#endif // DLIB_SOCKSTREAMBUF_KERNEL_2_CPp_ +#endif // DLIB_SOCKStREAMBUF_CPp_ diff --git a/dlib/sockstreambuf/sockstreambuf_kernel_2.h b/dlib/sockstreambuf/sockstreambuf.h similarity index 85% rename from dlib/sockstreambuf/sockstreambuf_kernel_2.h rename to dlib/sockstreambuf/sockstreambuf.h index 0e65de036..122489676 100644 --- a/dlib/sockstreambuf/sockstreambuf_kernel_2.h +++ b/dlib/sockstreambuf/sockstreambuf.h @@ -1,19 +1,20 @@ // Copyright (C) 2003 Davis E. King (davis@dlib.net) // License: Boost Software License See LICENSE.txt for the full license. -#ifndef DLIB_SOCKSTREAMBUF_KERNEl_2_ -#define DLIB_SOCKSTREAMBUF_KERNEl_2_ +#ifndef DLIB_SOCKStREAMBUF_H__ +#define DLIB_SOCKStREAMBUF_H__ #include #include #include "../sockets.h" -#include "sockstreambuf_kernel_abstract.h" +#include "sockstreambuf_abstract.h" +#include "sockstreambuf_unbuffered.h" namespace dlib { // ---------------------------------------------------------------------------------------- - class sockstreambuf_kernel_2 : public std::streambuf + class sockstreambuf : public std::streambuf { /*! INITIAL VALUE @@ -28,7 +29,13 @@ namespace dlib !*/ public: - sockstreambuf_kernel_2 ( + + // These typedefs are here for backwards compatibility with previous versions of + // dlib. + typedef sockstreambuf_unbuffered kernel_1a; + typedef sockstreambuf kernel_2a; + + sockstreambuf ( connection* con_ ) : con(*con_), @@ -38,7 +45,7 @@ namespace dlib init(); } - sockstreambuf_kernel_2 ( + sockstreambuf ( const scoped_ptr& con_ ) : con(*con_), @@ -48,7 +55,7 @@ namespace dlib init(); } - virtual ~sockstreambuf_kernel_2 ( + virtual ~sockstreambuf ( ) { sync(); @@ -141,8 +148,8 @@ namespace dlib } #ifdef NO_MAKEFILE -#include "sockstreambuf_kernel_2.cpp" +#include "sockstreambuf.cpp" #endif -#endif // DLIB_SOCKSTREAMBUF_KERNEl_2_ +#endif // DLIB_SOCKStREAMBUF_H__ diff --git a/dlib/sockstreambuf/sockstreambuf_kernel_abstract.h b/dlib/sockstreambuf/sockstreambuf_abstract.h similarity index 96% rename from dlib/sockstreambuf/sockstreambuf_kernel_abstract.h rename to dlib/sockstreambuf/sockstreambuf_abstract.h index 919682714..aa0985b74 100644 --- a/dlib/sockstreambuf/sockstreambuf_kernel_abstract.h +++ b/dlib/sockstreambuf/sockstreambuf_abstract.h @@ -1,7 +1,7 @@ // Copyright (C) 2003 Davis E. King (davis@dlib.net) // License: Boost Software License See LICENSE.txt for the full license. -#undef DLIB_SOCKSTREAMBUF_KERNEl_ABSTRACT_ -#ifdef DLIB_SOCKSTREAMBUF_KERNEl_ABSTRACT_ +#undef DLIB_SOCKSTREAMBUF_ABSTRACT_ +#ifdef DLIB_SOCKSTREAMBUF_ABSTRACT_ #include #include @@ -94,5 +94,5 @@ namespace dlib } -#endif // DLIB_SOCKSTREAMBUF_KERNEl_ABSTRACT_ +#endif // DLIB_SOCKSTREAMBUF_ABSTRACT_ diff --git a/dlib/sockstreambuf/sockstreambuf_kernel_1.cpp b/dlib/sockstreambuf/sockstreambuf_unbuffered.cpp similarity index 87% rename from dlib/sockstreambuf/sockstreambuf_kernel_1.cpp rename to dlib/sockstreambuf/sockstreambuf_unbuffered.cpp index e32f5246a..4dcefc17b 100644 --- a/dlib/sockstreambuf/sockstreambuf_kernel_1.cpp +++ b/dlib/sockstreambuf/sockstreambuf_unbuffered.cpp @@ -1,8 +1,9 @@ // Copyright (C) 2003 Davis E. King (davis@dlib.net) // License: Boost Software License See LICENSE.txt for the full license. -#ifndef DLIB_SOCKSTREAMBUF_KERNEL_1_CPp_ -#define DLIB_SOCKSTREAMBUF_KERNEL_1_CPp_ -#include "sockstreambuf_kernel_1.h" +#ifndef DLIB_SOCKSTrEAMBUF_UNBUFFERED_CPp_ +#define DLIB_SOCKSTrEAMBUF_UNBUFFERED_CPp_ + +#include "sockstreambuf_unbuffered.h" namespace dlib @@ -12,7 +13,7 @@ namespace dlib // output functions // ---------------------------------------------------------------------------------------- - sockstreambuf_kernel_1::int_type sockstreambuf_kernel_1:: + sockstreambuf_unbuffered::int_type sockstreambuf_unbuffered:: overflow ( int_type c ) @@ -31,7 +32,7 @@ namespace dlib // ---------------------------------------------------------------------------------------- - std::streamsize sockstreambuf_kernel_1:: + std::streamsize sockstreambuf_unbuffered:: xsputn ( const char* s, std::streamsize num @@ -49,7 +50,7 @@ namespace dlib // input functions // ---------------------------------------------------------------------------------------- - sockstreambuf_kernel_1::int_type sockstreambuf_kernel_1:: + sockstreambuf_unbuffered::int_type sockstreambuf_unbuffered:: underflow( ) { @@ -76,7 +77,7 @@ namespace dlib // ---------------------------------------------------------------------------------------- - sockstreambuf_kernel_1::int_type sockstreambuf_kernel_1:: + sockstreambuf_unbuffered::int_type sockstreambuf_unbuffered:: uflow( ) { @@ -106,7 +107,7 @@ namespace dlib // ---------------------------------------------------------------------------------------- - sockstreambuf_kernel_1::int_type sockstreambuf_kernel_1:: + sockstreambuf_unbuffered::int_type sockstreambuf_unbuffered:: pbackfail( int_type c ) @@ -126,7 +127,7 @@ namespace dlib // ---------------------------------------------------------------------------------------- - std::streamsize sockstreambuf_kernel_1:: + std::streamsize sockstreambuf_unbuffered:: xsgetn ( char_type* s, std::streamsize n @@ -163,5 +164,5 @@ namespace dlib // ---------------------------------------------------------------------------------------- } -#endif // DLIB_SOCKSTREAMBUF_KERNEL_1_CPp_ +#endif // DLIB_SOCKSTrEAMBUF_UNBUFFERED_CPp_ diff --git a/dlib/sockstreambuf/sockstreambuf_kernel_1.h b/dlib/sockstreambuf/sockstreambuf_unbuffered.h similarity index 78% rename from dlib/sockstreambuf/sockstreambuf_kernel_1.h rename to dlib/sockstreambuf/sockstreambuf_unbuffered.h index 19d4f7a8f..82834c7e6 100644 --- a/dlib/sockstreambuf/sockstreambuf_kernel_1.h +++ b/dlib/sockstreambuf/sockstreambuf_unbuffered.h @@ -1,21 +1,26 @@ // Copyright (C) 2003 Davis E. King (davis@dlib.net) // License: Boost Software License See LICENSE.txt for the full license. -#ifndef DLIB_SOCKSTREAMBUF_KERNEl_1_ -#define DLIB_SOCKSTREAMBUF_KERNEl_1_ +#ifndef DLIB_SOCKSTrEAMBUF_UNBUFFERED_H__ +#define DLIB_SOCKSTrEAMBUF_UNBUFFERED_H__ #include #include #include "../sockets.h" -#include "sockstreambuf_kernel_abstract.h" +#include "sockstreambuf_abstract.h" namespace dlib { // ---------------------------------------------------------------------------------------- - class sockstreambuf_kernel_1 : public std::streambuf + 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. + INITIAL VALUE con == a connection lastread_next == false @@ -36,7 +41,9 @@ namespace dlib !*/ public: - sockstreambuf_kernel_1 ( + + + sockstreambuf_unbuffered ( connection* con_ ) : con(*con_), @@ -44,7 +51,7 @@ namespace dlib lastread_next(false) {} - sockstreambuf_kernel_1 ( + sockstreambuf_unbuffered ( const scoped_ptr& con_ ) : con(*con_), @@ -99,8 +106,8 @@ namespace dlib } #ifdef NO_MAKEFILE -#include "sockstreambuf_kernel_1.cpp" +#include "sockstreambuf_unbuffered.cpp" #endif -#endif // DLIB_SOCKSTREAMBUF_KERNEl_1_ +#endif // DLIB_SOCKSTrEAMBUF_UNBUFFERED_H__