DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
/////////////////////////////////////////////////////////////////////////////// // simple_repeat_matcher.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_CORE_MATCHER_SIMPLE_REPEAT_MATCHER_HPP_EAN_10_04_2005 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_SIMPLE_REPEAT_MATCHER_HPP_EAN_10_04_2005 // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include
#include
#include
#include
#include
#include
#include
namespace boost { namespace xpressive { namespace detail { /////////////////////////////////////////////////////////////////////////////// // simple_repeat_traits // struct greedy_slow_tag {}; struct greedy_fast_tag {}; struct non_greedy_tag {}; typedef static_xpression
any_sxpr; typedef matcher_wrapper
any_dxpr; template
struct simple_repeat_traits { typedef typename mpl::if_
::type tag_type; }; template<> struct simple_repeat_traits
{ typedef greedy_fast_tag tag_type; }; template<> struct simple_repeat_traits
{ typedef greedy_fast_tag tag_type; }; /////////////////////////////////////////////////////////////////////////////// // simple_repeat_matcher // template
struct simple_repeat_matcher : quant_style_variable_width { typedef Xpr xpr_type; typedef mpl::bool_
greedy_type; Xpr xpr_; unsigned int min_, max_; std::size_t width_; simple_repeat_matcher(Xpr const &xpr, unsigned int min, unsigned int max, std::size_t width) : xpr_(xpr) , min_(min) , max_(max) , width_(width) { // it is the job of the parser to make sure this never happens BOOST_ASSERT(min <= max); BOOST_ASSERT(0 != max); BOOST_ASSERT(0 != width && unknown_width() != width); BOOST_ASSERT(Xpr::width == unknown_width() || Xpr::width == width); } template
bool match(match_state
&state, Next const &next) const { typedef mpl::bool_
::value> is_rand; typedef typename simple_repeat_traits
::tag_type tag_type; return this->match_(state, next, tag_type()); } // greedy, fixed-width quantifier template
bool match_(match_state
&state, Next const &next, greedy_slow_tag) const { int const diff = -static_cast
(Xpr::width == unknown_width::value ? this->width_ : Xpr::width); unsigned int matches = 0; BidiIter const tmp = state.cur_; // greedily match as much as we can while(matches < this->max_ && this->xpr_.match(state)) { ++matches; } if(this->min_ > matches) { state.cur_ = tmp; return false; } // try matching the rest of the pattern, and back off if necessary for(; ; --matches, std::advance(state.cur_, diff)) { if(next.match(state)) { return true; } else if(this->min_ == matches) { state.cur_ = tmp; return false; } } } // non-greedy fixed-width quantification template
bool match_(match_state
&state, Next const &next, non_greedy_tag) const { BidiIter const tmp = state.cur_; unsigned int matches = 0; for(; matches < this->min_; ++matches) { if(!this->xpr_.match(state)) { state.cur_ = tmp; return false; } } do { if(next.match(state)) { return true; } } while(matches++ < this->max_ && this->xpr_.match(state)); state.cur_ = tmp; return false; } // when greedily matching any character, skip to the end instead of iterating there. template
bool match_(match_state
&state, Next const &next, greedy_fast_tag) const { BidiIter const tmp = state.cur_; std::size_t const diff_to_end = static_cast
(state.end_ - tmp); // is there enough room? if(this->min_ > diff_to_end) { return false; } BidiIter const min_iter = tmp + this->min_; state.cur_ += (std::min)((std::size_t)this->max_, diff_to_end); for(;; --state.cur_) { if(next.match(state)) { return true; } else if(min_iter == state.cur_) { state.cur_ = tmp; return false; } } } detail::width get_width() const { if(this->min_ != this->max_) { return unknown_width::value; } return this->min_ * this->width_; } private: simple_repeat_matcher &operator =(simple_repeat_matcher const &); }; // BUGBUG can all non-greedy quantification be done with the fixed width quantifier? // BUGBUG matchers are chained together using static_xpression so that matchers to // the left can invoke matchers to the right. This is so that if the left matcher // succeeds but the right matcher fails, the left matcher is given the opportunity // to try something else. This is how backtracking works. However, if the left matcher // can succeed only one way (as with any_matcher, for example), it does not need // backtracking. In this case, leaving its stack frame active is a waste of stack // space. Can something be done? }}} #endif
simple_repeat_matcher.hpp
Page URL
File URL
Prev
34/36
Next
Download
( 6 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.