annotate DEPENDENCIES/generic/include/boost/spirit/home/x3/char/literal_char.hpp @ 133:4acb5d8d80b6 tip

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