Exemplo n.º 1
0
_STLP_EXP_DECLSPEC strstreambuf::strstreambuf(__alloc_fn alloc_f, __free_fn free_f)
  : _M_alloc_fun(alloc_f), _M_free_fun(free_f),
    _M_dynamic(true), _M_frozen(false), _M_constant(false)
#ifdef __SYMBIAN32__
    , _pfrozenendsave(NULL)
    ,_pgetfrozenendsave( NULL)
#endif     
{
  streamsize n = 16;
#ifndef __SYMBIAN32__  
  char* buf = _M_alloc(n);
#else
  char* buf = NULL;
  if(alloc_f!=NULL)
  	buf = (char*)_M_alloc_fun(n);
  else
  	buf = _M_alloc(n);
  if(buf)
  	*buf = '\0';
#endif 
  if (buf) {
    setp(buf, buf + n);
    setg(buf, buf, buf);
  }
}
Exemplo n.º 2
0
strstreambuf::strstreambuf(__alloc_fn alloc_f, __free_fn free_f)
  : _M_alloc_fun(alloc_f), _M_free_fun(free_f),
    _M_dynamic(true), _M_frozen(false), _M_constant(false) {
  size_t n = 16;

  char* buf = _M_alloc(n);
  if (buf) {
    setp(buf, buf + n);
    setg(buf, buf, buf);
  }
}
Exemplo n.º 3
0
_STLP_EXP_DECLSPEC strstreambuf::int_type strstreambuf::overflow(int_type c) {
  if (c == traits_type::eof())
    return traits_type::not_eof(c);
#ifdef __SYMBIAN32__
  if (pptr() != 0 && pptr() < epptr())
  {
    *pptr() = c;
    pbump(1);
    return c;
  }
  if (!_M_dynamic || _M_constant || _M_frozen)
  	return (EOF);	// can't extend
#endif
  // Try to expand the buffer.
  if (pptr() == epptr() && _M_dynamic && !_M_frozen && !_M_constant) {
    ptrdiff_t old_size = epptr() - pbase();
    ptrdiff_t new_size = (max)(2 * old_size, ptrdiff_t(1));

    char* buf = _M_alloc(new_size);
    if (buf) {
      memcpy(buf, pbase(), old_size);

      char* old_buffer = pbase();
      bool reposition_get = false;
      ptrdiff_t old_get_offset;
      if (gptr() != 0) {
        reposition_get = true;
        old_get_offset = gptr() - eback();
      }

      setp(buf, buf + new_size);
      pbump((int)old_size);

      if (reposition_get) 
        setg(buf, buf + old_get_offset, buf + (max)(old_get_offset, old_size));

      _M_free(old_buffer);
    }
  }

  if (pptr() != epptr()) {
    *pptr() = c;
    pbump(1);
    return c;
  }
  else
    return traits_type::eof();
}
Exemplo n.º 4
0
_STLP_BEGIN_NAMESPACE

// strstreambuf constructor, destructor.
strstreambuf::strstreambuf(streamsize initial_capacity)
   : _M_alloc_fun(0), _M_free_fun(0),
     _M_dynamic(true), _M_frozen(false), _M_constant(false) {
  size_t n = (sizeof(streamsize) > sizeof(size_t)) ? __STATIC_CAST(size_t, (min)(__STATIC_CAST(streamsize, (numeric_limits<size_t>::max)()),
                                                                                 (max)(initial_capacity, streamsize(16))))
                                                   : __STATIC_CAST(size_t, (max)(initial_capacity, streamsize(16)));

  char* buf = _M_alloc(n);
  if (buf) {
    setp(buf, buf + n);
    setg(buf, buf, buf);
  }
}
Exemplo n.º 5
0
strstreambuf::int_type strstreambuf::overflow(int_type c) {
  if (c == traits_type::eof())
    return traits_type::not_eof(c);

  // Try to expand the buffer.
  if (pptr() == epptr() && _M_dynamic && !_M_frozen && !_M_constant) {
    ptrdiff_t old_size = epptr() - pbase();
    ptrdiff_t new_size = (max)(2 * old_size, ptrdiff_t(1));

    char* buf = _M_alloc(new_size);
    if (buf) {
      memcpy(buf, pbase(), old_size);

      char* old_buffer = pbase();
      bool reposition_get = false;
      ptrdiff_t old_get_offset;
      if (gptr() != 0) {
        reposition_get = true;
        old_get_offset = gptr() - eback();
      }

      setp(buf, buf + new_size);
      pbump((int)old_size);

      if (reposition_get)
        setg(buf, buf + old_get_offset, buf + (max)(old_get_offset, old_size));

      _M_free(old_buffer);
    }
  }

  if (pptr() != epptr()) {
    *pptr() = traits_type::to_char_type(c);
    pbump(1);
    return c;
  }
  else
    return traits_type::eof();
}
Exemplo n.º 6
0
_STLP_BEGIN_NAMESPACE

// strstreambuf constructor, destructor.

_STLP_EXP_DECLSPEC strstreambuf::strstreambuf(streamsize initial_capacity)
   :  _M_alloc_fun(0), _M_free_fun(0),
     _M_dynamic(true), _M_frozen(false), _M_constant(false)  
#ifdef __SYMBIAN32__
    , _pfrozenendsave(NULL)
    ,_pgetfrozenendsave( NULL)
#endif     
{
  streamsize n = (max)(initial_capacity, streamsize(16));

  char* buf = _M_alloc(n);
#ifdef __SYMBIAN32__  
  *buf = '\0';
#endif  
  if (buf) {
    setp(buf, buf + n);
    setg(buf, buf, buf);
  }
}