x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
hash_peek_bitset.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\xpressive\detail\utility\hash_peek_bitset.hpp
旋转
特效
属性
历史版本
/////////////////////////////////////////////////////////////////////////////// // hash_peek_bitset.hpp // // Copyright 2007 Eric Niebler. 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) #ifndef BOOST_XPRESSIVE_DETAIL_HASH_PEEK_BITSET_HPP_EAN_10_04_2005 #define BOOST_XPRESSIVE_DETAIL_HASH_PEEK_BITSET_HPP_EAN_10_04_2005 // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once # pragma warning(push) # pragma warning(disable : 4100) // unreferenced formal parameter # pragma warning(disable : 4127) // conditional expression constant #endif #include
#include
// for std::char_traits #include
namespace boost { namespace xpressive { namespace detail { /////////////////////////////////////////////////////////////////////////////// // hash_peek_bitset // template
struct hash_peek_bitset { typedef Char char_type; typedef typename std::char_traits
::int_type int_type; hash_peek_bitset() : icase_(false) , bset_() { } std::size_t count() const { return this->bset_.count(); } void set_all() { this->icase_ = false; this->bset_.set(); } template
void set_char(char_type ch, bool icase, Traits const &traits) { if(this->test_icase_(icase)) { ch = icase ? traits.translate_nocase(ch) : traits.translate(ch); this->bset_.set(traits.hash(ch)); } } template
void set_range(char_type from, char_type to, bool no, bool icase, Traits const &traits) { int_type ifrom = std::char_traits
::to_int_type(from); int_type ito = std::char_traits
::to_int_type(to); BOOST_ASSERT(ifrom <= ito); // bound the computational complexity. BUGBUG could set the inverse range if(no || 256 < (ito - ifrom)) { this->set_all(); } else if(this->test_icase_(icase)) { for(int_type i = ifrom; i <= ito; ++i) { char_type ch = std::char_traits
::to_char_type(i); ch = icase ? traits.translate_nocase(ch) : traits.translate(ch); this->bset_.set(traits.hash(ch)); } } } template
void set_class(typename Traits::char_class_type char_class, bool no, Traits const &traits) { if(1 != sizeof(char_type)) { // wide character set, no efficient way of filling in the bitset, so set them all to 1 this->set_all(); } else { for(std::size_t i = 0; i <= UCHAR_MAX; ++i) { char_type ch = std::char_traits
::to_char_type(static_cast
(i)); if(no != traits.isctype(ch, char_class)) { this->bset_.set(i); } } } } void set_bitset(hash_peek_bitset
const &that) { this->bset_ |= that.bset_; } void set_charset(basic_chset_8bit
const &that, bool icase) { if(this->test_icase_(icase)) { this->bset_ |= that.base(); } } bool icase() const { return this->icase_; } template
bool test(char_type ch, Traits const &traits) const { ch = this->icase_ ? traits.translate_nocase(ch) : traits.translate(ch); return this->bset_.test(traits.hash(ch)); } template
bool test(char_type ch, Traits const &traits, mpl::false_) const { BOOST_ASSERT(!this->icase_); return this->bset_.test(traits.hash(traits.translate(ch))); } template
bool test(char_type ch, Traits const &traits, mpl::true_) const { BOOST_ASSERT(this->icase_); return this->bset_.test(traits.hash(traits.translate_nocase(ch))); } private: // Make sure all sub-expressions being merged have the same case-sensitivity bool test_icase_(bool icase) { std::size_t count = this->bset_.count(); if(256 == count) { return false; // all set already, nothing to do } else if(0 != count && this->icase_ != icase) { this->set_all(); // icase mismatch! set all and bail return false; } this->icase_ = icase; return true; } bool icase_; std::bitset<256> bset_; }; }}} // namespace boost::xpressive::detail #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma warning(pop) #endif #endif
hash_peek_bitset.hpp
网页地址
文件地址
上一页
7/16
下一页
下载
( 4 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.