comparison DEPENDENCIES/generic/include/boost/spirit/home/x3/numeric/uint.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 Copyright (c) 2011 Jan Frederick Eick
4
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #if !defined(BOOST_SPIRIT_X3_UINT_APR_17_2006_0901AM)
9 #define BOOST_SPIRIT_X3_UINT_APR_17_2006_0901AM
10
11 #if defined(_MSC_VER)
12 #pragma once
13 #endif
14
15 #include <boost/spirit/home/x3/core/parser.hpp>
16 #include <boost/spirit/home/x3/core/skip_over.hpp>
17 #include <boost/spirit/home/x3/support/numeric_utils/extract_int.hpp>
18 #include <cstdint>
19
20 namespace boost { namespace spirit { namespace x3
21 {
22 ///////////////////////////////////////////////////////////////////////////
23 template <
24 typename T
25 , unsigned Radix = 10
26 , unsigned MinDigits = 1
27 , int MaxDigits = -1>
28 struct uint_parser : parser<uint_parser<T, Radix, MinDigits, MaxDigits>>
29 {
30 // check template parameter 'Radix' for validity
31 static_assert(
32 (Radix >= 2 && Radix <= 36),
33 "Error Unsupported Radix");
34
35 typedef T attribute_type;
36 static bool const has_attribute = true;
37
38 template <typename Iterator, typename Context, typename Attribute>
39 bool parse(Iterator& first, Iterator const& last
40 , Context const& context, unused_type, Attribute& attr) const
41 {
42 typedef extract_uint<T, Radix, MinDigits, MaxDigits> extract;
43 x3::skip_over(first, last, context);
44 return extract::call(first, last, attr);
45 }
46 };
47
48 #define BOOST_SPIRIT_X3_UINT_PARSER(uint_type, name) \
49 typedef uint_parser<uint_type> name##type; \
50 name##type const name = {}; \
51 /***/
52
53 BOOST_SPIRIT_X3_UINT_PARSER(unsigned long, ulong_)
54 BOOST_SPIRIT_X3_UINT_PARSER(unsigned short, ushort_)
55 BOOST_SPIRIT_X3_UINT_PARSER(unsigned int, uint_)
56 BOOST_SPIRIT_X3_UINT_PARSER(unsigned long long, ulong_long)
57
58 BOOST_SPIRIT_X3_UINT_PARSER(uint8_t, uint8)
59 BOOST_SPIRIT_X3_UINT_PARSER(uint16_t, uint16)
60 BOOST_SPIRIT_X3_UINT_PARSER(uint32_t, uint32)
61 BOOST_SPIRIT_X3_UINT_PARSER(uint64_t, uint64)
62
63 #undef BOOST_SPIRIT_X3_UINT_PARSER
64
65 #define BOOST_SPIRIT_X3_UINT_PARSER(uint_type, radix, name) \
66 typedef uint_parser<uint_type, radix> name##type; \
67 name##type const name = name##type(); \
68 /***/
69
70 BOOST_SPIRIT_X3_UINT_PARSER(unsigned, 2, bin)
71 BOOST_SPIRIT_X3_UINT_PARSER(unsigned, 8, oct)
72 BOOST_SPIRIT_X3_UINT_PARSER(unsigned, 16, hex)
73
74 #undef BOOST_SPIRIT_X3_UINT_PARSER
75
76
77 }}}
78
79 #endif