vmd_get_type.qbk 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. [/
  2. (C) Copyright Edward Diener 2011-2015
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. ]
  7. [section:vmd_convert_sequence Getting the type of data]
  8. VMD has the ability to retrieve the type of any data which it can
  9. parse, which means any VMD sequence. The macro to do this is called
  10. BOOST_VMD_GET_TYPE and it takes a single required parameter, which
  11. is a VMD sequence.
  12. It returns one of the types previously discussed when introducing
  13. v-types as an identifier subset. As explained previously in that
  14. topic a v-type is fully recognized by VMD macros and can be part
  15. of a sequence and passed as VMD data just like all the other data types
  16. VMD recognizes.
  17. When BOOST_VMD_GET_TYPE returns the type of data it returns by default
  18. the most specific type that the data can be. This means that non-empty
  19. lists and arrays are returned as such, not as tuples, and numbers
  20. and types and empty lists are returned as such, not as identifiers.
  21. #include <boost/vmd/get_type.hpp>
  22. #define BOOST_VMD_REGISTER_ANID (ANID)
  23. #define SEQUENCE_EMPTY
  24. #define SEQUENCE_MULTI (1,2,3) 88
  25. #define SEQUENCE1 (3,(1,2,3))
  26. #define SEQUENCE2 ANID
  27. #define SEQUENCE3 (1,(2,(3,BOOST_PP_NIL)))
  28. #define SEQUENCE4 1
  29. #define SEQUENCE5 (1)(2)(3)
  30. #define SEQUENCE6 (1,2,3)
  31. #define SEQUENCE7 BOOST_VMD_TYPE_NUMBER
  32. BOOST_VMD_GET_TYPE(SEQUENCE_EMPTY) will return BOOST_VMD_TYPE_EMPTY
  33. BOOST_VMD_GET_TYPE(SEQUENCE_MULTI) will return BOOST_VMD_TYPE_SEQUENCE
  34. BOOST_VMD_GET_TYPE(SEQUENCE1) will return BOOST_VMD_TYPE_ARRAY
  35. BOOST_VMD_GET_TYPE(SEQUENCE2) will return BOOST_VMD_TYPE_IDENTIFIER
  36. BOOST_VMD_GET_TYPE(SEQUENCE3) will return BOOST_VMD_TYPE_LIST
  37. BOOST_VMD_GET_TYPE(SEQUENCE4) will return BOOST_VMD_TYPE_NUMBER
  38. BOOST_VMD_GET_TYPE(SEQUENCE5) will return BOOST_VMD_TYPE_SEQ
  39. BOOST_VMD_GET_TYPE(SEQUENCE6) will return BOOST_VMD_TYPE_TUPLE
  40. BOOST_VMD_GET_TYPE(SEQUENCE7) will return BOOST_VMD_TYPE_TYPE
  41. [heading Usage]
  42. You can use the general header file:
  43. #include <boost/vmd/vmd.hpp>
  44. or you can use the individual header file:
  45. #include <boost/vmd/get_type.hpp>
  46. for the BOOST_VMD_GET_TYPE macro.
  47. [endsect]