create_parser.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) 2001-2011 Hartmut Kaiser
  2. //
  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. #if !defined(BOOST_SPIRIT_QI_CREATE_NOV_21_2009_0444PM)
  6. #define BOOST_SPIRIT_QI_CREATE_NOV_21_2009_0444PM
  7. #if defined(_MSC_VER)
  8. #pragma once
  9. #endif
  10. #include <boost/spirit/home/qi/auto/meta_create.hpp>
  11. ///////////////////////////////////////////////////////////////////////////////
  12. namespace boost { namespace spirit { namespace result_of
  13. {
  14. template <typename T>
  15. struct create_parser
  16. : spirit::traits::meta_create<qi::domain, T> {};
  17. }}}
  18. ///////////////////////////////////////////////////////////////////////////////
  19. namespace boost { namespace spirit { namespace qi
  20. {
  21. // Main API function for parser creation from data type
  22. template <typename T>
  23. typename result_of::create_parser<T>::type
  24. create_parser()
  25. {
  26. return spirit::traits::meta_create<qi::domain, T>::call();
  27. }
  28. }}}
  29. ///////////////////////////////////////////////////////////////////////////////
  30. namespace boost { namespace spirit { namespace traits
  31. {
  32. // Meta function returning true if create_parser does return a valid
  33. // parser for the given type T.
  34. template <typename T>
  35. struct create_parser_exists
  36. : meta_create_exists<qi::domain, T> {};
  37. }}}
  38. #endif