Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/spirit/home/x3/char/literal_char.hpp @ 102:f46d142149f5
Whoops, finish that update
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:13:41 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
101:c530137014c0 | 102:f46d142149f5 |
---|---|
1 /*============================================================================= | |
2 Copyright (c) 2001-2014 Joel de Guzman | |
3 | |
4 Distributed under the Boost Software License, Version 1.0. (See accompanying | |
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 ==============================================================================*/ | |
7 #if !defined(BOOST_SPIRIT_X3_LITERAL_CHAR_APRIL_16_2006_1051AM) | |
8 #define BOOST_SPIRIT_X3_LITERAL_CHAR_APRIL_16_2006_1051AM | |
9 | |
10 #if defined(_MSC_VER) | |
11 #pragma once | |
12 #endif | |
13 | |
14 #include <boost/spirit/home/x3/char/char_parser.hpp> | |
15 #include <boost/spirit/home/x3/support/utility/utf8.hpp> | |
16 #include <boost/type_traits/is_same.hpp> | |
17 | |
18 namespace boost { namespace spirit { namespace x3 | |
19 { | |
20 template <typename Encoding, typename Attribute = typename Encoding::char_type> | |
21 struct literal_char : char_parser<literal_char<Encoding, Attribute>> | |
22 { | |
23 typedef typename Encoding::char_type char_type; | |
24 typedef Encoding encoding; | |
25 typedef Attribute attribute_type; | |
26 static bool const has_attribute = | |
27 !is_same<unused_type, attribute_type>::value; | |
28 | |
29 template <typename Char> | |
30 literal_char(Char ch) | |
31 : ch(static_cast<char_type>(ch)) {} | |
32 | |
33 template <typename Char, typename Context> | |
34 bool test(Char ch_, Context const&) const | |
35 { | |
36 return ((sizeof(Char) <= sizeof(char_type)) || encoding::ischar(ch_)) | |
37 && ch == char_type(ch_); | |
38 } | |
39 | |
40 char_type ch; | |
41 }; | |
42 | |
43 template <typename Encoding, typename Attribute> | |
44 struct get_info<literal_char<Encoding, Attribute>> | |
45 { | |
46 typedef std::string result_type; | |
47 std::string operator()(literal_char<Encoding, Attribute> const& p) const | |
48 { | |
49 return '\'' + to_utf8(Encoding::toucs4(p.ch)) + '\''; | |
50 } | |
51 }; | |
52 }}} | |
53 | |
54 #endif |