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