annotate DEPENDENCIES/generic/include/boost/spirit/home/classic/meta/as_parser.hpp @ 118:770eb830ec19 emscripten

Typo fix
author Chris Cannam
date Wed, 18 May 2016 16:14:08 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*=============================================================================
Chris@16 2 Copyright (c) 2002-2003 Joel de Guzman
Chris@16 3 Copyright (c) 2002-2003 Hartmut Kaiser
Chris@16 4 http://spirit.sourceforge.net/
Chris@16 5
Chris@16 6 Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 =============================================================================*/
Chris@16 9 #if !defined(BOOST_SPIRIT_AS_PARSER_HPP)
Chris@16 10 #define BOOST_SPIRIT_AS_PARSER_HPP
Chris@16 11
Chris@16 12 #include <boost/spirit/home/classic/namespace.hpp>
Chris@16 13 #include <boost/spirit/home/classic/core/primitives/primitives.hpp>
Chris@16 14
Chris@16 15 namespace boost { namespace spirit {
Chris@16 16
Chris@16 17 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
Chris@16 18
Chris@16 19 ///////////////////////////////////////////////////////////////////////////
Chris@16 20 //
Chris@16 21 // Helper templates to derive the parser type from an auxilliary type
Chris@16 22 // and to generate an object of the required parser type given an
Chris@16 23 // auxilliary object. Supported types to convert are parsers,
Chris@16 24 // single characters and character strings.
Chris@16 25 //
Chris@16 26 ///////////////////////////////////////////////////////////////////////////
Chris@16 27 namespace impl
Chris@16 28 {
Chris@16 29 template<typename T>
Chris@16 30 struct default_as_parser
Chris@16 31 {
Chris@16 32 typedef T type;
Chris@16 33 static type const& convert(type const& p)
Chris@16 34 {
Chris@16 35 return p;
Chris@16 36 }
Chris@16 37 };
Chris@16 38
Chris@16 39 struct char_as_parser
Chris@16 40 {
Chris@16 41 typedef chlit<char> type;
Chris@16 42 static type convert(char ch)
Chris@16 43 {
Chris@16 44 return type(ch);
Chris@16 45 }
Chris@16 46 };
Chris@16 47
Chris@16 48 struct wchar_as_parser
Chris@16 49 {
Chris@16 50 typedef chlit<wchar_t> type;
Chris@16 51 static type convert(wchar_t ch)
Chris@16 52 {
Chris@16 53 return type(ch);
Chris@16 54 }
Chris@16 55 };
Chris@16 56
Chris@16 57 struct string_as_parser
Chris@16 58 {
Chris@16 59 typedef strlit<char const*> type;
Chris@16 60 static type convert(char const* str)
Chris@16 61 {
Chris@16 62 return type(str);
Chris@16 63 }
Chris@16 64 };
Chris@16 65
Chris@16 66 struct wstring_as_parser
Chris@16 67 {
Chris@16 68 typedef strlit<wchar_t const*> type;
Chris@16 69 static type convert(wchar_t const* str)
Chris@16 70 {
Chris@16 71 return type(str);
Chris@16 72 }
Chris@16 73 };
Chris@16 74 }
Chris@16 75
Chris@16 76 template<typename T>
Chris@16 77 struct as_parser : impl::default_as_parser<T> {};
Chris@16 78
Chris@16 79 template<>
Chris@16 80 struct as_parser<char> : impl::char_as_parser {};
Chris@16 81
Chris@16 82 template<>
Chris@16 83 struct as_parser<wchar_t> : impl::wchar_as_parser {};
Chris@16 84
Chris@16 85 template<>
Chris@16 86 struct as_parser<char*> : impl::string_as_parser {};
Chris@16 87
Chris@16 88 template<>
Chris@16 89 struct as_parser<char const*> : impl::string_as_parser {};
Chris@16 90
Chris@16 91 template<>
Chris@16 92 struct as_parser<wchar_t*> : impl::wstring_as_parser {};
Chris@16 93
Chris@16 94 template<>
Chris@16 95 struct as_parser<wchar_t const*> : impl::wstring_as_parser {};
Chris@16 96
Chris@16 97 template<int N>
Chris@16 98 struct as_parser<char[N]> : impl::string_as_parser {};
Chris@16 99
Chris@16 100 template<int N>
Chris@16 101 struct as_parser<wchar_t[N]> : impl::wstring_as_parser {};
Chris@16 102
Chris@16 103 template<int N>
Chris@16 104 struct as_parser<char const[N]> : impl::string_as_parser {};
Chris@16 105
Chris@16 106 template<int N>
Chris@16 107 struct as_parser<wchar_t const[N]> : impl::wstring_as_parser {};
Chris@16 108
Chris@16 109 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
Chris@16 110
Chris@16 111 }} // namespace BOOST_SPIRIT_CLASSIC_NS
Chris@16 112
Chris@16 113 #endif