rpa::augm_basic_stringbuf< DerivStrmBuf > Struct Template Reference

#include <row_buffer.h>

List of all members.

Public Types

typedef DerivStrmBuf::char_type char_type
typedef DerivStrmBuf::traits_type traits_type

Public Member Functions

void check (void) const
 augm_basic_stringbuf (void)
 'out' : At construction, created for writing into it.
bool a_empty (void) const
void a_clear (void)
bool a_flush (std::basic_streambuf< char_type, traits_type > *aStrmBuf)

Private Member Functions

size_t size (void) const
bool dmp_fd (int aFilDes)
bool dmp_file (FILE *aOutFile)


Detailed Description

template<class DerivStrmBuf>
struct rpa::augm_basic_stringbuf< DerivStrmBuf >

This is a specialization when the buffer is a std::stringbuf. The implementation of basic_stringbuf may be optimized :


Member Typedef Documentation

template<class DerivStrmBuf>
typedef DerivStrmBuf::char_type rpa::augm_basic_stringbuf< DerivStrmBuf >::char_type

template<class DerivStrmBuf>
typedef DerivStrmBuf::traits_type rpa::augm_basic_stringbuf< DerivStrmBuf >::traits_type


Constructor & Destructor Documentation

template<class DerivStrmBuf>
rpa::augm_basic_stringbuf< DerivStrmBuf >::augm_basic_stringbuf ( void   )  [inline]

'out' : At construction, created for writing into it.


Member Function Documentation

template<class DerivStrmBuf>
void rpa::augm_basic_stringbuf< DerivStrmBuf >::a_clear ( void   )  [inline]

This empties the buffer without deallocating its memory, for reusing. Called prior to using it as an output buffer without size limit. NOTE: Not called for limited-size buffer. See basic_stringbuf::setbuf(). Therefore, it is not only here that we should actually empty the buffer. Equivalent to ' buffer_type::str("") ', but faster.

template<class DerivStrmBuf>
bool rpa::augm_basic_stringbuf< DerivStrmBuf >::a_empty ( void   )  const [inline]

This tells whether something was written into the buffer or not. Must be very fast and avoid costly conversions.

This is equivalent to ' str().size() == 0 '.

template<class DerivStrmBuf>
bool rpa::augm_basic_stringbuf< DerivStrmBuf >::a_flush ( std::basic_streambuf< char_type, traits_type > *  aStrmBuf  )  [inline]

Dumps the content to any kind of std::basic_streambuf. This avoids the member str(), which involves a costly std::string. This is equivalent to : aOStr << str() ;

Limited-size buffers do not flush when empty. However, this check is not done with unlimited buffers. So, if the buffer is already empty, we do nothing. This check is very fast, and it should happen rarely.

sputn is slightly faster than 'write' and allows error processing. xsputn is slightly faster than sputn, but is protected.

template<class DerivStrmBuf>
void rpa::augm_basic_stringbuf< DerivStrmBuf >::check ( void   )  const [inline]

template<class DerivStrmBuf>
bool rpa::augm_basic_stringbuf< DerivStrmBuf >::dmp_fd ( int  aFilDes  )  [inline, private]

When the output has 'fd', dumps the stringbuf in an int file descriptor. Unix-like only. Returns true if the input must be cleaned.

Limited-size buffers do not flush when empty. However, this check is not done with unlimited buffers. So, if the buffer is already empty, we do nothing. This check is very fast, and it should happen rarely.

template<class DerivStrmBuf>
bool rpa::augm_basic_stringbuf< DerivStrmBuf >::dmp_file ( FILE *  aOutFile  )  [inline, private]

When the output has the member 'file', it is possible to write the content of the stringbuf in the FILE ptr, with POSIX functions.

Limited-size buffers do not flush when empty. However, this check is not done with unlimited buffers. So, if the buffer is already empty, we do nothing. This check is very fast, and it should happen rarely.

We are sure that we have exclusive access to this file. Therefore, it is possible to use 'fwrite_unlocked' on Linux.

template<class DerivStrmBuf>
size_t rpa::augm_basic_stringbuf< DerivStrmBuf >::size ( void   )  const [inline, private]

This returns the number of chars in the buffer. This is modelled after the member std::basic_stringbuf::str(void) : if (this->pptr()) { The current egptr() may not be the actual string end. if (this->pptr() > this->egptr()) return __string_type(this->pbase(), this->pptr()); else return __string_type(this->pbase(), this->egptr()); } else return _M_string;

We could use std::max but, because of the depth of function calls, we are sure here that it will be inlined.


The documentation for this struct was generated from the following file:
Generated on Tue Sep 25 10:20:38 2007 for rpa by  doxygen 1.4.7