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
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
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 }
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
0036
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 }
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
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
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
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
0103 };
0104
0105 }
0106 }
0107 }
0108
0109 #endif