sl@0: #ifndef BOOST_ARCHIVE_DINKUMWARE_HPP sl@0: #define BOOST_ARCHIVE_DINKUMWARE_HPP sl@0: sl@0: // MS compatible compilers support #pragma once sl@0: #if defined(_MSC_VER) && (_MSC_VER >= 1020) sl@0: # pragma once sl@0: #endif sl@0: sl@0: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 sl@0: // dinkumware.hpp: sl@0: sl@0: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . sl@0: // Use, modification and distribution is subject to the Boost Software sl@0: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: sl@0: // See http://www.boost.org for updates, documentation, and revision history. sl@0: sl@0: // this file adds a couple of things that are missing from the dinkumware sl@0: // implementation of the standard library. sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: sl@0: namespace std { sl@0: sl@0: // define i/o operators for 64 bit integers sl@0: template sl@0: basic_ostream & sl@0: operator<<(basic_ostream & os, boost::uint64_t t){ sl@0: // octal rendering of 64 bit number would be 22 octets + eos sl@0: CharType d[23]; sl@0: unsigned int radix; sl@0: sl@0: if(os.flags() & (int)std::ios_base::hex) sl@0: radix = 16; sl@0: else sl@0: if(os.flags() & (int)std::ios_base::oct) sl@0: radix = 8; sl@0: else sl@0: //if(s.flags() & (int)std::ios_base::dec) sl@0: radix = 10; sl@0: unsigned int i = 0; sl@0: do{ sl@0: unsigned int j = t % radix; sl@0: d[i++] = j + ((j < 10) ? '0' : ('a' - 10)); sl@0: t /= radix; sl@0: } sl@0: while(t > 0); sl@0: d[i--] = '\0'; sl@0: sl@0: // reverse digits sl@0: unsigned int j = 0; sl@0: while(j < i){ sl@0: CharType k = d[i]; sl@0: d[i] = d[j]; sl@0: d[j] = k; sl@0: --i;++j; sl@0: } sl@0: os << d; sl@0: return os; sl@0: sl@0: } sl@0: sl@0: template sl@0: basic_ostream & sl@0: operator<<(basic_ostream &os, boost::int64_t t){ sl@0: if(0 <= t){ sl@0: os << static_cast(t); sl@0: } sl@0: else{ sl@0: os.put('-'); sl@0: os << -t; sl@0: } sl@0: return os; sl@0: } sl@0: sl@0: template sl@0: basic_istream & sl@0: operator>>(basic_istream &is, boost::int64_t & t){ sl@0: CharType d; sl@0: do{ sl@0: d = is.get(); sl@0: } sl@0: while(::isspace(d)); sl@0: bool negative = (d == '-'); sl@0: if(negative) sl@0: d = is.get(); sl@0: unsigned int radix; sl@0: if(is.flags() & (int)std::ios_base::hex) sl@0: radix = 16; sl@0: else sl@0: if(is.flags() & (int)std::ios_base::oct) sl@0: radix = 8; sl@0: else sl@0: //if(s.flags() & (int)std::ios_base::dec) sl@0: radix = 10; sl@0: t = 0; sl@0: do{ sl@0: if('0' <= d && d <= '9') sl@0: t = t * radix + (d - '0'); sl@0: else sl@0: if('a' <= d && d <= 'f') sl@0: t = t * radix + (d - 'a' + 10); sl@0: else sl@0: break; sl@0: d = is.get(); sl@0: } sl@0: while(!is.fail()); sl@0: // restore the delimiter sl@0: is.putback(d); sl@0: is.clear(); sl@0: if(negative) sl@0: t = -t; sl@0: return is; sl@0: } sl@0: sl@0: template sl@0: basic_istream & sl@0: operator>>(basic_istream &is, boost::uint64_t & t){ sl@0: boost::int64_t it; sl@0: is >> it; sl@0: t = it; sl@0: return is; sl@0: } sl@0: sl@0: //#endif sl@0: sl@0: template<> sl@0: class back_insert_iterator > : public sl@0: iterator sl@0: { sl@0: public: sl@0: typedef basic_string container_type; sl@0: typedef container_type::reference reference; sl@0: sl@0: explicit back_insert_iterator(container_type & s) sl@0: : container(& s) sl@0: {} // construct with container sl@0: sl@0: back_insert_iterator & operator=( sl@0: container_type::const_reference Val_ sl@0: ){ // push value into container sl@0: //container->push_back(Val_); sl@0: *container += Val_; sl@0: return (*this); sl@0: } sl@0: sl@0: back_insert_iterator & operator*(){ sl@0: return (*this); sl@0: } sl@0: sl@0: back_insert_iterator & operator++(){ sl@0: // pretend to preincrement sl@0: return (*this); sl@0: } sl@0: sl@0: back_insert_iterator operator++(int){ sl@0: // pretend to postincrement sl@0: return (*this); sl@0: } sl@0: sl@0: protected: sl@0: container_type *container; // pointer to container sl@0: }; sl@0: sl@0: template sl@0: inline back_insert_iterator > back_inserter( sl@0: basic_string & s sl@0: ){ sl@0: return (std::back_insert_iterator >(s)); sl@0: } sl@0: sl@0: template<> sl@0: class back_insert_iterator > : public sl@0: iterator sl@0: { sl@0: public: sl@0: typedef basic_string container_type; sl@0: typedef container_type::reference reference; sl@0: sl@0: explicit back_insert_iterator(container_type & s) sl@0: : container(& s) sl@0: {} // construct with container sl@0: sl@0: back_insert_iterator & operator=( sl@0: container_type::const_reference Val_ sl@0: ){ // push value into container sl@0: //container->push_back(Val_); sl@0: *container += Val_; sl@0: return (*this); sl@0: } sl@0: sl@0: back_insert_iterator & operator*(){ sl@0: return (*this); sl@0: } sl@0: sl@0: back_insert_iterator & operator++(){ sl@0: // pretend to preincrement sl@0: return (*this); sl@0: } sl@0: sl@0: back_insert_iterator operator++(int){ sl@0: // pretend to postincrement sl@0: return (*this); sl@0: } sl@0: sl@0: protected: sl@0: container_type *container; // pointer to container sl@0: }; sl@0: sl@0: template sl@0: inline back_insert_iterator > back_inserter( sl@0: basic_string & s sl@0: ){ sl@0: return (std::back_insert_iterator >(s)); sl@0: } sl@0: sl@0: } // namespace std sl@0: sl@0: #endif //BOOST_ARCHIVE_DINKUMWARE_HPP