unicode_iterators.qbk 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. [/
  2. Copyright 2006-2007 John Maddock.
  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:uni_iter Unicode Iterators]
  8. [h4 Synopsis]
  9. ``#include <boost/regex/pending/unicode_iterator.hpp>``
  10. template <class BaseIterator, class U16Type = ::boost::uint16_t>
  11. class u32_to_u16_iterator;
  12. template <class BaseIterator, class U32Type = ::boost::uint32_t>
  13. class u16_to_u32_iterator;
  14. template <class BaseIterator, class U8Type = ::boost::uint8_t>
  15. class u32_to_u8_iterator;
  16. template <class BaseIterator, class U32Type = ::boost::uint32_t>
  17. class u8_to_u32_iterator;
  18. template <class BaseIterator>
  19. class utf16_output_iterator;
  20. template <class BaseIterator>
  21. class utf8_output_iterator;
  22. [h4 Description]
  23. This header contains a selection of iterator adaptors that make a sequence of characters in one
  24. encoding "look like" a read-only sequence of characters in another encoding.
  25. template <class BaseIterator, class U16Type = ::boost::uint16_t>
  26. class u32_to_u16_iterator
  27. {
  28. u32_to_u16_iterator();
  29. u32_to_u16_iterator(BaseIterator start_position);
  30. // Other standard BidirectionalIterator members here...
  31. };
  32. A Bidirectional iterator adapter that makes an underlying sequence of UTF32 characters look like
  33. a (read-only) sequence of UTF16 characters. The UTF16 characters are encoded in the platforms
  34. native byte order.
  35. template <class BaseIterator, class U32Type = ::boost::uint32_t>
  36. class u16_to_u32_iterator
  37. {
  38. u16_to_u32_iterator();
  39. u16_to_u32_iterator(BaseIterator start_position);
  40. u16_to_u32_iterator(BaseIterator start_position, BaseIterator start_range, BaseIterator end_range);
  41. // Other standard BidirectionalIterator members here...
  42. };
  43. A Bidirectional iterator adapter that makes an underlying sequence of UTF16 characters
  44. (in the platforms native byte order) look like a (read-only) sequence of UTF32 characters.
  45. The three-arg constructor of this class takes the start and end of the underlying sequence
  46. as well as the position to start iteration from. This constructor validates that the
  47. underlying sequence has validly encoded endpoints: this prevents accidentally incrementing/decrementing
  48. past the end of the underlying sequence as a result of invalid UTF16 code sequences at the endpoints
  49. of the underlying range.
  50. template <class BaseIterator, class U8Type = ::boost::uint8_t>
  51. class u32_to_u8_iterator
  52. {
  53. u32_to_u8_iterator();
  54. u32_to_u8_iterator(BaseIterator start_position);
  55. // Other standard BidirectionalIterator members here...
  56. };
  57. A Bidirectional iterator adapter that makes an underlying sequence of UTF32 characters look like
  58. a (read-only) sequence of UTF8 characters.
  59. template <class BaseIterator, class U32Type = ::boost::uint32_t>
  60. class u8_to_u32_iterator
  61. {
  62. u8_to_u32_iterator();
  63. u8_to_u32_iterator(BaseIterator start_position);
  64. u8_to_u32_iterator(BaseIterator start_position, BaseIterator start_range, BaseIterator end_range);
  65. // Other standard BidirectionalIterator members here...
  66. };
  67. A Bidirectional iterator adapter that makes an underlying sequence of UTF8 characters
  68. look like a (read-only) sequence of UTF32 characters.
  69. The three-arg constructor of this class takes the start and end of the underlying sequence
  70. as well as the position to start iteration from. This constructor validates that the
  71. underlying sequence has validly encoded endpoints: this prevents accidentally incrementing/decrementing
  72. past the end of the underlying sequence as a result of invalid UTF8 code sequences at the endpoints
  73. of the underlying range.
  74. template <class BaseIterator>
  75. class utf16_output_iterator
  76. {
  77. utf16_output_iterator(const BaseIterator& b);
  78. utf16_output_iterator(const utf16_output_iterator& that);
  79. utf16_output_iterator& operator=(const utf16_output_iterator& that);
  80. // Other standard OutputIterator members here...
  81. };
  82. Simple OutputIterator adapter - accepts UTF32 values as input, and forwards them to ['BaseIterator b]
  83. as UTF16. Both UTF32 and UTF16 values are in native byte order.
  84. template <class BaseIterator>
  85. class utf8_output_iterator
  86. {
  87. utf8_output_iterator(const BaseIterator& b);
  88. utf8_output_iterator(const utf8_output_iterator& that);
  89. utf8_output_iterator& operator=(const utf8_output_iterator& that);
  90. // Other standard OutputIterator members here...
  91. };
  92. Simple OutputIterator adapter - accepts UTF32 values as input, and forwards them to ['BaseIterator b]
  93. as UTF8. The UTF32 input values must be in native byte order.
  94. [endsect]