File indexing completed on 2025-01-18 09:28:30
0001 #ifndef BOOST_ARCHIVE_DINKUMWARE_HPP
0002 #define BOOST_ARCHIVE_DINKUMWARE_HPP
0003
0004
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <iterator>
0023 #include <string>
0024
0025 #include <boost/config.hpp>
0026 #include <boost/cstdint.hpp>
0027
0028 namespace std {
0029
0030
0031 template<class CharType>
0032 basic_ostream<CharType> &
0033 operator<<(basic_ostream<CharType> & os, boost::uint64_t t){
0034
0035 CharType d[23];
0036 unsigned int radix;
0037
0038 if(os.flags() & (int)std::ios_base::hex)
0039 radix = 16;
0040 else
0041 if(os.flags() & (int)std::ios_base::oct)
0042 radix = 8;
0043 else
0044
0045 radix = 10;
0046 unsigned int i = 0;
0047 do{
0048 unsigned int j = t % radix;
0049 d[i++] = j + ((j < 10) ? '0' : ('a' - 10));
0050 t /= radix;
0051 }
0052 while(t > 0);
0053 d[i--] = '\0';
0054
0055
0056 unsigned int j = 0;
0057 while(j < i){
0058 CharType k = d[i];
0059 d[i] = d[j];
0060 d[j] = k;
0061 --i;++j;
0062 }
0063 os << d;
0064 return os;
0065
0066 }
0067
0068 template<class CharType>
0069 basic_ostream<CharType> &
0070 operator<<(basic_ostream<CharType> &os, boost::int64_t t){
0071 if(0 <= t){
0072 os << static_cast<boost::uint64_t>(t);
0073 }
0074 else{
0075 os.put('-');
0076 os << -t;
0077 }
0078 return os;
0079 }
0080
0081 template<class CharType>
0082 basic_istream<CharType> &
0083 operator>>(basic_istream<CharType> &is, boost::int64_t & t){
0084 CharType d;
0085 do{
0086 d = is.get();
0087 }
0088 while(::isspace(d));
0089 bool negative = (d == '-');
0090 if(negative)
0091 d = is.get();
0092 unsigned int radix;
0093 if(is.flags() & (int)std::ios_base::hex)
0094 radix = 16;
0095 else
0096 if(is.flags() & (int)std::ios_base::oct)
0097 radix = 8;
0098 else
0099
0100 radix = 10;
0101 t = 0;
0102 do{
0103 if('0' <= d && d <= '9')
0104 t = t * radix + (d - '0');
0105 else
0106 if('a' <= d && d <= 'f')
0107 t = t * radix + (d - 'a' + 10);
0108 else
0109 break;
0110 d = is.get();
0111 }
0112 while(!is.fail());
0113
0114 is.putback(d);
0115 is.clear();
0116 if(negative)
0117 t = -t;
0118 return is;
0119 }
0120
0121 template<class CharType>
0122 basic_istream<CharType> &
0123 operator>>(basic_istream<CharType> &is, boost::uint64_t & t){
0124 boost::int64_t it;
0125 is >> it;
0126 t = it;
0127 return is;
0128 }
0129
0130 template<>
0131 class back_insert_iterator<basic_string<char> > : public
0132 iterator<output_iterator_tag, char>
0133 {
0134 public:
0135 typedef basic_string<char> container_type;
0136 typedef container_type::reference reference;
0137
0138 explicit back_insert_iterator(container_type & s)
0139 : container(& s)
0140 {}
0141
0142 back_insert_iterator<container_type> & operator=(
0143 container_type::const_reference Val_
0144 ){
0145
0146 *container += Val_;
0147 return (*this);
0148 }
0149
0150 back_insert_iterator<container_type> & operator*(){
0151 return (*this);
0152 }
0153
0154 back_insert_iterator<container_type> & operator++(){
0155
0156 return (*this);
0157 }
0158
0159 back_insert_iterator<container_type> operator++(int){
0160
0161 return (*this);
0162 }
0163
0164 protected:
0165 container_type *container;
0166 };
0167
0168 template<char>
0169 inline back_insert_iterator<basic_string<char> > back_inserter(
0170 basic_string<char> & s
0171 ){
0172 return (std::back_insert_iterator<basic_string<char> >(s));
0173 }
0174
0175 template<>
0176 class back_insert_iterator<basic_string<wchar_t> > : public
0177 iterator<output_iterator_tag, wchar_t>
0178 {
0179 public:
0180 typedef basic_string<wchar_t> container_type;
0181 typedef container_type::reference reference;
0182
0183 explicit back_insert_iterator(container_type & s)
0184 : container(& s)
0185 {}
0186
0187 back_insert_iterator<container_type> & operator=(
0188 container_type::const_reference Val_
0189 ){
0190
0191 *container += Val_;
0192 return (*this);
0193 }
0194
0195 back_insert_iterator<container_type> & operator*(){
0196 return (*this);
0197 }
0198
0199 back_insert_iterator<container_type> & operator++(){
0200
0201 return (*this);
0202 }
0203
0204 back_insert_iterator<container_type> operator++(int){
0205
0206 return (*this);
0207 }
0208
0209 protected:
0210 container_type *container;
0211 };
0212
0213 template<wchar_t>
0214 inline back_insert_iterator<basic_string<wchar_t> > back_inserter(
0215 basic_string<wchar_t> & s
0216 ){
0217 return (std::back_insert_iterator<basic_string<wchar_t> >(s));
0218 }
0219
0220 }
0221
0222 #endif