File indexing completed on 2025-01-31 10:01:58
0001
0002
0003
0004
0005
0006
0007
0008
0009 #if !defined(BOOST_SPIRIT_AS_PARSER_HPP)
0010 #define BOOST_SPIRIT_AS_PARSER_HPP
0011
0012 #include <boost/spirit/home/classic/namespace.hpp>
0013 #include <boost/spirit/home/classic/core/primitives/primitives.hpp>
0014
0015 namespace boost { namespace spirit {
0016
0017 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 namespace impl
0028 {
0029 template<typename T>
0030 struct default_as_parser
0031 {
0032 typedef T type;
0033 static type const& convert(type const& p)
0034 {
0035 return p;
0036 }
0037 };
0038
0039 struct char_as_parser
0040 {
0041 typedef chlit<char> type;
0042 static type convert(char ch)
0043 {
0044 return type(ch);
0045 }
0046 };
0047
0048 struct wchar_as_parser
0049 {
0050 typedef chlit<wchar_t> type;
0051 static type convert(wchar_t ch)
0052 {
0053 return type(ch);
0054 }
0055 };
0056
0057 struct string_as_parser
0058 {
0059 typedef strlit<char const*> type;
0060 static type convert(char const* str)
0061 {
0062 return type(str);
0063 }
0064 };
0065
0066 struct wstring_as_parser
0067 {
0068 typedef strlit<wchar_t const*> type;
0069 static type convert(wchar_t const* str)
0070 {
0071 return type(str);
0072 }
0073 };
0074 }
0075
0076 template<typename T>
0077 struct as_parser : impl::default_as_parser<T> {};
0078
0079 template<>
0080 struct as_parser<char> : impl::char_as_parser {};
0081
0082 template<>
0083 struct as_parser<wchar_t> : impl::wchar_as_parser {};
0084
0085 template<>
0086 struct as_parser<char*> : impl::string_as_parser {};
0087
0088 template<>
0089 struct as_parser<char const*> : impl::string_as_parser {};
0090
0091 template<>
0092 struct as_parser<wchar_t*> : impl::wstring_as_parser {};
0093
0094 template<>
0095 struct as_parser<wchar_t const*> : impl::wstring_as_parser {};
0096
0097 template<int N>
0098 struct as_parser<char[N]> : impl::string_as_parser {};
0099
0100 template<int N>
0101 struct as_parser<wchar_t[N]> : impl::wstring_as_parser {};
0102
0103 template<int N>
0104 struct as_parser<char const[N]> : impl::string_as_parser {};
0105
0106 template<int N>
0107 struct as_parser<wchar_t const[N]> : impl::wstring_as_parser {};
0108
0109 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0110
0111 }}
0112
0113 #endif