Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:53

0001 // ----------------------------------------------------------------------------
0002 //  workarounds for gcc < 3.0. 
0003 // ----------------------------------------------------------------------------
0004 
0005 //  Copyright Samuel Krempp 2003. Use, modification, and distribution are
0006 //  subject to the Boost Software License, Version 1.0. (See accompanying
0007 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 //  See http://www.boost.org/libs/format for library home page
0010 
0011 
0012 // ----------------------------------------------------------------------------
0013 
0014 // There's a lot to do, the stdlib shipped with gcc prior to 3.x 
0015 // was terribly non-conforming. 
0016 // . defines macros switches
0017 // . supplies template classes basic_foo<char,Tr> where gcc only supplies foo.
0018 //  i.e :
0019 //     -  basic_ios<char, Tr>        from ios
0020 //     -  basic_ostream<char, Tr>    from ostream
0021 //     -  basic_srteambuf<char, Tr>  from streambuf
0022 // these can be used transparently. (it obviously does not work for wchar_t)
0023 // . specialise CompatAlloc and CompatTraits to wrap gcc-2.95's 
0024 //    string_char_traits and std::alloc 
0025 
0026 #if  BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
0027    // only for gcc-2.95's native stdlib
0028 
0029 #ifndef BOOST_FORMAT_WORKAROUNDS_GCC295_H
0030 #define BOOST_FORMAT_WORKAROUNDS_GCC295_H
0031 
0032 // SGI STL doesnt have <ostream> and others, so we need iostream.
0033 #include <iostream> 
0034 #define BOOST_FORMAT_OSTREAM_DEFINED
0035 
0036 #include <streambuf.h>
0037 #define BOOST_FORMAT_STREAMBUF_DEFINED
0038 
0039 #define BOOST_NO_TEMPLATE_STD_STREAM
0040 
0041 #ifndef BOOST_IO_STD
0042 #  define BOOST_IO_STD std::
0043 #endif
0044 
0045 
0046 
0047 // *** 
0048 // gcc's simple classes turned into standard-like template classes :
0049 
0050 namespace std {
0051 
0052 
0053     // gcc has string_char_traits, it's incomplete.
0054     // we declare a std::char_traits, and specialize CompatTraits<..> on it
0055     // to do what is required
0056     template<class Ch>
0057     class char_traits; // no definition here, we will just use it as a tag.
0058 
0059     template <class Ch, class Tr>
0060     class basic_streambuf;
0061 
0062     template <class Tr> 
0063     class basic_streambuf<char, Tr> : public streambuf {
0064     };
0065 
0066     template <class Ch, class Tr=::std::char_traits<Ch> >
0067     class basic_ios;
0068 
0069     template <class Tr>
0070     class basic_ios<char, Tr> : public ostream {
0071     public:
0072         basic_ios(streambuf * p) : ostream(p) {};
0073          char fill()  const { return ios::fill(); } // gcc returns wchar..
0074          char fill(char c)  { return ios::fill(c); } // gcc takes wchar..
0075          char widen(char c) { return c; }
0076          char narrow(char c, char def) { return c; }
0077         basic_ios& copyfmt(const ios& right) {
0078             fill(right.fill());
0079             flags(right.flags() );
0080             exceptions(right.exceptions());
0081             width(right.width());
0082             precision(right.precision());
0083             return *this;
0084         }
0085      };
0086 
0087 
0088     typedef ios ios_base;
0089 
0090     template <class Ch, class Tr>
0091     class basic_ostream;
0092 
0093      template <class Tr> 
0094      class basic_ostream<char, Tr> : public basic_ios<char, Tr>
0095      {
0096      public:
0097          basic_ostream(streambuf * p) : basic_ios<char,Tr> (p) {}
0098      };
0099 
0100 } // namespace std
0101 
0102 
0103 namespace boost {
0104     namespace io {
0105 
0106 
0107         // ** CompatTraits gcc2.95 specialisations ----------------------------
0108         template<class Ch>
0109         class CompatTraits< ::std::string_char_traits<Ch> >
0110             : public ::std::string_char_traits<Ch> 
0111         {
0112         public:
0113             typedef CompatTraits                compatible_type;
0114 
0115             typedef Ch char_type;
0116             typedef int int_type;
0117             typedef ::std::streampos pos_type;
0118             typedef ::std::streamoff off_type;
0119         
0120             static char_type 
0121             to_char_type(const int_type& meta) {
0122                 return static_cast<char_type>(meta); }
0123             static int_type 
0124             to_int_type(const char_type& ch) {
0125                 return static_cast<int_type>(static_cast<unsigned char>(ch) );}
0126             static bool 
0127             eq_int_type(const int_type& left, const int_type& right) {
0128                 return left == right; }
0129             static int_type 
0130             eof() {
0131                 return static_cast<int_type>(EOF);
0132             }
0133             static int_type 
0134             not_eof(const int_type& meta) {
0135                 return (meta == eof()) ? 0 : meta;
0136             }
0137         };
0138 
0139         template<class Ch>
0140         class CompatTraits< ::std::char_traits<Ch> > {
0141         public:
0142             typedef CompatTraits< ::std::string_char_traits<Ch> >  compatible_type;
0143         };
0144 
0145         // ** CompatAlloc gcc-2.95  specialisations ---------------------------
0146         template<>
0147         class CompatAlloc< ::std::alloc>
0148         {
0149         public:
0150             typedef ::std::allocator<char> compatible_type;
0151         };
0152 
0153     } // N.S. io
0154 } // N.S. boost
0155 
0156 
0157 
0158 
0159 
0160 #endif // include guard
0161 
0162 #endif // if workaround