x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
aggregate.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\iostreams\filter\aggregate.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_AGGREGATE_FILTER_HPP_INCLUDED #define BOOST_IOSTREAMS_AGGREGATE_FILTER_HPP_INCLUDED #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include
// copy, min. #include
#include
// back_inserter #include
#include
// default_device_buffer_size #include
#include
#include
// openmode, streamsize. #include
#include
// check_eof #include
#include
#include
// Must come last. #include
// MSVC. namespace boost { namespace iostreams { // // Template name: aggregate_filter. // Template paramters: // Ch - The character type. // Alloc - The allocator type. // Description: Utility for defining DualUseFilters which filter an // entire stream at once. To use, override the protected virtual // member do_filter. // Note: This filter should not be copied while it is in use. // template
> class aggregate_filter { public: typedef Ch char_type; struct category : dual_use, filter_tag, multichar_tag, closable_tag { }; aggregate_filter() : ptr_(0), state_(0) { } virtual ~aggregate_filter() { } template
std::streamsize read(Source& src, char_type* s, std::streamsize n) { using namespace std; assert(!(state_ & f_write)); state_ |= f_read; if (!(state_ & f_eof)) do_read(src); std::streamsize amt = (std::min)(n, static_cast
(data_.size() - ptr_)); if (amt) { BOOST_IOSTREAMS_CHAR_TRAITS(char_type)::copy(s, &data_[ptr_], amt); ptr_ += amt; } return detail::check_eof(amt); } template
std::streamsize write(Sink&, const char_type* s, std::streamsize n) { assert(!(state_ & f_read)); state_ |= f_write; data_.insert(data_.end(), s, s + n); return n; } template
void close(Sink& sink, BOOST_IOS::openmode which) { if ((state_ & f_read) != 0 && which == BOOST_IOS::in) close_impl(); if ((state_ & f_write) != 0 && which == BOOST_IOS::out) { try { vector_type filtered; do_filter(data_, filtered); do_write( sink, &filtered[0], static_cast
(filtered.size()) ); } catch (...) { close_impl(); throw; } close_impl(); } } protected: typedef std::vector
vector_type; typedef typename vector_type::size_type size_type; private: virtual void do_filter(const vector_type& src, vector_type& dest) = 0; virtual void do_close() { } template
void do_read(Source& src) { using std::streamsize; vector_type data; while (true) { const std::streamsize size = default_device_buffer_size; Ch buf[size]; std::streamsize amt; if ((amt = boost::iostreams::read(src, buf, size)) == -1) break; data.insert(data.end(), buf, buf + amt); } do_filter(data, data_); state_ |= f_eof; } template
void do_write(Sink& sink, const char* s, std::streamsize n) { typedef typename iostreams::category_of
::type category; typedef is_convertible
can_write; do_write(sink, s, n, can_write()); } template
void do_write(Sink& sink, const char* s, std::streamsize n, mpl::true_) { iostreams::write(sink, s, n); } template
void do_write(Sink&, const char*, std::streamsize, mpl::false_) { } void close_impl() { data_.clear(); ptr_ = 0; state_ = 0; do_close(); } enum flag_type { f_read = 1, f_write = f_read << 1, f_eof = f_write << 1 }; // Note: typically will not be copied while vector contains data. vector_type data_; size_type ptr_; int state_; }; BOOST_IOSTREAMS_PIPABLE(aggregate_filter, 1) } } // End namespaces iostreams, boost. #include
// MSVC. #endif // #ifndef BOOST_IOSTREAMS_AGGREGATE_FILTER_HPP_INCLUDED
aggregate.hpp
网页地址
文件地址
上一页 1/11
下一页
下载
( 5 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.