LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
-#if !defined(CPP_MACROMAP_UTIL_HPP_HK041119)
-#define CPP_MACROMAP_UTIL_HPP_HK041119
+#if !defined(BOOST_CPP_MACROMAP_UTIL_HPP_HK041119)
+#define BOOST_CPP_MACROMAP_UTIL_HPP_HK041119
#include <boost/assert.hpp>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/util/unput_queue_iterator.hpp>
+#include <boost/wave/language_support.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
// Test, whether a given identifier resolves to a predefined name
//
///////////////////////////////////////////////////////////////////////////////
-template <typename StringT>
+template <typename ContextT, typename StringT>
inline bool
-is_special_macroname (StringT const &name)
+is_special_macroname (ContextT const & ctx, StringT const &name)
{
if (name.size() < 7)
return false;
if ("defined" == name)
return true;
+#if BOOST_WAVE_SUPPORT_HAS_INCLUDE != 0
+ if (boost::wave::need_has_include(ctx.get_language()) &&
+ ("__has_include" == name))
+ return true;
+#endif
+
if ('_' == name[0] && '_' == name[1]) {
- StringT str = name.substr(2);
+ StringT str = name.substr(2);
if (str == "cplusplus" || str == "STDC__" ||
str == "TIME__" || str == "DATE__" ||
using namespace boost::wave;
if (IS_CATEGORY(left, ParameterTokenType)) {
- // if the existing token is of type T_PARAMETERBASE, then the right token
- // must be of type T_IDENTIFIER or a keyword
- token_id id = token_id(right);
+ // if the existing token is of type T_PARAMETERBASE, then the right token
+ // must be of type T_IDENTIFIER or a keyword
+ token_id id = token_id(right);
return (T_IDENTIFIER == id ||
IS_CATEGORY(id, KeywordTokenType) ||
{
typedef typename ContainerT::const_iterator const_iterator_type;
-const_iterator_type first1 = definition.begin();
-const_iterator_type last1 = definition.end();
-const_iterator_type first2 = new_definition.begin();
-const_iterator_type last2 = new_definition.end();
+ const_iterator_type first1 = definition.begin();
+ const_iterator_type last1 = definition.end();
+ const_iterator_type first2 = new_definition.begin();
+ const_iterator_type last2 = new_definition.end();
while (first1 != last1 && first2 != last2 && token_equals(*first1, *first2))
{
- // skip whitespace, if both sequences have a whitespace next
- token_id id1 = next_token<const_iterator_type>::peek(first1, last1, false);
- token_id id2 = next_token<const_iterator_type>::peek(first2, last2, false);
+ // skip whitespace, if both sequences have a whitespace next
+ token_id id1 = next_token<const_iterator_type>::peek(first1, last1, false);
+ token_id id2 = next_token<const_iterator_type>::peek(first2, last2, false);
if (IS_CATEGORY(id1, WhiteSpaceTokenType) &&
IS_CATEGORY(id2, WhiteSpaceTokenType))
{
- // all consecutive whitespace tokens count as one whitespace
- // adjust first1 and first2 accordingly
+ // all consecutive whitespace tokens count as one whitespace
+ // adjust first1 and first2 accordingly
skip_whitespace(first1, last1);
skip_whitespace(first2, last2);
}
++first2;
}
else {
- // the sequences differ
+ // the sequences differ
break;
}
}
typedef typename ContainerT::const_iterator const_iterator_type;
-const_iterator_type first1 = parameters.begin();
-const_iterator_type last1 = parameters.end();
-const_iterator_type first2 = new_parameters.begin();
-const_iterator_type last2 = new_parameters.end();
+ const_iterator_type first1 = parameters.begin();
+ const_iterator_type last1 = parameters.end();
+ const_iterator_type first2 = new_parameters.begin();
+ const_iterator_type last2 = new_parameters.end();
while (first1 != last1 && first2 != last2) {
- // parameters are different, if the corresponding tokens are different
+ // parameters are different, if the corresponding tokens are different
using namespace boost::wave;
if (token_id(*first1) != token_id(*first2) ||
(*first1).get_value() != (*first2).get_value())
{
using namespace boost::wave;
-// strip leading whitespace
+ // strip leading whitespace
if (replacement_list.size() > 0) {
- typename ContainerT::iterator end = replacement_list.end();
- typename ContainerT::iterator it = replacement_list.begin();
+ typename ContainerT::iterator end = replacement_list.end();
+ typename ContainerT::iterator it = replacement_list.begin();
while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) {
token_id id(*it);
}
}
-// strip trailing whitespace
+ // strip trailing whitespace
if (replacement_list.size() > 0) {
- typename ContainerT::reverse_iterator rend = replacement_list.rend();
- typename ContainerT::reverse_iterator rit = replacement_list.rbegin();
+ typename ContainerT::reverse_iterator rend = replacement_list.rend();
+ typename ContainerT::reverse_iterator rit = replacement_list.rbegin();
while (rit != rend && IS_CATEGORY(*rit, WhiteSpaceTokenType))
++rit;
- typename ContainerT::iterator end = replacement_list.end();
- typename ContainerT::iterator it = rit.base();
+ typename ContainerT::iterator end = replacement_list.end();
+ typename ContainerT::iterator it = rit.base();
while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) {
token_id id(*it);
return true;
}
+///////////////////////////////////////////////////////////////////////////////
+//
+// Tests whether the given token sequence consists only of whitespace
+// and placemarkers
+//
+///////////////////////////////////////////////////////////////////////////////
+template <typename ContainerT>
+inline bool
+is_blank_only (ContainerT const &argument)
+{
+ typename ContainerT::const_iterator end = argument.end();
+ for (typename ContainerT::const_iterator it = argument.begin();
+ it != end; ++it)
+ {
+ if (!IS_CATEGORY(*it, WhiteSpaceTokenType) &&
+ (T_PLACEMARKER != token_id(*it)))
+ return false;
+ }
+ return true;
+}
+
///////////////////////////////////////////////////////////////////////////////
//
// Remove all placeholder tokens from the given token sequence
{
using namespace boost::wave;
-// strip leading whitespace
+ // strip leading whitespace
if (replacement_list.size() > 0) {
- typename ContainerT::iterator end = replacement_list.end();
- typename ContainerT::iterator it = replacement_list.begin();
+ typename ContainerT::iterator end = replacement_list.end();
+ typename ContainerT::iterator it = replacement_list.begin();
while (it != end) {
token_id id(*it);
}
}
- // remove all 'new' leading and trailing whitespace
+ // remove all 'new' leading and trailing whitespace
if (is_whitespace_only(replacement_list))
trim_replacement_list(replacement_list);
}
{
using namespace boost::wave;
-// strip leading whitespace (should be only one token)
+ // strip leading whitespace (should be only one token)
if (argument.size() > 0 &&
IS_CATEGORY(argument.front(), WhiteSpaceTokenType))
{
{
using namespace boost::wave;
-// strip trailing whitespace (should be only one token)
+ // strip trailing whitespace (should be only one token)
if (argument.size() > 0 &&
IS_CATEGORY(argument.back(), WhiteSpaceTokenType))
{
#include BOOST_ABI_SUFFIX
#endif
-#endif // !defined(CPP_MACROMAP_UTIL_HPP_HK041119)
+#endif // !defined(BOOST_CPP_MACROMAP_UTIL_HPP_HK041119)