x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
escape_char.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\spirit\utility\escape_char.hpp
旋转
特效
属性
历史版本
/*============================================================================= Copyright (c) 2001-2003 Daniel Nuffer http://spirit.sourceforge.net/ Use, modification and distribution is subject to 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_SPIRIT_ESCAPE_CHAR_HPP #define BOOST_SPIRIT_ESCAPE_CHAR_HPP /////////////////////////////////////////////////////////////////////////////// #include
#include
#include
#include
#include
#include
#include
/////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { /////////////////////////////////////////////////////////////////////////////// // // escape_char_action class // // Links an escape char parser with a user defined semantic action. // The semantic action may be a function or a functor. A function // should be compatible with the interface: // // void f(CharT ch); // // A functor should have a member operator() with a compatible signature // as above. The matching character is passed into the function/functor. // This is the default class that character parsers use when dealing with // the construct: // // p[f] // // where p is a parser and f is a function or functor. // /////////////////////////////////////////////////////////////////////////////// template < typename ParserT, typename ActionT, unsigned long Flags, typename CharT > struct escape_char_action : public unary
> > { typedef escape_char_action
self_t; typedef action_parser_category parser_category_t; typedef unary
> base_t; template
struct result { typedef typename match_result
::type type; }; escape_char_action(ParserT const& p, ActionT const& a) : base_t(p), actor(a) {} template
typename parser_result
::type parse(ScannerT const& scan) const { return impl::escape_char_action_parse
:: parse(scan, *this); } ActionT const& predicate() const { return actor; } private: ActionT actor; }; /////////////////////////////////////////////////////////////////////////////// // // escape_char_parser class // // The escape_char_parser helps in conjunction with the escape_char_action // template class (see above) in parsing escaped characters. There are two // different variants of this parser: one for parsing C style escaped // characters and one for parsing LEX style escaped characters. // // The C style escaped character parser is generated, when the template // parameter 'Flags' is equal to 'c_escapes' (a constant defined in the // file impl/escape_char.ipp). This parser recognizes all valid C escape // character sequences: '\t', '\b', '\f', '\n', '\r', '\"', '\'', '\\' // and the numeric style escapes '\120' (octal) and '\x2f' (hexadecimal) // and converts these to their character equivalent, for instance the // sequence of a backslash and a 'b' is parsed as the character '\b'. // All other escaped characters are rejected by this parser. // // The LEX style escaped character parser is generated, when the template // parameter 'Flags' is equal to 'lex_escapes' (a constant defined in the // file impl/escape_char.ipp). This parser recognizes all the C style // escaped character sequences (as described above) and additionally // does not reject all other escape sequences. All not mentioned escape // sequences are converted by the parser to the plain character, for // instance '\a' will be parsed as 'a'. // // All not escaped characters are parsed without modification. // /////////////////////////////////////////////////////////////////////////////// template
struct escape_char_action_parser_gen; template
struct escape_char_parser : public parser
> { // only the values c_escapes and lex_escapes are valid for Flags BOOST_STATIC_ASSERT(Flags == c_escapes || Flags == lex_escapes); typedef escape_char_parser
self_t; typedef escape_char_action_parser_gen
action_parser_generator_t; template
struct result { typedef typename match_result
::type type; }; template
escape_char_action
operator[](ActionT const& actor) const { return escape_char_action
(*this, actor); } template
typename parser_result
::type parse(ScannerT const &scan) const { return impl::escape_char_parse
::parse(scan, *this); } }; template
struct escape_char_action_parser_gen { template
static escape_char_action
generate (ParserT const &p, ActionT const &actor) { typedef escape_char_action
action_parser_t; return action_parser_t(p, actor); } }; /////////////////////////////////////////////////////////////////////////////// // // predefined escape_char_parser objects // // These objects should be used for generating correct escaped character // parsers. // /////////////////////////////////////////////////////////////////////////////// const escape_char_parser
lex_escape_ch_p = escape_char_parser
(); const escape_char_parser
c_escape_ch_p = escape_char_parser
(); /////////////////////////////////////////////////////////////////////////////// }} // namespace boost::spirit #endif
escape_char.hpp
网页地址
文件地址
上一页
7/19
下一页
下载
( 6 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.