source: NonGTP/Boost/boost/wave/language_support.hpp @ 857

Revision 857, 6.6 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1/*=============================================================================
2    Boost.Wave: A Standard compliant C++ preprocessor library
3    Definition of the various language support constants
4   
5    http://www.boost.org/
6
7    Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
8    Software License, Version 1.0. (See accompanying file
9    LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10=============================================================================*/
11#if !defined(LANGUAGE_SUPPORT_HPP_93EDD057_2DEF_44BC_BC9F_FDABB9F51AFA_INCLUDED)
12#define LANGUAGE_SUPPORT_HPP_93EDD057_2DEF_44BC_BC9F_FDABB9F51AFA_INCLUDED
13
14#include <boost/wave/wave_config.hpp>
15
16///////////////////////////////////////////////////////////////////////////////
17namespace boost {
18namespace wave {
19
20enum language_support {
21//  support flags for C++98
22    support_normal = 0x01,
23    support_cpp = support_normal,
24   
25    support_long_long = 0x02,
26
27#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
28//  support flags for C99
29    support_variadics = 0x04,
30    support_c99 = support_variadics | support_long_long | 0x08,
31#endif
32
33    support_option_mask = 0xFF00,
34    support_option_preserve_comments = 0x0100,
35    support_option_no_character_validation = 0x0200,
36    support_option_convert_trigraphs = 0x0400,
37    support_option_single_line = 0x0800
38};
39
40///////////////////////////////////////////////////////////////////////////////
41// 
42//  need_cpp
43//
44//      Extract, if the language to support is C++98
45//
46///////////////////////////////////////////////////////////////////////////////
47inline bool
48need_cpp(language_support language)
49{
50    return (language & ~support_option_mask) == support_cpp;
51}
52
53///////////////////////////////////////////////////////////////////////////////
54// 
55//  need_long_long
56//
57//      Extract, if the language to support needs long long support
58//
59///////////////////////////////////////////////////////////////////////////////
60inline bool
61need_long_long(language_support language)
62{
63    return (language & support_long_long) ? true : false;
64}
65
66///////////////////////////////////////////////////////////////////////////////
67// 
68//  enable_long_long
69//
70//      Set long long support in the language to support
71//
72///////////////////////////////////////////////////////////////////////////////
73inline language_support
74enable_long_long(language_support language, bool enable = true)
75{
76    if (enable)
77        return static_cast<language_support>(language | support_long_long);
78    return static_cast<language_support>(language & ~support_long_long);
79}
80
81#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
82
83///////////////////////////////////////////////////////////////////////////////
84// 
85//  need_variadics
86//
87//      Extract, if the language to support needs variadics support
88//
89///////////////////////////////////////////////////////////////////////////////
90inline bool
91need_variadics(language_support language)
92{
93    return (language & support_variadics) ? true : false;
94}
95
96///////////////////////////////////////////////////////////////////////////////
97// 
98//  enable_variadics
99//
100//      Set variadics support in the language to support
101//
102///////////////////////////////////////////////////////////////////////////////
103inline language_support
104enable_variadics(language_support language, bool enable = true)
105{
106    if (enable)
107        return static_cast<language_support>(language | support_variadics);
108    return static_cast<language_support>(language & ~support_variadics);
109}
110
111///////////////////////////////////////////////////////////////////////////////
112// 
113//  need_c99
114//
115//      Extract, if the language to support is C99
116//
117///////////////////////////////////////////////////////////////////////////////
118inline bool
119need_c99(language_support language)
120{
121    return (language & ~support_option_mask) == support_c99;
122}
123
124#else  // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
125
126///////////////////////////////////////////////////////////////////////////////
127inline bool
128need_variadics(language_support language)
129{
130    return false;
131}
132
133///////////////////////////////////////////////////////////////////////////////
134inline language_support
135enable_variadics(language_support language, bool enable = true)
136{
137    return language;
138}
139
140//////////////////////////////////////////////////////////////////////////////
141inline bool
142need_c99(language_support language)
143{
144    return false;
145}
146
147#endif // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
148
149///////////////////////////////////////////////////////////////////////////////
150// 
151//  need_preserve_comments
152//
153//      Extract, if the comments have to be preserved
154//
155///////////////////////////////////////////////////////////////////////////////
156inline bool
157need_preserve_comments(language_support language)
158{
159    return (language & support_option_preserve_comments) ? true : false;
160}
161
162///////////////////////////////////////////////////////////////////////////////
163// 
164//  enable_preserve_comments
165//
166//      Set preserve comments support in the language to support
167//
168///////////////////////////////////////////////////////////////////////////////
169inline language_support
170enable_preserve_comments(language_support language, bool enable = true)
171{
172    if (enable)
173        return static_cast<language_support>(language | support_option_preserve_comments);
174    return static_cast<language_support>(language & ~support_option_preserve_comments);
175}
176
177///////////////////////////////////////////////////////////////////////////////
178// 
179//  get_support_options
180//
181//      Set preserve comments support in the language to support
182//
183///////////////////////////////////////////////////////////////////////////////
184inline language_support
185get_support_options(language_support language)
186{
187    return static_cast<language_support>(language & support_option_mask);
188}
189
190///////////////////////////////////////////////////////////////////////////////
191// 
192//  set_support_options
193//
194//      Set language option (for fine tuning of lexer bahaviour)
195//
196///////////////////////////////////////////////////////////////////////////////
197inline language_support
198set_support_options(language_support language, language_support option)
199{
200    return static_cast<language_support>(
201        (language & ~support_option_mask) | (option & support_option_mask));
202}
203
204///////////////////////////////////////////////////////////////////////////////
205}   // namespace wave
206}   // namespace boost
207
208#endif // !defined(LANGUAGE_SUPPORT_HPP_93EDD057_2DEF_44BC_BC9F_FDABB9F51AFA_INCLUDED)
Note: See TracBrowser for help on using the repository browser.