sl@0: /* sl@0: * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved. sl@0: * sl@0: * Copyright (c) 1999 sl@0: * Silicon Graphics Computer Systems, Inc. sl@0: * sl@0: * Copyright (c) 1999 sl@0: * Boris Fomitchev sl@0: * sl@0: * This material is provided "as is", with absolutely no warranty expressed sl@0: * or implied. Any use is at your own risk. sl@0: * sl@0: * Permission to use or copy this software for any purpose is hereby granted sl@0: * without fee, provided the above notices are retained on all copies. sl@0: * Permission to modify the code and to distribute modified code is granted, sl@0: * provided the above notices are retained, and a notice that the code was sl@0: * modified is included with the above copyright notice. sl@0: * sl@0: */ sl@0: # include "stlport_prefix.h" sl@0: sl@0: sl@0: #include sl@0: #include sl@0: sl@0: // Implementation of non-inline member functions of class sl@0: // basic_streambuf > sl@0: sl@0: # if defined (__hpux) sl@0: # define FILE_CAST(x) (__REINTERPRET_CAST(FILE*, x)) sl@0: # else sl@0: # define FILE_CAST(x) x sl@0: # endif sl@0: sl@0: _STLP_BEGIN_NAMESPACE sl@0: sl@0: #if !defined(_STLP_WINCE) sl@0: sl@0: _STLP_EXP_DECLSPEC basic_streambuf >::~basic_streambuf() {} sl@0: sl@0: // This constructor is an extension. It is for streambuf subclasses that sl@0: // are synchronized with C stdio files. sl@0: _STLP_EXP_DECLSPEC basic_streambuf > sl@0: ::basic_streambuf(FILE* __get, FILE* __put) sl@0: : _M_get(__get ? __get : FILE_CAST(&_M_default_get)), sl@0: _M_put(__put ? __put : FILE_CAST(&_M_default_put)), sl@0: _M_locale() sl@0: { sl@0: _M_lock._M_initialize(); sl@0: sl@0: if (_M_get == FILE_CAST(&_M_default_get)) sl@0: _FILE_I_set(_M_get, 0, 0, 0); sl@0: if (_M_put == FILE_CAST(&_M_default_put)) sl@0: _FILE_O_set(_M_put, 0, 0, 0); sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC basic_streambuf > sl@0: ::basic_streambuf _STLP_PSPEC2(char, char_traits) () sl@0: : _M_get(__REINTERPRET_CAST(FILE*,&_M_default_get)), sl@0: _M_put(__REINTERPRET_CAST(FILE*,&_M_default_put)), _M_locale() sl@0: { sl@0: // _M_lock._M_initialize(); sl@0: _FILE_I_set(_M_get, 0, 0, 0); sl@0: _FILE_O_set(_M_put, 0, 0, 0); sl@0: } sl@0: sl@0: // virtual functions sl@0: sl@0: _STLP_EXP_DECLSPEC void basic_streambuf >::imbue(const locale&) sl@0: {} sl@0: sl@0: _STLP_EXP_DECLSPEC basic_streambuf >* sl@0: basic_streambuf >::setbuf(char*, streamsize) sl@0: { sl@0: return this; sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC basic_streambuf >::pos_type sl@0: basic_streambuf > sl@0: ::seekoff(off_type, ios_base::seekdir, ios_base::openmode) sl@0: { sl@0: return pos_type(-1); sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC basic_streambuf >::pos_type sl@0: basic_streambuf > sl@0: ::seekpos(pos_type, ios_base::openmode) sl@0: { sl@0: return pos_type(-1); sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC int basic_streambuf >::sync() sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC streamsize basic_streambuf >::showmanyc() sl@0: { sl@0: return 0; sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC streamsize basic_streambuf > sl@0: ::xsgetn(char* s, streamsize n) sl@0: { sl@0: streamsize result = 0; sl@0: const int_type eof = traits_type::eof(); sl@0: sl@0: while (result < n) { sl@0: if (_FILE_I_avail(_M_get) > 0) { sl@0: size_t chunk = (min) (__STATIC_CAST(size_t,_FILE_I_avail(_M_get)), sl@0: __STATIC_CAST(size_t,n - result)); sl@0: traits_type::copy(s, _FILE_I_next(_M_get), chunk); sl@0: result += chunk; sl@0: s += chunk; sl@0: _FILE_I_bump(_M_get, chunk); sl@0: } sl@0: else { sl@0: int_type c = sbumpc(); sl@0: if (c != eof) { sl@0: *s = c; sl@0: ++result; sl@0: ++s; sl@0: } sl@0: else sl@0: break; sl@0: } sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC basic_streambuf >::int_type sl@0: basic_streambuf >::underflow() sl@0: { sl@0: return traits_type::eof(); sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC basic_streambuf >::int_type sl@0: basic_streambuf >::uflow() sl@0: { sl@0: const int_type eof = traits_type::eof(); sl@0: return this->underflow() == eof sl@0: ? eof sl@0: : traits_type::to_int_type(_FILE_I_postincr(_M_get)); sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC basic_streambuf >::int_type sl@0: basic_streambuf >::pbackfail(int_type /* __c */) sl@0: { sl@0: return traits_type::eof(); sl@0: } sl@0: sl@0: sl@0: _STLP_EXP_DECLSPEC streamsize basic_streambuf > sl@0: ::xsputn(const char* s, streamsize n) sl@0: { sl@0: streamsize result = 0; sl@0: const int_type eof = traits_type::eof(); sl@0: sl@0: while (result < n) { sl@0: if (_FILE_O_avail(_M_put) > 0) { sl@0: size_t chunk = (min) (__STATIC_CAST(size_t,_FILE_O_avail(_M_put)), sl@0: __STATIC_CAST(size_t,n - result)); sl@0: traits_type::copy(_FILE_O_next(_M_put), s, chunk); sl@0: result += chunk; sl@0: s += chunk; sl@0: _FILE_O_bump(_M_put, (int)chunk); sl@0: } sl@0: sl@0: else if (this->overflow(traits_type::to_int_type(*s)) != eof) { sl@0: ++result; sl@0: ++s; sl@0: } sl@0: else sl@0: break; sl@0: } sl@0: return result; sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC streamsize basic_streambuf > sl@0: ::_M_xsputnc(char c, streamsize n) sl@0: { sl@0: streamsize result = 0; sl@0: const int_type eof = traits_type::eof(); sl@0: sl@0: while (result < n) { sl@0: if (_FILE_O_avail(_M_put) > 0) { sl@0: size_t chunk = (min) (__STATIC_CAST(size_t,_FILE_O_avail(_M_put)), sl@0: __STATIC_CAST(size_t,n - result)); sl@0: traits_type::assign(_FILE_O_next(_M_put), chunk, c); sl@0: result += chunk; sl@0: _FILE_O_bump(_M_put, (int)chunk); sl@0: } sl@0: sl@0: else if (this->overflow(traits_type::to_int_type(c)) != eof) sl@0: ++result; sl@0: else sl@0: break; sl@0: } sl@0: return result; sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC basic_streambuf >::int_type sl@0: basic_streambuf >::overflow(int_type/* c */) sl@0: { sl@0: return traits_type::eof(); sl@0: } sl@0: sl@0: _STLP_EXP_DECLSPEC basic_streambuf >::int_type sl@0: basic_streambuf >::_M_snextc_aux() sl@0: { sl@0: int_type eof = traits_type::eof(); sl@0: if (_FILE_I_avail(_M_get) == 0) sl@0: return this->uflow() == eof ? eof : this->sgetc(); sl@0: else { sl@0: _FILE_I_set(_M_get, sl@0: _FILE_I_begin(_M_get), _FILE_I_end(_M_get), _FILE_I_end(_M_get)); sl@0: return this->underflow(); sl@0: } sl@0: } sl@0: sl@0: sl@0: _STLP_EXP_DECLSPEC locale basic_streambuf >::pubimbue(const locale& loc) sl@0: { sl@0: this->imbue(loc); sl@0: locale tmp = _M_locale; sl@0: _M_locale = loc; sl@0: return tmp; sl@0: } sl@0: sl@0: #else sl@0: sl@0: #if !defined(_STLP_NO_FORCE_INSTANTIATE) sl@0: template class basic_streambuf >; sl@0: #endif sl@0: sl@0: #endif /* _STLP_WINCE */ sl@0: sl@0: //---------------------------------------------------------------------- sl@0: // Force instantiation of basic_streambuf sl@0: sl@0: // not basic_streambuf, because it's specialized. sl@0: sl@0: #if !defined(_STLP_NO_FORCE_INSTANTIATE) sl@0: #if !defined (_STLP_NO_WCHAR_T) sl@0: template class basic_streambuf >; sl@0: #endif /* INSTANTIATE_WIDE_STREAMS */ sl@0: #endif sl@0: sl@0: _STLP_END_NAMESPACE sl@0: sl@0: // Local Variables: sl@0: // mode:C++ sl@0: // End: