ref_const_ref_const_ref_a.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_CONST_REF_ACTOR_HPP
  8. #define BOOST_SPIRIT_ACTOR_REF_CONST_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. // , a const reference to value1_ref and a const reference to value2_ref.
  16. // Typically, value1_ref is a key and value2_ref is value for associative
  17. // container operations.
  18. // act methods are feed with ref, value1_ref, value2_ref. The parse result
  19. // is not used by this holder.
  20. //
  21. // (This doc uses convention available in actors.hpp)
  22. //
  23. // Constructor:
  24. // ...(
  25. // T& ref_,
  26. // Value1T const& value1_ref_,
  27. // Value2T const& value2_ref_ );
  28. // where ref_, value1_ref and value2_ref_ are stored in the holder.
  29. //
  30. // Action calls:
  31. // act(ref, value1_ref, value2_ref);
  32. //
  33. // () operators: both
  34. //
  35. ///////////////////////////////////////////////////////////////////////////
  36. template<
  37. typename T,
  38. typename Value1T,
  39. typename Value2T,
  40. typename ActionT
  41. >
  42. class ref_const_ref_const_ref_actor : public ActionT
  43. {
  44. private:
  45. T& ref;
  46. Value1T const& value1_ref;
  47. Value2T const& value2_ref;
  48. public:
  49. ref_const_ref_const_ref_actor(
  50. T& ref_,
  51. Value1T const& value1_ref_,
  52. Value2T const& value2_ref_
  53. )
  54. :
  55. ref(ref_),
  56. value1_ref(value1_ref_),
  57. value2_ref(value2_ref_)
  58. {}
  59. template<typename T2>
  60. void operator()(T2 const& /*val*/) const
  61. {
  62. this->act(ref,value1_ref,value2_ref); // defined in ActionT
  63. }
  64. template<typename IteratorT>
  65. void operator()(
  66. IteratorT const& /*first*/,
  67. IteratorT const& /*last*/
  68. ) const
  69. {
  70. this->act(ref,value1_ref,value2_ref); // defined in ActionT
  71. }
  72. };
  73. BOOST_SPIRIT_CLASSIC_NAMESPACE_END
  74. }}
  75. #endif