Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:29

0001 #ifndef BOOST_ARCHIVE_ITERATORS_BASE64_FROM_BINARY_HPP
0002 #define BOOST_ARCHIVE_ITERATORS_BASE64_FROM_BINARY_HPP
0003 
0004 // MS compatible compilers support #pragma once
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008 
0009 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0010 // base64_from_binary.hpp
0011 
0012 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
0013 // Use, modification and distribution is subject to the Boost Software
0014 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0015 // http://www.boost.org/LICENSE_1_0.txt)
0016 
0017 //  See http://www.boost.org for updates, documentation, and revision history.
0018 
0019 #include <boost/assert.hpp>
0020 
0021 #include <cstddef> // size_t
0022 #if defined(BOOST_NO_STDC_NAMESPACE)
0023 namespace std{
0024     using ::size_t;
0025 } // namespace std
0026 #endif
0027 
0028 #include <boost/iterator/transform_iterator.hpp>
0029 #include <boost/archive/iterators/dataflow_exception.hpp>
0030 
0031 namespace boost {
0032 namespace archive {
0033 namespace iterators {
0034 
0035 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0036 // convert binary integers to base64 characters
0037 
0038 namespace detail {
0039 
0040 template<class CharType>
0041 struct from_6_bit {
0042     typedef CharType result_type;
0043     CharType operator()(CharType t) const{
0044         static const char * lookup_table =
0045             "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
0046             "abcdefghijklmnopqrstuvwxyz"
0047             "0123456789"
0048             "+/";
0049         BOOST_ASSERT(t < 64);
0050         return lookup_table[static_cast<size_t>(t)];
0051     }
0052 };
0053 
0054 } // namespace detail
0055 
0056 // note: what we would like to do is
0057 // template<class Base, class CharType = typename Base::value_type>
0058 //  typedef transform_iterator<
0059 //      from_6_bit<CharType>,
0060 //      transform_width<Base, 6, sizeof(Base::value_type) * 8, CharType>
0061 //  > base64_from_binary;
0062 // but C++ won't accept this.  Rather than using a "type generator" and
0063 // using a different syntax, make a derivation which should be equivalent.
0064 //
0065 // Another issue addressed here is that the transform_iterator doesn't have
0066 // a templated constructor.  This makes it incompatible with the dataflow
0067 // ideal.  This is also addressed here.
0068 
0069 //template<class Base, class CharType = typename Base::value_type>
0070 template<
0071     class Base,
0072     class CharType = typename boost::iterator_value<Base>::type
0073 >
0074 class base64_from_binary :
0075     public transform_iterator<
0076         detail::from_6_bit<CharType>,
0077         Base
0078     >
0079 {
0080     friend class boost::iterator_core_access;
0081     typedef transform_iterator<
0082         typename detail::from_6_bit<CharType>,
0083         Base
0084     > super_t;
0085 
0086 public:
0087     // make composable by using templated constructor
0088     template<class T>
0089     base64_from_binary(T start) :
0090         super_t(
0091             Base(static_cast< T >(start)),
0092             detail::from_6_bit<CharType>()
0093         )
0094     {}
0095     // intel 7.1 doesn't like default copy constructor
0096     base64_from_binary(const base64_from_binary & rhs) :
0097         super_t(
0098             Base(rhs.base_reference()),
0099             detail::from_6_bit<CharType>()
0100         )
0101     {}
0102 //    base64_from_binary(){};
0103 };
0104 
0105 } // namespace iterators
0106 } // namespace archive
0107 } // namespace boost
0108 
0109 #endif // BOOST_ARCHIVE_ITERATORS_BASE64_FROM_BINARY_HPP