x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
direct_streambuf.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\iostreams\detail\streambuf\direct_streambuf.hpp
旋转
特效
属性
历史版本
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) // (C) Copyright 2003-2007 Jonathan Turkanis // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) // See http://www.boost.org/libs/iostreams for documentation. #ifndef BOOST_IOSTREAMS_DETAIL_DIRECT_STREAMBUF_HPP_INCLUDED #define BOOST_IOSTREAMS_DETAIL_DIRECT_STREAMBUF_HPP_INCLUDED #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include
#include
#include
#include
// pair. #include
// BOOST_DEDUCED_TYPENAME, #include
// member template friends. #include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
// Must come last. #include
// MSVC. namespace boost { namespace iostreams { namespace detail { template< typename T, typename Tr = BOOST_IOSTREAMS_CHAR_TRAITS( BOOST_DEDUCED_TYPENAME char_type_of
::type ) > class direct_streambuf : public linked_streambuf
::type, Tr> { public: typedef typename char_type_of
::type char_type; BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr) private: typedef linked_streambuf
base_type; typedef typename category_of
::type category; typedef BOOST_IOSTREAMS_BASIC_STREAMBUF( char_type, traits_type ) streambuf_type; public: // stream needs access. void open(const T& t, int buffer_size, int pback_size); bool is_open() const; void close(); bool auto_close() const { return auto_close_; } void set_auto_close(bool close) { auto_close_ = close; } bool strict_sync() { return true; } // Declared in linked_streambuf. T* component() { return storage_.get(); } protected: #if !BOOST_WORKAROUND(__GNUC__, == 2) BOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base_type) #endif direct_streambuf(); //--------------Virtual functions-----------------------------------------// // Declared in linked_streambuf. void close_impl(BOOST_IOS::openmode m); const std::type_info& component_type() const { return typeid(T); } void* component_impl() { return component(); } #ifdef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES public: #endif // Declared in basic_streambuf. int_type underflow(); int_type pbackfail(int_type c); int_type overflow(int_type c); pos_type seekoff( off_type off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which ); pos_type seekpos(pos_type sp, BOOST_IOS::openmode which); private: pos_type seek_impl( stream_offset off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which ); void init_input(any_tag) { } void init_input(input); void init_output(any_tag) { } void init_output(output); void init_get_area(); void init_put_area(); bool one_head() const; bool two_head() const; optional
storage_; char_type *ibeg_, *iend_, *obeg_, *oend_; bool auto_close_; }; //------------------Implementation of direct_streambuf------------------------// template
direct_streambuf
::direct_streambuf() : ibeg_(0), iend_(0), obeg_(0), oend_(0), auto_close_(true) { this->set_true_eof(true); } template
void direct_streambuf
::open(const T& t, int, int) { storage_.reset(t); init_input(category()); init_output(category()); setg(0, 0, 0); setp(0, 0); } template
bool direct_streambuf
::is_open() const { return ibeg_ != 0 || obeg_ != 0; } template
void direct_streambuf
::close() { base_type* self = this; detail::execute_all( detail::call_member_close(*self, BOOST_IOS::in), detail::call_member_close(*self, BOOST_IOS::out), detail::call_reset(storage_) ); } template
typename direct_streambuf
::int_type direct_streambuf
::underflow() { if (!ibeg_) throw cant_read(); if (!gptr()) init_get_area(); return gptr() != iend_ ? traits_type::to_int_type(*gptr()) : traits_type::eof(); } template
typename direct_streambuf
::int_type direct_streambuf
::pbackfail(int_type c) { using namespace std; if (!ibeg_) throw cant_read(); if (gptr() != 0 && gptr() != ibeg_) { gbump(-1); if (!traits_type::eq_int_type(c, traits_type::eof())) *gptr() = traits_type::to_char_type(c); return traits_type::not_eof(c); } throw bad_putback(); } template
typename direct_streambuf
::int_type direct_streambuf
::overflow(int_type c) { using namespace std; if (!obeg_) throw BOOST_IOSTREAMS_FAILURE("no write access"); if (!pptr()) init_put_area(); if (!traits_type::eq_int_type(c, traits_type::eof())) { if (pptr() == oend_) throw BOOST_IOSTREAMS_FAILURE("write area exhausted"); *pptr() = traits_type::to_char_type(c); pbump(1); return c; } return traits_type::not_eof(c); } template
inline typename direct_streambuf
::pos_type direct_streambuf
::seekoff (off_type off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which) { return seek_impl(off, way, which); } template
inline typename direct_streambuf
::pos_type direct_streambuf
::seekpos (pos_type sp, BOOST_IOS::openmode which) { return seek_impl(position_to_offset(sp), BOOST_IOS::beg, which); } template
void direct_streambuf
::close_impl(BOOST_IOS::openmode which) { if (which == BOOST_IOS::in && ibeg_ != 0) { setg(0, 0, 0); ibeg_ = iend_ = 0; } if (which == BOOST_IOS::out && obeg_ != 0) { sync(); setp(0, 0); obeg_ = oend_ = 0; } boost::iostreams::close(*storage_, which); } template
typename direct_streambuf
::pos_type direct_streambuf
::seek_impl (stream_offset off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which) { using namespace std; BOOST_IOS::openmode both = BOOST_IOS::in | BOOST_IOS::out; if (two_head() && (which & both) == both) throw bad_seek(); stream_offset result = -1; bool one = one_head(); if (one && (pptr() != 0 || gptr()== 0)) init_get_area(); // Switch to input mode, for code reuse. if (one || (which & BOOST_IOS::in) != 0 && ibeg_ != 0) { if (!gptr()) setg(ibeg_, ibeg_, iend_); ptrdiff_t next = 0; switch (way) { case BOOST_IOS::beg: next = off; break; case BOOST_IOS::cur: next = (gptr() - ibeg_) + off; break; case BOOST_IOS::end: next = (iend_ - ibeg_) + off; break; default: assert(0); } if (next < 0 || next > (iend_ - ibeg_)) throw bad_seek(); setg(ibeg_, ibeg_ + next, iend_); result = next; } if (!one && (which & BOOST_IOS::out) != 0 && obeg_ != 0) { if (!pptr()) setp(obeg_, oend_); ptrdiff_t next = 0; switch (way) { case BOOST_IOS::beg: next = off; break; case BOOST_IOS::cur: next = (pptr() - obeg_) + off; break; case BOOST_IOS::end: next = (oend_ - obeg_) + off; break; default: assert(0); } if (next < 0 || next > (oend_ - obeg_)) throw bad_seek(); pbump(static_cast
(next - (pptr() - obeg_))); result = next; } return offset_to_position(result); } template
void direct_streambuf
::init_input(input) { std::pair
p = input_sequence(*storage_); ibeg_ = p.first; iend_ = p.second; } template
void direct_streambuf
::init_output(output) { std::pair
p = output_sequence(*storage_); obeg_ = p.first; oend_ = p.second; } template
void direct_streambuf
::init_get_area() { setg(ibeg_, ibeg_, iend_); if (one_head() && pptr()) { gbump(static_cast
(pptr() - obeg_)); setp(0, 0); } } template
void direct_streambuf
::init_put_area() { setp(obeg_, oend_); if (one_head() && gptr()) { pbump(static_cast
(gptr() - ibeg_)); setg(0, 0, 0); } } template
inline bool direct_streambuf
::one_head() const { return ibeg_ && obeg_ && ibeg_ == obeg_; } template
inline bool direct_streambuf
::two_head() const { return ibeg_ && obeg_ && ibeg_ != obeg_; } //----------------------------------------------------------------------------// } // End namespace detail. } } // End namespaces iostreams, boost. #include
// MSVC #endif // #ifndef BOOST_IOSTREAMS_DETAIL_DIRECT_STREAMBUF_HPP_INCLUDED
direct_streambuf.hpp
网页地址
文件地址
上一页
2/4
下一页
下载
( 9 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.