what_function.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. =============================================================================*/
  6. #ifndef BOOST_SPIRIT_SUPPORT_DETAIL_WHAT_FUNCTION_HPP
  7. #define BOOST_SPIRIT_SUPPORT_DETAIL_WHAT_FUNCTION_HPP
  8. #if defined(_MSC_VER)
  9. #pragma once
  10. #endif
  11. #include <string>
  12. #include <boost/spirit/home/support/info.hpp>
  13. #include <boost/detail/workaround.hpp>
  14. namespace boost { namespace spirit { namespace detail
  15. {
  16. #ifdef _MSC_VER
  17. # pragma warning(push)
  18. # pragma warning(disable: 4512) // assignment operator could not be generated.
  19. #endif
  20. template <typename Context>
  21. struct what_function
  22. {
  23. what_function(info& what_, Context& context_)
  24. : what(what_), context(context_)
  25. {
  26. what.value = std::list<info>();
  27. }
  28. template <typename Component>
  29. void operator()(Component const& component) const
  30. {
  31. #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
  32. (void)component; // suppresses warning: C4100: 'component' : unreferenced formal parameter
  33. #endif
  34. boost::get<std::list<info> >(what.value).
  35. push_back(component.what(context));
  36. }
  37. info& what;
  38. Context& context;
  39. };
  40. #ifdef _MSC_VER
  41. # pragma warning(pop)
  42. #endif
  43. }}}
  44. #endif