1 #ifndef BOOST_ARCHIVE_DINKUMWARE_HPP
2 #define BOOST_ARCHIVE_DINKUMWARE_HPP
4 // MS compatible compilers support #pragma once
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 // this file adds a couple of things that are missing from the dinkumware
20 // implementation of the standard library.
25 #include <boost/config.hpp>
26 #include <boost/cstdint.hpp>
30 // define i/o operators for 64 bit integers
31 template<class CharType>
32 basic_ostream<CharType> &
33 operator<<(basic_ostream<CharType> & os, boost::uint64_t t){
34 // octal rendering of 64 bit number would be 22 octets + eos
38 if(os.flags() & (int)std::ios_base::hex)
41 if(os.flags() & (int)std::ios_base::oct)
44 //if(s.flags() & (int)std::ios_base::dec)
48 unsigned int j = t % radix;
49 d[i++] = j + ((j < 10) ? '0' : ('a' - 10));
68 template<class CharType>
69 basic_ostream<CharType> &
70 operator<<(basic_ostream<CharType> &os, boost::int64_t t){
72 os << static_cast<boost::uint64_t>(t);
81 template<class CharType>
82 basic_istream<CharType> &
83 operator>>(basic_istream<CharType> &is, boost::int64_t & t){
89 bool negative = (d == '-');
93 if(is.flags() & (int)std::ios_base::hex)
96 if(is.flags() & (int)std::ios_base::oct)
99 //if(s.flags() & (int)std::ios_base::dec)
103 if('0' <= d && d <= '9')
104 t = t * radix + (d - '0');
106 if('a' <= d && d <= 'f')
107 t = t * radix + (d - 'a' + 10);
113 // restore the delimiter
121 template<class CharType>
122 basic_istream<CharType> &
123 operator>>(basic_istream<CharType> &is, boost::uint64_t & t){
131 class back_insert_iterator<basic_string<char> > : public
132 iterator<output_iterator_tag, char>
135 typedef basic_string<char> container_type;
136 typedef container_type::reference reference;
138 explicit back_insert_iterator(container_type & s)
140 {} // construct with container
142 back_insert_iterator<container_type> & operator=(
143 container_type::const_reference Val_
144 ){ // push value into container
145 //container->push_back(Val_);
150 back_insert_iterator<container_type> & operator*(){
154 back_insert_iterator<container_type> & operator++(){
155 // pretend to preincrement
159 back_insert_iterator<container_type> operator++(int){
160 // pretend to postincrement
165 container_type *container; // pointer to container
169 inline back_insert_iterator<basic_string<char> > back_inserter(
170 basic_string<char> & s
172 return (std::back_insert_iterator<basic_string<char> >(s));
176 class back_insert_iterator<basic_string<wchar_t> > : public
177 iterator<output_iterator_tag, wchar_t>
180 typedef basic_string<wchar_t> container_type;
181 typedef container_type::reference reference;
183 explicit back_insert_iterator(container_type & s)
185 {} // construct with container
187 back_insert_iterator<container_type> & operator=(
188 container_type::const_reference Val_
189 ){ // push value into container
190 //container->push_back(Val_);
195 back_insert_iterator<container_type> & operator*(){
199 back_insert_iterator<container_type> & operator++(){
200 // pretend to preincrement
204 back_insert_iterator<container_type> operator++(int){
205 // pretend to postincrement
210 container_type *container; // pointer to container
214 inline back_insert_iterator<basic_string<wchar_t> > back_inserter(
215 basic_string<wchar_t> & s
217 return (std::back_insert_iterator<basic_string<wchar_t> >(s));
222 #endif //BOOST_ARCHIVE_DINKUMWARE_HPP