clear_actor.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*=============================================================================
  2. Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
  3. http://spirit.sourceforge.net/
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. =============================================================================*/
  7. #ifndef BOOST_SPIRIT_ACTOR_CLEAR_ACTOR_HPP
  8. #define BOOST_SPIRIT_ACTOR_CLEAR_ACTOR_HPP
  9. #include <boost/spirit/home/classic/namespace.hpp>
  10. #include <boost/spirit/home/classic/actor/ref_actor.hpp>
  11. namespace boost { namespace spirit {
  12. BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
  13. ///////////////////////////////////////////////////////////////////////////
  14. // Summary:
  15. // A semantic action policy that calls clear method.
  16. // (This doc uses convention available in actors.hpp)
  17. //
  18. // Actions (what it does):
  19. // ref.clear();
  20. //
  21. // Policy name:
  22. // clear_action
  23. //
  24. // Policy holder, corresponding helper method:
  25. // ref_actor, clear_a( ref );
  26. //
  27. // () operators: both.
  28. //
  29. // See also ref_actor for more details.
  30. ///////////////////////////////////////////////////////////////////////////
  31. struct clear_action
  32. {
  33. template<
  34. typename T
  35. >
  36. void act(T& ref_) const
  37. {
  38. ref_.clear();
  39. }
  40. };
  41. ///////////////////////////////////////////////////////////////////////////
  42. // helper method that creates a and_assign_actor.
  43. ///////////////////////////////////////////////////////////////////////////
  44. template<typename T>
  45. inline ref_actor<T,clear_action> clear_a(T& ref_)
  46. {
  47. return ref_actor<T,clear_action>(ref_);
  48. }
  49. BOOST_SPIRIT_CLASSIC_NAMESPACE_END
  50. }}
  51. #endif