what_function.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #if !defined(SPIRIT_WHAT_FUNCTION_APRIL_22_2007_0236PM)
  7. #define SPIRIT_WHAT_FUNCTION_APRIL_22_2007_0236PM
  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. template <typename Context>
  17. struct what_function
  18. {
  19. what_function(info& what_, Context& context_)
  20. : what(what_), context(context_)
  21. {
  22. what.value = std::list<info>();
  23. }
  24. template <typename Component>
  25. void operator()(Component const& component) const
  26. {
  27. #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
  28. component; // suppresses warning: C4100: 'component' : unreferenced formal parameter
  29. #endif
  30. boost::get<std::list<info> >(what.value).
  31. push_back(component.what(context));
  32. }
  33. info& what;
  34. Context& context;
  35. // silence MSVC warning C4512: assignment operator could not be generated
  36. BOOST_DELETED_FUNCTION(what_function& operator= (what_function const&))
  37. };
  38. }}}
  39. #endif