fastcgi++
A C++ FastCGI/Web API
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Fastcgipp::FcgiStreambuf< charT, traits > Class Template Reference

Stream buffer class for output of client data through FastCGI. More...

#include <fastcgi++/fcgistreambuf.hpp>

Inheritance diagram for Fastcgipp::FcgiStreambuf< charT, traits >:
Fastcgipp::WebStreambuf< charT, traits >

Public Member Functions

 FcgiStreambuf ()
 
void configure (const Protocol::RequestId &id, const Protocol::RecordType &type, const std::function< void(const Socket &, Block &&)> send_)
 Configure the stream buffer. More...
 
virtual ~FcgiStreambuf ()
 
void dump (const char *data, size_t size)
 Dumps raw data directly into the FastCGI protocol. More...
 
void dump (std::basic_istream< char > &stream)
 Dumps an input stream directly into the FastCGI protocol. More...
 

Private Types

typedef std::basic_streambuf< charT, traits >::int_type int_type
 
typedef std::basic_streambuf< charT, traits >::traits_type traits_type
 
typedef std::basic_streambuf< charT, traits >::char_type char_type
 

Private Member Functions

int_type overflow (int_type c=traits_type::eof())
 
int sync ()
 
bool emptyBuffer ()
 Code converts, packages and transmits all data in the stream buffer. More...
 
template<>
bool emptyBuffer ()
 
template<>
bool emptyBuffer ()
 

Private Attributes

char_type m_buffer [s_buffSize]
 The buffer. More...
 
Protocol::RequestId m_id
 ID associated with the request. More...
 
Protocol::RecordType m_type
 Type of output stream (ERR or OUT) More...
 
std::function< void(const Socket &, Block &&)> send
 Function to actually send the record. More...
 

Static Private Attributes

static const int s_buffSize = 8192
 Size of the internal stream buffer. More...
 

Detailed Description

template<class charT, class traits = std::char_traits<charT>>
class Fastcgipp::FcgiStreambuf< charT, traits >

Stream buffer class for output of client data through FastCGI.

This class is derived from WebStreambuf<charT, traits>. It acts just the same with the added feature of the dump() function but properly flushes into FastCGI records.

Template Parameters
charTCharacter type (char or wchar_t)
traitsCharacter traits
Date
May 3, 2017
Author
Eddie Carle <eddie.nosp@m.@isa.nosp@m.tec.c.nosp@m.a>

Definition at line 55 of file fcgistreambuf.hpp.

Member Typedef Documentation

◆ char_type

template<class charT, class traits = std::char_traits<charT>>
typedef std::basic_streambuf<charT, traits>::char_type Fastcgipp::FcgiStreambuf< charT, traits >::char_type
private

Definition at line 114 of file fcgistreambuf.hpp.

◆ int_type

template<class charT, class traits = std::char_traits<charT>>
typedef std::basic_streambuf<charT, traits>::int_type Fastcgipp::FcgiStreambuf< charT, traits >::int_type
private

Definition at line 112 of file fcgistreambuf.hpp.

◆ traits_type

template<class charT, class traits = std::char_traits<charT>>
typedef std::basic_streambuf<charT, traits>::traits_type Fastcgipp::FcgiStreambuf< charT, traits >::traits_type
private

Definition at line 113 of file fcgistreambuf.hpp.

Constructor & Destructor Documentation

◆ FcgiStreambuf()

template<class charT, class traits = std::char_traits<charT>>
Fastcgipp::FcgiStreambuf< charT, traits >::FcgiStreambuf ( )
inline

Definition at line 58 of file fcgistreambuf.hpp.

◆ ~FcgiStreambuf()

template<class charT, class traits = std::char_traits<charT>>
virtual Fastcgipp::FcgiStreambuf< charT, traits >::~FcgiStreambuf ( )
inlinevirtual

Definition at line 83 of file fcgistreambuf.hpp.

Member Function Documentation

◆ configure()

template<class charT, class traits = std::char_traits<charT>>
void Fastcgipp::FcgiStreambuf< charT, traits >::configure ( const Protocol::RequestId id,
const Protocol::RecordType type,
const std::function< void(const Socket &, Block &&)>  send_ 
)
inline

Configure the stream buffer.

Sets FastCGI related member data necessary for operation of the stream buffer.

Parameters
[in]idComplete ID associated with the request
[in]typeType of output stream (ERR or OUT)
[in]send_Function to send record with

Definition at line 72 of file fcgistreambuf.hpp.

◆ dump() [1/2]

template<class charT , class traits >
void Fastcgipp::FcgiStreambuf< charT, traits >::dump ( const char *  data,
size_t  size 
)

Dumps raw data directly into the FastCGI protocol.

This function exists as a mechanism to dump raw data out the stream bypassing the stream buffer or any code conversion mechanisms. If the user has any binary data to send, this is the function to do it with.

Parameters
[in]dataPointer to first byte of data to send
[in]sizeSize in bytes of data to be sent

Definition at line 144 of file fcgistreambuf.cpp.

Referenced by Fastcgipp::Request< charT >::dump().

◆ dump() [2/2]

template<class charT , class traits >
void Fastcgipp::FcgiStreambuf< charT, traits >::dump ( std::basic_istream< char > &  stream)

Dumps an input stream directly into the FastCGI protocol.

This function exists as a mechanism to dump a raw input stream out this stream bypassing the stream buffer or any code conversion mechanisms. Typically this would be a filestream associated with an image or something. The stream is transmitted until an EOF.

Parameters
[in]streamReference to input stream that should be transmitted.

Definition at line 183 of file fcgistreambuf.cpp.

◆ emptyBuffer() [1/3]

template<>
bool Fastcgipp::FcgiStreambuf< wchar_t, std::char_traits< wchar_t > >::emptyBuffer ( )
private

Definition at line 38 of file fcgistreambuf.cpp.

◆ emptyBuffer() [2/3]

template<>
bool Fastcgipp::FcgiStreambuf< char, std::char_traits< char > >::emptyBuffer ( )
private

Definition at line 93 of file fcgistreambuf.cpp.

◆ emptyBuffer() [3/3]

template<class charT, class traits = std::char_traits<charT>>
bool Fastcgipp::FcgiStreambuf< charT, traits >::emptyBuffer ( )
private

Code converts, packages and transmits all data in the stream buffer.

Referenced by Fastcgipp::FcgiStreambuf< charT >::sync().

◆ overflow()

template<class charT , class traits >
Fastcgipp::FcgiStreambuf< charT, traits >::int_type Fastcgipp::FcgiStreambuf< charT, traits >::overflow ( int_type  c = traits_type::eof())
private

Definition at line 133 of file fcgistreambuf.cpp.

◆ sync()

template<class charT, class traits = std::char_traits<charT>>
int Fastcgipp::FcgiStreambuf< charT, traits >::sync ( )
inlineprivate

Member Data Documentation

◆ m_buffer

template<class charT, class traits = std::char_traits<charT>>
char_type Fastcgipp::FcgiStreambuf< charT, traits >::m_buffer[s_buffSize]
private

The buffer.

Definition at line 130 of file fcgistreambuf.hpp.

Referenced by Fastcgipp::FcgiStreambuf< charT >::FcgiStreambuf().

◆ m_id

template<class charT, class traits = std::char_traits<charT>>
Protocol::RequestId Fastcgipp::FcgiStreambuf< charT, traits >::m_id
private

ID associated with the request.

Definition at line 133 of file fcgistreambuf.hpp.

Referenced by Fastcgipp::FcgiStreambuf< charT >::configure().

◆ m_type

template<class charT, class traits = std::char_traits<charT>>
Protocol::RecordType Fastcgipp::FcgiStreambuf< charT, traits >::m_type
private

Type of output stream (ERR or OUT)

Definition at line 136 of file fcgistreambuf.hpp.

Referenced by Fastcgipp::FcgiStreambuf< charT >::configure().

◆ s_buffSize

template<class charT, class traits = std::char_traits<charT>>
const int Fastcgipp::FcgiStreambuf< charT, traits >::s_buffSize = 8192
staticprivate

Size of the internal stream buffer.

Definition at line 127 of file fcgistreambuf.hpp.

Referenced by Fastcgipp::FcgiStreambuf< charT >::FcgiStreambuf().

◆ send

template<class charT, class traits = std::char_traits<charT>>
std::function<void(const Socket&, Block&&)> Fastcgipp::FcgiStreambuf< charT, traits >::send
private

Function to actually send the record.

Definition at line 139 of file fcgistreambuf.hpp.

Referenced by Fastcgipp::FcgiStreambuf< charT >::configure().


The documentation for this class was generated from the following files: