upper_lower_case.hpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright (c) 2001-2011 Hartmut Kaiser
  2. // Copyright (c) 2001-2011 Joel de Guzman
  3. //
  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. #if !defined(SPIRIT_UPPER_LOWER_CASE_JANUARY_19_2009_1142AM)
  7. #define SPIRIT_UPPER_LOWER_CASE_JANUARY_19_2009_1142AM
  8. #if defined(_MSC_VER)
  9. #pragma once
  10. #endif
  11. #include <boost/spirit/home/support/common_terminals.hpp>
  12. #include <boost/spirit/home/support/modify.hpp>
  13. #include <boost/spirit/home/karma/domain.hpp>
  14. #include <boost/spirit/home/karma/meta_compiler.hpp>
  15. namespace boost { namespace spirit
  16. {
  17. ///////////////////////////////////////////////////////////////////////////
  18. // Enablers
  19. ///////////////////////////////////////////////////////////////////////////
  20. template <typename CharEncoding>
  21. struct use_directive<
  22. karma::domain, tag::char_code<tag::upper, CharEncoding> > // enables upper
  23. : mpl::true_ {};
  24. template <typename CharEncoding>
  25. struct use_directive<
  26. karma::domain, tag::char_code<tag::lower, CharEncoding> > // enables lower
  27. : mpl::true_ {};
  28. ///////////////////////////////////////////////////////////////////////////
  29. template <typename CharEncoding>
  30. struct is_modifier_directive<karma::domain
  31. , tag::char_code<tag::upper, CharEncoding> >
  32. : mpl::true_ {};
  33. template <typename CharEncoding>
  34. struct is_modifier_directive<karma::domain
  35. , tag::char_code<tag::lower, CharEncoding> >
  36. : mpl::true_ {};
  37. ///////////////////////////////////////////////////////////////////////////
  38. // Don't add tag::upper or tag::lower if there is already one of those in
  39. // the modifier list
  40. template <typename Current, typename CharEncoding>
  41. struct compound_modifier<
  42. Current
  43. , tag::char_code<tag::upper, CharEncoding>
  44. , typename enable_if<
  45. has_modifier<Current, tag::char_code<tag::lower, CharEncoding> >
  46. >::type
  47. >
  48. : Current
  49. {
  50. compound_modifier()
  51. : Current() {}
  52. compound_modifier(Current const& current,
  53. tag::char_code<tag::upper, CharEncoding> const&)
  54. : Current(current) {}
  55. };
  56. template <typename Current, typename CharEncoding>
  57. struct compound_modifier<
  58. Current
  59. , tag::char_code<tag::lower, CharEncoding>
  60. , typename enable_if<
  61. has_modifier<Current, tag::char_code<tag::upper, CharEncoding> >
  62. >::type
  63. >
  64. : Current
  65. {
  66. compound_modifier()
  67. : Current() {}
  68. compound_modifier(Current const& current,
  69. tag::char_code<tag::lower, CharEncoding> const&)
  70. : Current(current) {}
  71. };
  72. }}
  73. #endif