1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
#ifndef BOOST_ARCHIVE_ITERATORS_REMOVE_WHITESPACE_HPP
#define BOOST_ARCHIVE_ITERATORS_REMOVE_WHITESPACE_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// remove_whitespace.hpp
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/assert.hpp>
#include <boost/serialization/pfto.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/filter_iterator.hpp>
#include <boost/iterator/iterator_traits.hpp>
// here is the default standard implementation of the functor used
// by the filter iterator to remove spaces. Unfortunately usage
// of this implementation in combination with spirit trips a bug
// VC 6.5. The only way I can find to work around it is to
// implement a special non-standard version for this platform
#ifndef BOOST_NO_CWCTYPE
#include <cwctype> // iswspace
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{ using ::iswspace; }
#endif
#endif
#include <cctype> // isspace
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{ using ::isspace; }
#endif
#if defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER)
// this is required for the RW STL on Linux and Tru64.
#undef isspace
#undef iswspace
#endif
namespace { // anonymous
template<class CharType>
struct remove_whitespace_predicate;
template<>
struct remove_whitespace_predicate<char>
{
bool operator()(unsigned char t){
return ! std::isspace(t);
}
};
#ifndef BOOST_NO_CWCHAR
template<>
struct remove_whitespace_predicate<wchar_t>
{
bool operator()(wchar_t t){
return ! std::iswspace(t);
}
};
#endif
} // namespace anonymous
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// convert base64 file data (including whitespace and padding) to binary
namespace boost {
namespace archive {
namespace iterators {
// custom version of filter iterator which doesn't look ahead further than
// necessary
template<class Predicate, class Base>
class filter_iterator
: public boost::iterator_adaptor<
filter_iterator<Predicate, Base>,
Base,
use_default,
single_pass_traversal_tag
>
{
friend class boost::iterator_core_access;
typedef typename boost::iterator_adaptor<
filter_iterator<Predicate, Base>,
Base,
use_default,
single_pass_traversal_tag
> super_t;
typedef filter_iterator<Predicate, Base> this_t;
typedef typename super_t::reference reference_type;
reference_type dereference_impl(){
if(! m_full){
while(! m_predicate(* this->base_reference()))
++(this->base_reference());
m_full = true;
}
return * this->base_reference();
}
reference_type dereference() const {
return const_cast<this_t *>(this)->dereference_impl();
}
Predicate m_predicate;
bool m_full;
public:
// note: this function is public only because comeau compiler complained
// I don't know if this is because the compiler is wrong or what
void increment(){
m_full = false;
++(this->base_reference());
}
filter_iterator(Base start) :
super_t(start),
m_full(false)
{}
filter_iterator(){}
};
template<class Base>
class remove_whitespace :
public filter_iterator<
remove_whitespace_predicate<
typename boost::iterator_value<Base>::type
//typename Base::value_type
>,
Base
>
{
friend class boost::iterator_core_access;
typedef filter_iterator<
remove_whitespace_predicate<
typename boost::iterator_value<Base>::type
//typename Base::value_type
>,
Base
> super_t;
public:
// remove_whitespace(){} // why is this needed?
// make composible buy using templated constructor
template<class T>
remove_whitespace(BOOST_PFTO_WRAPPER(T) start) :
super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start))))
{}
// intel 7.1 doesn't like default copy constructor
remove_whitespace(const remove_whitespace & rhs) :
super_t(rhs.base_reference())
{}
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_REMOVE_WHITESPACE_HPP
|