First public contribution.
1 #ifndef BOOST_ARCHIVE_DINKUMWARE_HPP
2 #define BOOST_ARCHIVE_DINKUMWARE_HPP
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
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){
133 class back_insert_iterator<basic_string<char> > : public
134 iterator<output_iterator_tag, char>
137 typedef basic_string<char> container_type;
138 typedef container_type::reference reference;
140 explicit back_insert_iterator(container_type & s)
142 {} // construct with container
144 back_insert_iterator<container_type> & operator=(
145 container_type::const_reference Val_
146 ){ // push value into container
147 //container->push_back(Val_);
152 back_insert_iterator<container_type> & operator*(){
156 back_insert_iterator<container_type> & operator++(){
157 // pretend to preincrement
161 back_insert_iterator<container_type> operator++(int){
162 // pretend to postincrement
167 container_type *container; // pointer to container
171 inline back_insert_iterator<basic_string<char> > back_inserter(
172 basic_string<char> & s
174 return (std::back_insert_iterator<basic_string<char> >(s));
178 class back_insert_iterator<basic_string<wchar_t> > : public
179 iterator<output_iterator_tag, wchar_t>
182 typedef basic_string<wchar_t> container_type;
183 typedef container_type::reference reference;
185 explicit back_insert_iterator(container_type & s)
187 {} // construct with container
189 back_insert_iterator<container_type> & operator=(
190 container_type::const_reference Val_
191 ){ // push value into container
192 //container->push_back(Val_);
197 back_insert_iterator<container_type> & operator*(){
201 back_insert_iterator<container_type> & operator++(){
202 // pretend to preincrement
206 back_insert_iterator<container_type> operator++(int){
207 // pretend to postincrement
212 container_type *container; // pointer to container
216 inline back_insert_iterator<basic_string<wchar_t> > back_inserter(
217 basic_string<wchar_t> & s
219 return (std::back_insert_iterator<basic_string<wchar_t> >(s));
224 #endif //BOOST_ARCHIVE_DINKUMWARE_HPP