Chris@16
|
1 // ----------------------------------------------------------------------------
|
Chris@16
|
2 // compat_workarounds : general framework for non-conformance workarounds
|
Chris@16
|
3 // ----------------------------------------------------------------------------
|
Chris@16
|
4
|
Chris@16
|
5 // Copyright Samuel Krempp 2003. Use, modification, and distribution are
|
Chris@16
|
6 // subject to the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
7 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8
|
Chris@16
|
9 // see http://www.boost.org/libs/format for library home page
|
Chris@16
|
10
|
Chris@16
|
11 // ----------------------------------------------------------------------------
|
Chris@16
|
12
|
Chris@16
|
13
|
Chris@16
|
14 // this file defines wrapper classes to hide non-conforming
|
Chris@16
|
15 // std::char_traits<> and std::allocator<> traits
|
Chris@16
|
16 // and Includes : config_macros.hpp (defines config macros
|
Chris@16
|
17 // and compiler-specific switches)
|
Chris@16
|
18
|
Chris@16
|
19 // Non-conformant Std-libs fail to supply conformant traits (std::char_traits,
|
Chris@16
|
20 // std::allocator) and/or the std::string doesnt support them.
|
Chris@16
|
21 // We don't want to have hundreds of #ifdef workarounds, so we define
|
Chris@16
|
22 // replacement traits.
|
Chris@16
|
23 // But both char_traits and allocator traits are visible in the interface,
|
Chris@16
|
24 // (inside the final string type), thus we need to keep both
|
Chris@16
|
25 // the replacement type (typedefed to 'compatible_type') for real use,
|
Chris@16
|
26 // and the original stdlib type (typedef to 'type_for_string') for interface
|
Chris@16
|
27 // visibility. This is what Compat* classes do (as well as be transparent
|
Chris@16
|
28 // when good allocator and char traits are present)
|
Chris@16
|
29
|
Chris@16
|
30 #ifndef BOOST_FORMAT_COMPAT_WORKAROUNDS_HPP
|
Chris@16
|
31 #define BOOST_FORMAT_COMPAT_WORKAROUNDS_HPP
|
Chris@16
|
32
|
Chris@16
|
33 namespace boost {
|
Chris@16
|
34 namespace io {
|
Chris@16
|
35
|
Chris@16
|
36 // gcc-2.95 char traits (non-conformantly named string_char_traits)
|
Chris@16
|
37 // lack several functions so we extend them in a replacement class.
|
Chris@16
|
38 template<class Tr>
|
Chris@16
|
39 class CompatTraits;
|
Chris@16
|
40
|
Chris@16
|
41 // std::allocator<Ch> in gcc-2.95 is ok, but basic_string only works
|
Chris@16
|
42 // with plain 'std::alloc' still, alt_stringbuf requires a functionnal
|
Chris@16
|
43 // alloc template argument, so we need a replacement allocator
|
Chris@16
|
44 template<class Alloc>
|
Chris@16
|
45 class CompatAlloc;
|
Chris@16
|
46 } // N.S. io
|
Chris@16
|
47 }// N.S. boost
|
Chris@16
|
48
|
Chris@16
|
49
|
Chris@16
|
50 #include <boost/format/detail/config_macros.hpp>
|
Chris@16
|
51 // sets-up macros and load compiler-specific workarounds headers.
|
Chris@16
|
52
|
Chris@16
|
53 #if !defined(BOOST_FORMAT_STREAMBUF_DEFINED)
|
Chris@16
|
54 // workarounds-gcc-2.95 might have defined own streambuf
|
Chris@16
|
55 #include <streambuf>
|
Chris@16
|
56 #endif
|
Chris@16
|
57
|
Chris@16
|
58 #if !defined(BOOST_FORMAT_OSTREAM_DEFINED)
|
Chris@16
|
59 // workarounds-gcc-2.95 might already have included <iostream>
|
Chris@16
|
60 #include <ostream>
|
Chris@16
|
61 #endif
|
Chris@16
|
62
|
Chris@16
|
63
|
Chris@16
|
64
|
Chris@16
|
65 namespace boost {
|
Chris@16
|
66 namespace io {
|
Chris@16
|
67
|
Chris@16
|
68 // **** CompatTraits general definitions : ----------------------------
|
Chris@16
|
69 template<class Tr>
|
Chris@16
|
70 class CompatTraits
|
Chris@16
|
71 { // general case : be transparent
|
Chris@16
|
72 public:
|
Chris@16
|
73 typedef Tr compatible_type;
|
Chris@16
|
74 };
|
Chris@16
|
75
|
Chris@16
|
76 // **** CompatAlloc general definitions : -----------------------------
|
Chris@16
|
77 template<class Alloc>
|
Chris@16
|
78 class CompatAlloc
|
Chris@16
|
79 { // general case : be transparent
|
Chris@16
|
80 public:
|
Chris@16
|
81 typedef Alloc compatible_type;
|
Chris@16
|
82 };
|
Chris@16
|
83
|
Chris@16
|
84 } //N.S. io
|
Chris@16
|
85 } // N.S. boost
|
Chris@16
|
86 #endif // include guard
|