Click here to Skip to main content
15,881,757 members
Articles / Programming Languages / C++

Wave: a Standard conformant C++ preprocessor library

Rate me:
Please Sign up or sign in to vote.
4.96/5 (58 votes)
10 Jan 200413 min read 394.6K   4.4K   81  
Describes a free and fully Standard conformant C++ preprocessor library
/*=============================================================================
    Wave: A Standard compliant C++ preprocessor

    Definition of the various language support constants
    
    Copyright (c) 2001-2003 Hartmut Kaiser
    http://spirit.sourceforge.net/

    Permission to copy, use, modify, sell and distribute this software
    is granted provided this copyright notice appears in all copies.
    This software is provided "as is" without express or implied
    warranty, and with no claim as to its suitability for any purpose.

    See Copyright.txt for full copyright notices and acknowledgements.
=============================================================================*/
#if !defined(LANGUAGE_SUPPORT_HPP_93EDD057_2DEF_44BC_BC9F_FDABB9F51AFA_INCLUDED)
#define LANGUAGE_SUPPORT_HPP_93EDD057_2DEF_44BC_BC9F_FDABB9F51AFA_INCLUDED

///////////////////////////////////////////////////////////////////////////////
namespace wave {

enum language_support {
//  support flags for C++98
    support_normal = 0x01,
    support_cpp = support_normal,
    
#if defined(WAVE_SUPPORT_VARIADICS_PLACEMARKERS)
//  support flags for C99
    support_variadics = 0x02,
    support_c99 = support_variadics,
    
#if defined(WAVE_ENABLE_CPP0X_EXTENSIONS)
//  support flags for the experimental C++0x features
    support_extensions = 0x04,
    support_cpp0x = support_normal | support_variadics | support_extensions,
#endif // defined(WAVE_ENABLE_CPP0X_EXTENSIONS)
#endif // defined(WAVE_SUPPORT_VARIADICS_PLACEMARKERS)
};

///////////////////////////////////////////////////////////////////////////////
//  
//  need_cpp
//
//      Extract, if the language to support is C++98
//
///////////////////////////////////////////////////////////////////////////////
inline bool
need_cpp(language_support language) 
{
    return language == support_cpp;
}

#if defined(WAVE_SUPPORT_VARIADICS_PLACEMARKERS)

///////////////////////////////////////////////////////////////////////////////
//  
//  need_variadics
//
//      Extract, if the language to support needs variadics support
//
///////////////////////////////////////////////////////////////////////////////
inline bool 
need_variadics(language_support language) 
{
    return language & support_variadics;
}

///////////////////////////////////////////////////////////////////////////////
//  
//  enable_variadics
//
//      Set variadics support in the language to support
//
///////////////////////////////////////////////////////////////////////////////
inline language_support
enable_variadics(language_support language, bool enable = true)
{
    if (enable)
        return static_cast<language_support>(language | support_variadics);
    return static_cast<language_support>(language & ~support_variadics);
}

///////////////////////////////////////////////////////////////////////////////
//  
//  need_c99
//
//      Extract, if the language to support is C99
//
///////////////////////////////////////////////////////////////////////////////
inline bool
need_c99(language_support language) 
{
    return language == support_c99;
}

///////////////////////////////////////////////////////////////////////////////
//  
//  enable_c99
//
//      Set, whether to support C99 (alternatively C++98 is supported)
//
///////////////////////////////////////////////////////////////////////////////
inline language_support
enable_c99(bool enable = true)
{
    return enable ? support_c99 : support_normal;
}

#if defined(WAVE_ENABLE_CPP0X_EXTENSIONS)
///////////////////////////////////////////////////////////////////////////////
//  
//  need_cpp0x
//
//      Extract, if the language to support is C++0x
//
///////////////////////////////////////////////////////////////////////////////
inline bool
need_cpp0x(language_support language) 
{
    return language == support_cpp0x;
}

///////////////////////////////////////////////////////////////////////////////
//  
//  enable_c99
//
//      Set, whether to support the C++0x features (alternatively C++98 is 
//      supported)
//
///////////////////////////////////////////////////////////////////////////////
inline language_support
enable_cpp0x(bool enable = true)
{
    return enable ? support_cpp0x : support_normal;
}

#endif // defined(WAVE_ENABLE_CPP0X_EXTENSIONS)
#endif // defined(WAVE_SUPPORT_VARIADICS_PLACEMARKERS)

///////////////////////////////////////////////////////////////////////////////
}   // namespace wave

#endif // !defined(LANGUAGE_SUPPORT_HPP_93EDD057_2DEF_44BC_BC9F_FDABB9F51AFA_INCLUDED)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
Actively involved in Boost and the development of the Spirit parser construction framework.

Comments and Discussions