// -*- C++ -*- /*****************************************************************************\ * Copyright (c) 2004 Mark Aylett * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, sublicense, and/or sell copies of the Software, and to permit * * persons to whom the Software is furnished to do so, subject to the * * following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * * USE OR OTHER DEALINGS IN THE SOFTWARE. * \*****************************************************************************/ /** * \file mar_compat_cpp.h * \brief TODO */ #ifndef INCLUDED_MAR_COMPAT_CPP #define INCLUDED_MAR_COMPAT_CPP #if defined(__GNUC__) && __GNUC__ < 3 #ifndef INCLUDED_MAR_DEFS_CPP #include "mar_defs_cpp.h" #endif // INCLUDED_MAR_DEFS_CPP #ifndef INCLUDED_CSTRING #define INCLUDED_CSTRING #include #endif // INCLUDED_CSTRING #ifndef INCLUDED_IOSTREAM #define INCLUDED_IOSTREAM #include #endif // INCLUDED_IOSTREAM namespace std { typedef ios ios_base; template struct char_traits; template <> struct char_traits { typedef char char_type; typedef int int_type; typedef streampos pos_type; typedef streamoff off_type; // typedef mbstate_t state_type; static void assign(char_type& lhs, const char_type& rhs) { lhs = rhs; } static bool eq(const char_type& lhs, const char_type& rhs) { return lhs == rhs; } static bool lt(const char_type& lhs, const char_type& rhs) { return lhs < rhs; } static int compare(const char_type* lhs, const char_type* rhs, size_t len) { return memcmp(lhs, rhs, len); } static size_t length(const char_type* src) { return strlen(src); } static char_type* copy(char_type* to, const char_type* from, size_t len) { return reinterpret_cast(memcpy(to, from, len)); } static const char_type* find(const char_type* src, size_t len, const char_type& ch) { return reinterpret_cast(memchr(src, ch, len)); } static char_type* move(char_type *to, const char_type *from, size_t len) { return reinterpret_cast(memmove(to, from, len)); } static char_type* assign(char_type *to, size_t len, const char_type& ch) { return reinterpret_cast(memset(to, ch, len)); } static char_type to_char_type(const int_type& ch) { return static_cast(ch); } static int_type to_int_type(const char_type& ch) { return static_cast(static_cast(ch)); } static bool eq_int_type(const int_type& lhs, const int_type& rhs) { return lhs == rhs; } static int_type eof() { return EOF; } static int_type not_eof(const int_type& ch) { return ch != eof() ? ch : !eof(); } }; template > class basic_streambuf; template <> class basic_streambuf > : public streambuf { public: typedef char char_type; typedef char_traits char_traits; typedef char_traits::int_type int_type; typedef char_traits::pos_type pos_type; typedef char_traits::off_type off_type; }; template > class basic_istream; template <> class basic_istream > : public istream { public: typedef char char_type; typedef char_traits char_traits; typedef char_traits::int_type int_type; typedef char_traits::pos_type pos_type; typedef char_traits::off_type off_type; explicit basic_istream(basic_streambuf* buf) : istream(buf) { } }; template > class basic_ostream; template <> class basic_ostream > : public ostream { public: typedef char char_type; typedef char_traits char_traits; typedef char_traits::int_type int_type; typedef char_traits::pos_type pos_type; typedef char_traits::off_type off_type; explicit basic_ostream(basic_streambuf* buf) : ostream(buf) { } }; template > class basic_iostream; template <> class basic_iostream > : public iostream { public: typedef char char_type; typedef char_traits char_traits; typedef char_traits::int_type int_type; typedef char_traits::pos_type pos_type; typedef char_traits::off_type off_type; explicit basic_iostream(basic_streambuf* buf) : iostream(buf) { } }; } #endif // __GNUC__ < 3 #endif // INCLUDED_MAR_COMPAT_CPP