os/ossrv/ossrv_pub/boost_apis/boost/archive/dinkumware.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/archive/dinkumware.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,224 @@
     1.4 +#ifndef BOOST_ARCHIVE_DINKUMWARE_HPP
     1.5 +#define BOOST_ARCHIVE_DINKUMWARE_HPP
     1.6 +
     1.7 +// MS compatible compilers support #pragma once
     1.8 +#if defined(_MSC_VER) && (_MSC_VER >= 1020)
     1.9 +# pragma once
    1.10 +#endif
    1.11 +
    1.12 +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
    1.13 +// dinkumware.hpp:
    1.14 +
    1.15 +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 
    1.16 +// Use, modification and distribution is subject to the Boost Software
    1.17 +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    1.18 +// http://www.boost.org/LICENSE_1_0.txt)
    1.19 +
    1.20 +//  See http://www.boost.org for updates, documentation, and revision history.
    1.21 +
    1.22 +// this file adds a couple of things that are missing from the dinkumware
    1.23 +// implementation of the standard library.
    1.24 +
    1.25 +#include <iterator>
    1.26 +#include <string>
    1.27 +
    1.28 +#include <boost/config.hpp>
    1.29 +#include <boost/cstdint.hpp>
    1.30 +
    1.31 +namespace std {
    1.32 +
    1.33 +// define i/o operators for 64 bit integers
    1.34 +template<class CharType>
    1.35 +basic_ostream<CharType> & 
    1.36 +operator<<(basic_ostream<CharType> & os, boost::uint64_t t){
    1.37 +    // octal rendering of 64 bit number would be 22 octets + eos
    1.38 +    CharType d[23];
    1.39 +    unsigned int radix;
    1.40 +
    1.41 +    if(os.flags() & (int)std::ios_base::hex)
    1.42 +        radix = 16;
    1.43 +    else
    1.44 +    if(os.flags() & (int)std::ios_base::oct)
    1.45 +        radix = 8;
    1.46 +    else
    1.47 +    //if(s.flags() & (int)std::ios_base::dec)
    1.48 +        radix =  10;
    1.49 +    unsigned int i = 0;
    1.50 +    do{
    1.51 +        unsigned int j = t % radix;
    1.52 +        d[i++] = j + ((j < 10) ? '0' : ('a' - 10));
    1.53 +        t /= radix;
    1.54 +    }
    1.55 +    while(t > 0);
    1.56 +    d[i--] = '\0';
    1.57 +
    1.58 +    // reverse digits
    1.59 +    unsigned int j = 0;
    1.60 +    while(j < i){
    1.61 +        CharType k = d[i];
    1.62 +        d[i] = d[j];
    1.63 +        d[j] = k;
    1.64 +        --i;++j;
    1.65 +    }
    1.66 +    os << d;
    1.67 +    return os;
    1.68 +
    1.69 +}
    1.70 +
    1.71 +template<class CharType>
    1.72 +basic_ostream<CharType> & 
    1.73 +operator<<(basic_ostream<CharType> &os, boost::int64_t t){
    1.74 +    if(0 <= t){
    1.75 +        os << static_cast<boost::uint64_t>(t);
    1.76 +    }
    1.77 +    else{
    1.78 +        os.put('-');
    1.79 +        os << -t;
    1.80 +    }
    1.81 +    return os;
    1.82 +}
    1.83 +
    1.84 +template<class CharType>
    1.85 +basic_istream<CharType> & 
    1.86 +operator>>(basic_istream<CharType> &is, boost::int64_t & t){
    1.87 +    CharType d;
    1.88 +    do{
    1.89 +        d = is.get();
    1.90 +    }
    1.91 +    while(::isspace(d));
    1.92 +    bool negative = (d == '-');
    1.93 +    if(negative)
    1.94 +        d = is.get();
    1.95 +    unsigned int radix;
    1.96 +    if(is.flags() & (int)std::ios_base::hex)
    1.97 +        radix = 16;
    1.98 +    else
    1.99 +    if(is.flags() & (int)std::ios_base::oct)
   1.100 +        radix = 8;
   1.101 +    else
   1.102 +    //if(s.flags() & (int)std::ios_base::dec)
   1.103 +        radix =  10;
   1.104 +    t = 0;
   1.105 +    do{
   1.106 +        if('0' <= d && d <= '9')
   1.107 +            t = t * radix + (d - '0');
   1.108 +        else
   1.109 +        if('a' <= d && d <= 'f')
   1.110 +            t = t * radix + (d - 'a' + 10);
   1.111 +        else
   1.112 +            break;
   1.113 +        d = is.get();
   1.114 +    }
   1.115 +    while(!is.fail());
   1.116 +    // restore the delimiter
   1.117 +    is.putback(d);
   1.118 +    is.clear();
   1.119 +    if(negative)
   1.120 +        t = -t;
   1.121 +    return is;
   1.122 +}
   1.123 +
   1.124 +template<class CharType>
   1.125 +basic_istream<CharType> & 
   1.126 +operator>>(basic_istream<CharType> &is, boost::uint64_t & t){
   1.127 +    boost::int64_t it;
   1.128 +    is >> it;
   1.129 +    t = it;
   1.130 +    return is;
   1.131 +}
   1.132 +
   1.133 +//#endif
   1.134 +
   1.135 +template<>
   1.136 +class back_insert_iterator<basic_string<char> > : public 
   1.137 +    iterator<output_iterator_tag, char>
   1.138 +{
   1.139 +public:
   1.140 +    typedef basic_string<char> container_type;
   1.141 +    typedef container_type::reference reference;
   1.142 +
   1.143 +    explicit back_insert_iterator(container_type & s)
   1.144 +        : container(& s)
   1.145 +    {}    // construct with container
   1.146 +    
   1.147 +    back_insert_iterator<container_type> & operator=(
   1.148 +        container_type::const_reference Val_
   1.149 +    ){    // push value into container
   1.150 +        //container->push_back(Val_);
   1.151 +        *container += Val_;
   1.152 +        return (*this);
   1.153 +    }
   1.154 +
   1.155 +    back_insert_iterator<container_type> & operator*(){
   1.156 +        return (*this);
   1.157 +    }
   1.158 +
   1.159 +    back_insert_iterator<container_type> & operator++(){
   1.160 +        // pretend to preincrement
   1.161 +        return (*this);
   1.162 +    }
   1.163 +
   1.164 +    back_insert_iterator<container_type> operator++(int){
   1.165 +        // pretend to postincrement
   1.166 +        return (*this);
   1.167 +    }
   1.168 +
   1.169 +protected:
   1.170 +    container_type *container;    // pointer to container
   1.171 +};
   1.172 +
   1.173 +template<char> 
   1.174 +inline back_insert_iterator<basic_string<char> > back_inserter(
   1.175 +    basic_string<char> & s
   1.176 +){
   1.177 +    return (std::back_insert_iterator<basic_string<char> >(s));
   1.178 +}
   1.179 +
   1.180 +template<>
   1.181 +class back_insert_iterator<basic_string<wchar_t> > : public 
   1.182 +    iterator<output_iterator_tag, wchar_t>
   1.183 +{
   1.184 +public:
   1.185 +    typedef basic_string<wchar_t> container_type;
   1.186 +    typedef container_type::reference reference;
   1.187 +
   1.188 +    explicit back_insert_iterator(container_type & s)
   1.189 +        : container(& s)
   1.190 +    {}    // construct with container
   1.191 +    
   1.192 +    back_insert_iterator<container_type> & operator=(
   1.193 +        container_type::const_reference Val_
   1.194 +    ){    // push value into container
   1.195 +        //container->push_back(Val_);
   1.196 +        *container += Val_;
   1.197 +        return (*this);
   1.198 +    }
   1.199 +
   1.200 +    back_insert_iterator<container_type> & operator*(){
   1.201 +        return (*this);
   1.202 +    }
   1.203 +
   1.204 +    back_insert_iterator<container_type> & operator++(){
   1.205 +        // pretend to preincrement
   1.206 +        return (*this);
   1.207 +    }
   1.208 +
   1.209 +    back_insert_iterator<container_type> operator++(int){
   1.210 +        // pretend to postincrement
   1.211 +        return (*this);
   1.212 +    }
   1.213 +
   1.214 +protected:
   1.215 +    container_type *container;    // pointer to container
   1.216 +};
   1.217 +
   1.218 +template<wchar_t> 
   1.219 +inline back_insert_iterator<basic_string<wchar_t> > back_inserter(
   1.220 +    basic_string<wchar_t> & s
   1.221 +){
   1.222 +    return (std::back_insert_iterator<basic_string<wchar_t> >(s));
   1.223 +}
   1.224 +
   1.225 +} // namespace std
   1.226 +
   1.227 +#endif //BOOST_ARCHIVE_DINKUMWARE_HPP