ref_const_ref_actor.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_REF_CONST_REF_ACTOR_HPP
  8. #define BOOST_SPIRIT_ACTOR_REF_CONST_REF_ACTOR_HPP
  9. #include <boost/spirit/home/classic/namespace.hpp>
  10. namespace boost { namespace spirit {
  11. BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
  12. ///////////////////////////////////////////////////////////////////////////
  13. // Summary:
  14. // A semantic action policy holder. This holder stores a reference to ref
  15. // and a const reference to value_ref.
  16. // act methods are feed with ref and value_ref. The parse result is
  17. // not used by this holder.
  18. //
  19. // (This doc uses convention available in actors.hpp)
  20. //
  21. // Constructor:
  22. // ...(T& ref_, ValueT const& value_ref_);
  23. // where ref_ and value_ref_ are stored in the holder.
  24. //
  25. // Action calls:
  26. // act(ref, value_ref);
  27. //
  28. // () operators: both
  29. //
  30. ///////////////////////////////////////////////////////////////////////////
  31. template<
  32. typename T,
  33. typename ValueT,
  34. typename ActionT
  35. >
  36. class ref_const_ref_actor : public ActionT
  37. {
  38. private:
  39. T& ref;
  40. ValueT const& value_ref;
  41. public:
  42. ref_const_ref_actor(
  43. T& ref_,
  44. ValueT const& value_ref_
  45. )
  46. :
  47. ref(ref_),
  48. value_ref(value_ref_)
  49. {}
  50. template<typename T2>
  51. void operator()(T2 const& /*val*/) const
  52. {
  53. this->act(ref,value_ref); // defined in ActionT
  54. }
  55. template<typename IteratorT>
  56. void operator()(
  57. IteratorT const& /*first*/,
  58. IteratorT const& /*last*/
  59. ) const
  60. {
  61. this->act(ref,value_ref); // defined in ActionT
  62. }
  63. };
  64. BOOST_SPIRIT_CLASSIC_NAMESPACE_END
  65. }}
  66. #endif