auto.qbk 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. [/==============================================================================
  2. Copyright (C) 2001-2011 Joel de Guzman
  3. Copyright (C) 2001-2011 Hartmut Kaiser
  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. [section:auto Auto Parser]
  8. [heading Description]
  9. This module includes the description of the `auto_` parser. This parser
  10. can be used to automatically create a parser based on the supplied attribute
  11. type.
  12. [heading Header]
  13. // forwards to <boost/spirit/home/qi/auto.hpp>
  14. #include <boost/spirit/include/qi_auto.hpp>
  15. Also, see __include_structure__.
  16. [heading Namespace]
  17. [table
  18. [[Name]]
  19. [[`boost::spirit::auto_ // alias: boost::spirit::qi::auto_`]]
  20. ]
  21. [heading Model of]
  22. [:__primitive_parser_concept__]
  23. [heading Expression Semantics]
  24. Semantics of an expression is defined only where it differs from, or is
  25. not defined in __primitive_generator_concept__.
  26. [table
  27. [[Expression] [Description]]
  28. [[`auto_`] [Create a parser instance compatible with the
  29. supplied attribute type and use it for input
  30. matching.]]
  31. ]
  32. [heading Additional Requirements]
  33. The `auto_` parsers can be used to match input for any data type for which
  34. a mapping to a parser type is defined (the meta function
  35. `traits::create_parser_exists` returns `mpl::true_`).
  36. The following table outlines the predefined mapping rules from the attribute
  37. type to the parser type. These rules are applied recursively to create the parser
  38. type which can be used to match input for the given attribute type.
  39. [table
  40. [[Attribute type] [Parser type]]
  41. [[`char`, `wchar_t`] [`standard::char_`, `standard_wide::char_`]]
  42. [[`short`, `int`, `long`] [`short_`, `int_`, `long_`]]
  43. [[`unsigned short`, `unsigned int`, `unsigned long`]
  44. [`ushort_`, `uint_`, `ulong_`]]
  45. [[`float`, `double`, `long double`] [`float_`, `double_`, `long_double`]]
  46. [[`long long`, `unsigned long long`]
  47. [`long_long`, `ulong_long`]]
  48. [[`bool`] [`bool_`]]
  49. [[Any (STL) container] [Kleene Star (unary `'*'`)]]
  50. [[Any Fusion sequence] [Sequence operator (`'>>'`)]]
  51. [[`boost::optional<>`] [Optional operator (unary `'-'`)]]
  52. [[`boost::variant<>`] [Alternative operator (`'|'`)]]
  53. ]
  54. It is possible to add support for any custom data type by implementing a
  55. specialization of the customization point __customize_create_parser__. This
  56. customization can be used also to redefined any of the predefined mappings.
  57. [heading Attributes]
  58. [table
  59. [[Expression] [Attribute]]
  60. [[`auto_`] [`hold_any`]]
  61. ]
  62. [important The attribute type `hold_any` exposed by the `auto_`
  63. parser is semantically and syntactically equivalent to
  64. the type implemented by __boost_any__. It has been added to /Spirit/
  65. as it has better a performance and a smaller footprint if compared to
  66. __boost_any__.
  67. ]
  68. [heading Complexity]
  69. [:The complexity of the `auto_` parser depends on the supplied attribute type. Each
  70. attribute type results in a different parser type to be instantiated which
  71. defines the overall complexity.]
  72. [heading Example]
  73. [note The test harness for the example(s) below is presented in the
  74. __qi_basics_examples__ section.]
  75. Some includes:
  76. [reference_includes]
  77. Some using declarations:
  78. [reference_qi_using_declarations_auto]
  79. And a class definition used in the examples:
  80. [reference_qi_complex]
  81. [reference_qi_auto_complex]
  82. Some usage examples of `auto_` parsers:
  83. [reference_qi_auto]
  84. [endsect]