libstdc ++中basic_filebuf的默认缓冲区大小 [英] Default buffer size of basic_filebuf within libstdc++

查看:208
本文介绍了libstdc ++中basic_filebuf的默认缓冲区大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道libstdc ++中basic_filebuf从GNU GCC的默认缓冲区大小?我知道成员函数pubsetbuf(),我很确定缓冲区大小是实现定义的。在C中很简单,从< cstdio> 中取出BUFSIZ。



extern_buf , XSIZE intern_buf ISIZE

方案

我找到了。 C ++从C获取BUFSIZ(参见)。 fstream fstream.tcc 文件包含 basic_filebuf 类。

来自文件 fstream

的来自GCC的LIBSTDC ++





  #include< istream> 
#include< ostream>
#include< bits / codecvt.h>
#include< cstdio> // For BUFSIZ
#include< bits / basic_file.h> // For __basic_file,__c_lock
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include< string> // For std :: string overloads。
#endif


/ **
*内部缓冲区的实际大小。该数字等于放置区+ 1位置的大小
*,为溢出字符
*全部区域保留。
* /
size_t _M_buf_size;

来自文件 fstream.tcc

 模板< typename _CharT,typename _Traits> 
basic_filebuf< _CharT,_Traits> ::
basic_filebuf():__streambuf_type(),_M_lock(),_M_file(& _M_lock),
_M_mode(ios_base :: openmode(0) _M_state_beg(),_M_state_cur(),
_M_state_last(),_M_buf(0),_M_buf_size(BUFSIZ),
_M_buf_allocated(false),_M_reading b $ b _M_pback_cur_save(0),_M_pback_end_save(0),_M_pback_init(false),
_M_codecvt(0),_M_ext_buf(0),_M_ext_buf_size(0),_M_ext_next(0),
_M_ext_end
{
if(has_facet< __ codecvt_type>(this-> _M_buf_locale))
_M_codecvt =& use_facet< __ codecvt_type>(this-> _M_buf_locale);
}


Does anyone know the default buffer size for basic_filebuf in libstdc++ from the GNU GCC? I know the member function pubsetbuf() and I am pretty sure the the buffer size is implementation-defined. Within C it is simple, take BUFSIZ from <cstdio>.

Maybe the variable are called extern_buf, XSIZE, intern_buf or ISIZE?

解决方案

I found it. C++ takes the BUFSIZ from C (see ). The files fstream and fstream.tcc includes the class basic_filebuf.

Note: LIBSTDC++ from GCC

from file fstream

#include <istream>
#include <ostream>
#include <bits/codecvt.h>
#include <cstdio>             // For BUFSIZ
#include <bits/basic_file.h>  // For __basic_file, __c_lock
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <string>             // For std::string overloads.
#endif


/**
 *  Actual size of internal buffer. This number is equal to the size
 *  of the put area + 1 position, reserved for the overflow char of
 *  a full area.
 */
size_t          _M_buf_size;

from file fstream.tcc

template<typename _CharT, typename _Traits>
    basic_filebuf<_CharT, _Traits>::
    basic_filebuf() : __streambuf_type(), _M_lock(), _M_file(&_M_lock),
    _M_mode(ios_base::openmode(0)), _M_state_beg(), _M_state_cur(),
    _M_state_last(), _M_buf(0), _M_buf_size(BUFSIZ),
    _M_buf_allocated(false), _M_reading(false), _M_writing(false), _M_pback(), 
    _M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false),
    _M_codecvt(0), _M_ext_buf(0), _M_ext_buf_size(0), _M_ext_next(0),
    _M_ext_end(0)
    {
      if (has_facet<__codecvt_type>(this->_M_buf_locale))
    _M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale);
    }

这篇关于libstdc ++中basic_filebuf的默认缓冲区大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆