categories.hpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  2. // (C) Copyright 2003-2007 Jonathan Turkanis
  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. // See http://www.boost.org/libs/iostreams for documentation.
  6. // Contains category and mode tags for classifying filters, devices and
  7. // standard stream and stream buffers types.
  8. #ifndef BOOST_IOSTREAMS_CATEGORIES_HPP_INCLUDED
  9. #define BOOST_IOSTREAMS_CATEGORIES_HPP_INCLUDED
  10. #if defined(_MSC_VER)
  11. # pragma once
  12. #endif
  13. namespace boost { namespace iostreams {
  14. //------------------Tags for dispatch according to i/o mode-------------------//
  15. struct any_tag { };
  16. namespace detail { struct two_sequence : virtual any_tag { }; }
  17. namespace detail { struct random_access : virtual any_tag { }; }
  18. namespace detail { struct one_head : virtual any_tag { }; }
  19. namespace detail { struct two_head : virtual any_tag { }; }
  20. struct input : virtual any_tag { };
  21. struct output : virtual any_tag { };
  22. struct bidirectional : virtual input, virtual output, detail::two_sequence { };
  23. struct dual_use : virtual input, virtual output { }; // Pseudo-mode.
  24. struct input_seekable : virtual input, virtual detail::random_access { };
  25. struct output_seekable : virtual output, virtual detail::random_access { };
  26. struct seekable
  27. : virtual input_seekable,
  28. virtual output_seekable,
  29. detail::one_head
  30. { };
  31. struct dual_seekable
  32. : virtual input_seekable,
  33. virtual output_seekable,
  34. detail::two_head
  35. { };
  36. struct bidirectional_seekable
  37. : input_seekable, output_seekable,
  38. bidirectional, detail::two_head
  39. { };
  40. //------------------Tags for use as i/o categories----------------------------//
  41. struct device_tag : virtual any_tag { };
  42. struct filter_tag : virtual any_tag { };
  43. //
  44. // Tags for optional behavior.
  45. //
  46. struct peekable_tag : virtual any_tag { }; // Devices.
  47. struct closable_tag : virtual any_tag { };
  48. struct flushable_tag : virtual any_tag { };
  49. struct localizable_tag : virtual any_tag { };
  50. struct optimally_buffered_tag : virtual any_tag { };
  51. struct direct_tag : virtual any_tag { }; // Devices.
  52. struct multichar_tag : virtual any_tag { }; // Filters.
  53. struct source_tag : device_tag, input { };
  54. struct sink_tag : device_tag, output { };
  55. struct bidirectional_device_tag : device_tag, bidirectional { };
  56. struct seekable_device_tag : virtual device_tag, seekable { };
  57. struct input_filter_tag : filter_tag, input { };
  58. struct output_filter_tag : filter_tag, output { };
  59. struct bidirectional_filter_tag : filter_tag, bidirectional { };
  60. struct seekable_filter_tag : filter_tag, seekable { };
  61. struct dual_use_filter_tag : filter_tag, dual_use { };
  62. struct multichar_input_filter_tag
  63. : multichar_tag,
  64. input_filter_tag
  65. { };
  66. struct multichar_output_filter_tag
  67. : multichar_tag,
  68. output_filter_tag
  69. { };
  70. struct multichar_bidirectional_filter_tag
  71. : multichar_tag,
  72. bidirectional_filter_tag
  73. { };
  74. struct multichar_seekable_filter_tag
  75. : multichar_tag,
  76. seekable_filter_tag
  77. { };
  78. struct multichar_dual_use_filter_tag
  79. : multichar_tag,
  80. dual_use_filter_tag
  81. { };
  82. //
  83. // Tags for standard streams and streambufs.
  84. //
  85. struct std_io_tag : virtual localizable_tag { };
  86. struct istream_tag
  87. : virtual device_tag,
  88. virtual peekable_tag,
  89. virtual std_io_tag
  90. { };
  91. struct ostream_tag
  92. : virtual device_tag,
  93. virtual std_io_tag
  94. { };
  95. struct iostream_tag
  96. : istream_tag,
  97. ostream_tag
  98. { };
  99. struct streambuf_tag
  100. : device_tag,
  101. peekable_tag,
  102. std_io_tag
  103. { };
  104. struct ifstream_tag
  105. : input_seekable,
  106. closable_tag,
  107. istream_tag
  108. { };
  109. struct ofstream_tag
  110. : output_seekable,
  111. closable_tag,
  112. ostream_tag
  113. { };
  114. struct fstream_tag
  115. : seekable,
  116. closable_tag,
  117. iostream_tag
  118. { };
  119. struct filebuf_tag
  120. : seekable,
  121. closable_tag,
  122. streambuf_tag
  123. { };
  124. struct istringstream_tag
  125. : input_seekable,
  126. istream_tag
  127. { };
  128. struct ostringstream_tag
  129. : output_seekable,
  130. ostream_tag
  131. { };
  132. struct stringstream_tag
  133. : dual_seekable,
  134. iostream_tag
  135. { };
  136. struct stringbuf_tag
  137. : dual_seekable,
  138. streambuf_tag
  139. { };
  140. struct generic_istream_tag
  141. : input_seekable,
  142. istream_tag
  143. { };
  144. struct generic_ostream_tag
  145. : output_seekable,
  146. ostream_tag
  147. { };
  148. struct generic_iostream_tag
  149. : seekable,
  150. iostream_tag
  151. { };
  152. struct generic_streambuf_tag
  153. : seekable,
  154. streambuf_tag
  155. { };
  156. } } // End namespaces iostreams, boost.
  157. #endif // #ifndef BOOST_IOSTREAMS_CATEGORIES_HPP_INCLUDED