/Src/Dependencies/Boost/boost/spirit/home/qi/directive/omit.hpp

http://hadesmem.googlecode.com/ · C++ Header · 107 lines · 74 code · 14 blank · 19 comment · 0 complexity · 7a0c1fca3df652f061d5e025e4ec2a19 MD5 · raw file

  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_OMIT_MARCH_24_2007_0802AM)
  7. #define SPIRIT_OMIT_MARCH_24_2007_0802AM
  8. #if defined(_MSC_VER)
  9. #pragma once
  10. #endif
  11. #include <boost/spirit/home/qi/meta_compiler.hpp>
  12. #include <boost/spirit/home/qi/skip_over.hpp>
  13. #include <boost/spirit/home/qi/parser.hpp>
  14. #include <boost/spirit/home/support/unused.hpp>
  15. #include <boost/spirit/home/support/info.hpp>
  16. #include <boost/spirit/home/support/common_terminals.hpp>
  17. #include <boost/spirit/home/support/has_semantic_action.hpp>
  18. #include <boost/spirit/home/support/handles_container.hpp>
  19. namespace boost { namespace spirit
  20. {
  21. ///////////////////////////////////////////////////////////////////////////
  22. // Enablers
  23. ///////////////////////////////////////////////////////////////////////////
  24. template <>
  25. struct use_directive<qi::domain, tag::omit> // enables omit
  26. : mpl::true_ {};
  27. }}
  28. namespace boost { namespace spirit { namespace qi
  29. {
  30. #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
  31. using spirit::omit;
  32. #endif
  33. using spirit::omit_type;
  34. ///////////////////////////////////////////////////////////////////////////
  35. // omit_directive forces the attribute of subject parser
  36. // to be unused_type
  37. ///////////////////////////////////////////////////////////////////////////
  38. template <typename Subject>
  39. struct omit_directive : unary_parser<omit_directive<Subject> >
  40. {
  41. typedef Subject subject_type;
  42. omit_directive(Subject const& subject)
  43. : subject(subject) {}
  44. template <typename Context, typename Iterator>
  45. struct attribute
  46. {
  47. typedef unused_type type;
  48. };
  49. template <typename Iterator, typename Context
  50. , typename Skipper, typename Attribute>
  51. bool parse(Iterator& first, Iterator const& last
  52. , Context& context, Skipper const& skipper, Attribute& attr) const
  53. {
  54. return subject.parse(first, last, context, skipper, attr);
  55. }
  56. template <typename Context>
  57. info what(Context& context) const
  58. {
  59. return info("omit", subject.what(context));
  60. }
  61. Subject subject;
  62. private:
  63. // silence MSVC warning C4512: assignment operator could not be generated
  64. omit_directive& operator= (omit_directive const&);
  65. };
  66. ///////////////////////////////////////////////////////////////////////////
  67. // Parser generators: make_xxx function (objects)
  68. ///////////////////////////////////////////////////////////////////////////
  69. template <typename Subject, typename Modifiers>
  70. struct make_directive<tag::omit, Subject, Modifiers>
  71. {
  72. typedef omit_directive<Subject> result_type;
  73. result_type operator()(unused_type, Subject const& subject, unused_type) const
  74. {
  75. return result_type(subject);
  76. }
  77. };
  78. }}}
  79. namespace boost { namespace spirit { namespace traits
  80. {
  81. ///////////////////////////////////////////////////////////////////////////
  82. template <typename Subject>
  83. struct has_semantic_action<qi::omit_directive<Subject> >
  84. : mpl::false_ {};
  85. ///////////////////////////////////////////////////////////////////////////
  86. template <typename Subject, typename Attribute, typename Context
  87. , typename Iterator>
  88. struct handles_container<qi::omit_directive<Subject>, Attribute
  89. , Context, Iterator>
  90. : unary_handles_container<Subject, Attribute, Context, Iterator> {};
  91. }}}
  92. #endif