stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork

This commit is contained in:
2026-02-24 18:38:47 +00:00
parent da8c28aaeb
commit 65cb2619a7
13106 changed files with 2484322 additions and 1804 deletions
@@ -0,0 +1,68 @@
#ifndef BOOST_ARCHIVE_ITERATORS_BASE64_EXCEPTION_HPP
#define BOOST_ARCHIVE_ITERATORS_BASE64_EXCEPTION_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// base64_exception.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/config.hpp>
#ifndef BOOST_NO_EXCEPTIONS
#include <exception>
#include <boost/assert.hpp>
namespace boost {
namespace archive {
namespace iterators {
//////////////////////////////////////////////////////////////////////
// exceptions thrown by base64s
//
class base64_exception : public std::exception
{
public:
typedef enum {
invalid_code, // attempt to encode a value > 6 bits
invalid_character, // decode a value not in base64 char set
other_exception
} exception_code;
exception_code code;
base64_exception(exception_code c = other_exception) : code(c)
{}
virtual const char *what( ) const throw( )
{
const char *msg = "unknown exception code";
switch(code){
case invalid_code:
msg = "attempt to encode a value > 6 bits";
break;
case invalid_character:
msg = "attempt to decode a value not in base64 char set";
break;
default:
BOOST_ASSERT(false);
break;
}
return msg;
}
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif //BOOST_NO_EXCEPTIONS
#endif //BOOST_ARCHIVE_ITERATORS_ARCHIVE_EXCEPTION_HPP
@@ -0,0 +1,109 @@
#ifndef BOOST_ARCHIVE_ITERATORS_BASE64_FROM_BINARY_HPP
#define BOOST_ARCHIVE_ITERATORS_BASE64_FROM_BINARY_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// base64_from_binary.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 <cstddef> // size_t
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::size_t;
} // namespace std
#endif
#include <boost/iterator/transform_iterator.hpp>
#include <boost/archive/iterators/dataflow_exception.hpp>
namespace boost {
namespace archive {
namespace iterators {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// convert binary integers to base64 characters
namespace detail {
template<class CharType>
struct from_6_bit {
typedef CharType result_type;
CharType operator()(CharType t) const{
const char * lookup_table =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789"
"+/";
BOOST_ASSERT(t < 64);
return lookup_table[static_cast<size_t>(t)];
}
};
} // namespace detail
// note: what we would like to do is
// template<class Base, class CharType = typename Base::value_type>
// typedef transform_iterator<
// from_6_bit<CharType>,
// transform_width<Base, 6, sizeof(Base::value_type) * 8, CharType>
// > base64_from_binary;
// but C++ won't accept this. Rather than using a "type generator" and
// using a different syntax, make a derivation which should be equivalent.
//
// Another issue addressed here is that the transform_iterator doesn't have
// a templated constructor. This makes it incompatible with the dataflow
// ideal. This is also addressed here.
//template<class Base, class CharType = typename Base::value_type>
template<
class Base,
class CharType = typename boost::iterator_value<Base>::type
>
class base64_from_binary :
public transform_iterator<
detail::from_6_bit<CharType>,
Base
>
{
friend class boost::iterator_core_access;
typedef transform_iterator<
typename detail::from_6_bit<CharType>,
Base
> super_t;
public:
// make composible buy using templated constructor
template<class T>
base64_from_binary(T start) :
super_t(
Base(static_cast< T >(start)),
detail::from_6_bit<CharType>()
)
{}
// intel 7.1 doesn't like default copy constructor
base64_from_binary(const base64_from_binary & rhs) :
super_t(
Base(rhs.base_reference()),
detail::from_6_bit<CharType>()
)
{}
// base64_from_binary(){};
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_BASE64_FROM_BINARY_HPP
@@ -0,0 +1,118 @@
#ifndef BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE64_HPP
#define BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE64_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// binary_from_base64.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/throw_exception.hpp>
#include <boost/static_assert.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/archive/iterators/dataflow_exception.hpp>
namespace boost {
namespace archive {
namespace iterators {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// convert base64 characters to binary data
namespace detail {
template<class CharType>
struct to_6_bit {
typedef CharType result_type;
CharType operator()(CharType t) const{
const signed char lookup_table[] = {
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
52,53,54,55,56,57,58,59,60,61,-1,-1,-1, 0,-1,-1, // render '=' as 0
-1, 0, 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,-1,-1,-1,-1,-1,
-1,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,-1,-1,-1,-1,-1
};
// metrowerks trips this assertion - how come?
#if ! defined(__MWERKS__)
BOOST_STATIC_ASSERT(128 == sizeof(lookup_table));
#endif
signed char value = -1;
if((unsigned)t <= 127)
value = lookup_table[(unsigned)t];
if(-1 == value)
boost::serialization::throw_exception(
dataflow_exception(dataflow_exception::invalid_base64_character)
);
return value;
}
};
} // namespace detail
// note: what we would like to do is
// template<class Base, class CharType = typename Base::value_type>
// typedef transform_iterator<
// from_6_bit<CharType>,
// transform_width<Base, 6, sizeof(Base::value_type) * 8, CharType>
// > base64_from_binary;
// but C++ won't accept this. Rather than using a "type generator" and
// using a different syntax, make a derivation which should be equivalent.
//
// Another issue addressed here is that the transform_iterator doesn't have
// a templated constructor. This makes it incompatible with the dataflow
// ideal. This is also addressed here.
template<
class Base,
class CharType = typename boost::iterator_value<Base>::type
>
class binary_from_base64 : public
transform_iterator<
detail::to_6_bit<CharType>,
Base
>
{
friend class boost::iterator_core_access;
typedef transform_iterator<
detail::to_6_bit<CharType>,
Base
> super_t;
public:
// make composible buy using templated constructor
template<class T>
binary_from_base64(T start) :
super_t(
Base(static_cast< T >(start)),
detail::to_6_bit<CharType>()
)
{}
// intel 7.1 doesn't like default copy constructor
binary_from_base64(const binary_from_base64 & rhs) :
super_t(
Base(rhs.base_reference()),
detail::to_6_bit<CharType>()
)
{}
// binary_from_base64(){};
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE64_HPP
@@ -0,0 +1,102 @@
#ifndef BOOST_ARCHIVE_ITERATORS_DATAFLOW_HPP
#define BOOST_ARCHIVE_ITERATORS_DATAFLOW_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// dataflow.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/mpl/eval_if.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/int.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/static_assert.hpp>
namespace boost {
namespace archive {
namespace iterators {
// poor man's tri-state
struct tri_state {
enum state_enum {
is_false = false,
is_true = true,
is_indeterminant
} m_state;
// convert to bool
operator bool (){
BOOST_ASSERT(is_indeterminant != m_state);
return is_true == m_state ? true : false;
}
// assign from bool
tri_state & operator=(bool rhs) {
m_state = rhs ? is_true : is_false;
return *this;
}
tri_state(bool rhs) :
m_state(rhs ? is_true : is_false)
{}
tri_state(state_enum state) :
m_state(state)
{}
bool operator==(const tri_state & rhs) const {
return m_state == rhs.m_state;
}
bool operator!=(const tri_state & rhs) const {
return m_state != rhs.m_state;
}
};
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// implement functions common to dataflow iterators
template<class Derived>
class dataflow {
bool m_eoi;
protected:
// test for iterator equality
tri_state equal(const Derived & rhs) const {
if(m_eoi && rhs.m_eoi)
return true;
if(m_eoi || rhs.m_eoi)
return false;
return tri_state(tri_state::is_indeterminant);
}
void eoi(bool tf){
m_eoi = tf;
}
bool eoi() const {
return m_eoi;
}
public:
dataflow(bool tf) :
m_eoi(tf)
{}
dataflow() : // used for iterator end
m_eoi(true)
{}
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_DATAFLOW_HPP
@@ -0,0 +1,80 @@
#ifndef BOOST_ARCHIVE_ITERATORS_DATAFLOW_EXCEPTION_HPP
#define BOOST_ARCHIVE_ITERATORS_DATAFLOW_EXCEPTION_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// dataflow_exception.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/config.hpp>
#ifndef BOOST_NO_EXCEPTIONS
#include <exception>
#endif //BOOST_NO_EXCEPTIONS
#include <boost/assert.hpp>
namespace boost {
namespace archive {
namespace iterators {
//////////////////////////////////////////////////////////////////////
// exceptions thrown by dataflows
//
class dataflow_exception : public std::exception
{
public:
typedef enum {
invalid_6_bitcode,
invalid_base64_character,
invalid_xml_escape_sequence,
comparison_not_permitted,
invalid_conversion,
other_exception
} exception_code;
exception_code code;
dataflow_exception(exception_code c = other_exception) : code(c)
{}
virtual const char *what( ) const throw( )
{
const char *msg = "unknown exception code";
switch(code){
case invalid_6_bitcode:
msg = "attempt to encode a value > 6 bits";
break;
case invalid_base64_character:
msg = "attempt to decode a value not in base64 char set";
break;
case invalid_xml_escape_sequence:
msg = "invalid xml escape_sequence";
break;
case comparison_not_permitted:
msg = "cannot invoke iterator comparison now";
break;
case invalid_conversion:
msg = "invalid multbyte/wide char conversion";
break;
default:
BOOST_ASSERT(false);
break;
}
return msg;
}
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif //BOOST_ARCHIVE_ITERATORS_DATAFLOW_EXCEPTION_HPP
@@ -0,0 +1,114 @@
#ifndef BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP
#define BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// escape.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 <cstddef> // NULL
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_traits.hpp>
namespace boost {
namespace archive {
namespace iterators {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// insert escapes into text
template<class Derived, class Base>
class escape :
public boost::iterator_adaptor<
Derived,
Base,
typename boost::iterator_value<Base>::type,
single_pass_traversal_tag,
typename boost::iterator_value<Base>::type
>
{
typedef typename boost::iterator_value<Base>::type base_value_type;
typedef typename boost::iterator_reference<Base>::type reference_type;
friend class boost::iterator_core_access;
typedef typename boost::iterator_adaptor<
Derived,
Base,
base_value_type,
single_pass_traversal_tag,
base_value_type
> super_t;
typedef escape<Derived, Base> this_t;
void dereference_impl() {
m_current_value = static_cast<Derived *>(this)->fill(m_bnext, m_bend);
m_full = true;
}
//Access the value referred to
reference_type dereference() const {
if(!m_full)
const_cast<this_t *>(this)->dereference_impl();
return m_current_value;
}
bool equal(const this_t & rhs) const {
if(m_full){
if(! rhs.m_full)
const_cast<this_t *>(& rhs)->dereference_impl();
}
else{
if(rhs.m_full)
const_cast<this_t *>(this)->dereference_impl();
}
if(m_bnext != rhs.m_bnext)
return false;
if(this->base_reference() != rhs.base_reference())
return false;
return true;
}
void increment(){
if(++m_bnext < m_bend){
m_current_value = *m_bnext;
return;
}
++(this->base_reference());
m_bnext = NULL;
m_bend = NULL;
m_full = false;
}
// buffer to handle pending characters
const base_value_type *m_bnext;
const base_value_type *m_bend;
bool m_full;
base_value_type m_current_value;
public:
escape(Base base) :
super_t(base),
m_bnext(NULL),
m_bend(NULL),
m_full(false)
{
}
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP
@@ -0,0 +1,99 @@
#ifndef BOOST_ARCHIVE_ITERATORS_INSERT_LINEBREAKS_HPP
#define BOOST_ARCHIVE_ITERATORS_INSERT_LINEBREAKS_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// insert_linebreaks.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/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{ using ::memcpy; }
#endif
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_traits.hpp>
namespace boost {
namespace archive {
namespace iterators {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// insert line break every N characters
template<
class Base,
int N,
class CharType = typename boost::iterator_value<Base>::type
>
class insert_linebreaks :
public iterator_adaptor<
insert_linebreaks<Base, N, CharType>,
Base,
CharType,
single_pass_traversal_tag,
CharType
>
{
private:
friend class boost::iterator_core_access;
typedef iterator_adaptor<
insert_linebreaks<Base, N, CharType>,
Base,
CharType,
single_pass_traversal_tag,
CharType
> super_t;
bool equal(const insert_linebreaks<Base, N, CharType> & rhs) const {
return
// m_count == rhs.m_count
// && base_reference() == rhs.base_reference()
this->base_reference() == rhs.base_reference()
;
}
void increment() {
if(m_count == N){
m_count = 0;
return;
}
++m_count;
++(this->base_reference());
}
CharType dereference() const {
if(m_count == N)
return '\n';
return * (this->base_reference());
}
unsigned int m_count;
public:
// make composible buy using templated constructor
template<class T>
insert_linebreaks(T start) :
super_t(Base(static_cast< T >(start))),
m_count(0)
{}
// intel 7.1 doesn't like default copy constructor
insert_linebreaks(const insert_linebreaks & rhs) :
super_t(rhs.base_reference()),
m_count(rhs.m_count)
{}
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_INSERT_LINEBREAKS_HPP
@@ -0,0 +1,92 @@
#ifndef BOOST_ARCHIVE_ITERATORS_ISTREAM_ITERATOR_HPP
#define BOOST_ARCHIVE_ITERATORS_ISTREAM_ITERATOR_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// istream_iterator.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.
// note: this is a custom version of the standard istream_iterator.
// This is necessary as the standard version doesn't work as expected
// for wchar_t based streams on systems for which wchar_t not a true
// type but rather a synonym for some integer type.
#include <cstddef> // NULL
#include <istream>
#include <boost/iterator/iterator_facade.hpp>
namespace boost {
namespace archive {
namespace iterators {
// given a type, make an input iterator based on a pointer to that type
template<class Elem = char>
class istream_iterator :
public boost::iterator_facade<
istream_iterator<Elem>,
Elem,
std::input_iterator_tag,
Elem
>
{
friend class boost::iterator_core_access;
typedef istream_iterator this_t ;
typedef typename boost::iterator_facade<
istream_iterator<Elem>,
Elem,
std::input_iterator_tag,
Elem
> super_t;
typedef typename std::basic_istream<Elem> istream_type;
bool equal(const this_t & rhs) const {
// note: only works for comparison against end of stream
return m_istream == rhs.m_istream;
}
//Access the value referred to
Elem dereference() const {
return m_istream->peek();
}
void increment(){
if(NULL != m_istream){
m_istream->ignore(1);
}
}
istream_type *m_istream;
Elem m_current_value;
public:
istream_iterator(istream_type & is) :
m_istream(& is)
{
//increment();
}
istream_iterator() :
m_istream(NULL)
{}
istream_iterator(const istream_iterator<Elem> & rhs) :
m_istream(rhs.m_istream),
m_current_value(rhs.m_current_value)
{}
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_ISTREAM_ITERATOR_HPP
@@ -0,0 +1,138 @@
#ifndef BOOST_ARCHIVE_ITERATORS_MB_FROM_WCHAR_HPP
#define BOOST_ARCHIVE_ITERATORS_MB_FROM_WCHAR_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// mb_from_wchar.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 <cstddef> // size_t
#include <cwchar> // mbstate_t
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::mbstate_t;
} // namespace std
#endif
#include <boost/archive/detail/utf8_codecvt_facet.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
namespace boost {
namespace archive {
namespace iterators {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// class used by text archives to translate wide strings and to char
// strings of the currently selected locale
template<class Base> // the input iterator
class mb_from_wchar
: public boost::iterator_adaptor<
mb_from_wchar<Base>,
Base,
wchar_t,
single_pass_traversal_tag,
char
>
{
friend class boost::iterator_core_access;
typedef typename boost::iterator_adaptor<
mb_from_wchar<Base>,
Base,
wchar_t,
single_pass_traversal_tag,
char
> super_t;
typedef mb_from_wchar<Base> this_t;
char dereference_impl() {
if(! m_full){
fill();
m_full = true;
}
return m_buffer[m_bnext];
}
char dereference() const {
return (const_cast<this_t *>(this))->dereference_impl();
}
// test for iterator equality
bool equal(const mb_from_wchar<Base> & rhs) const {
// once the value is filled, the base_reference has been incremented
// so don't permit comparison anymore.
return
0 == m_bend
&& 0 == m_bnext
&& this->base_reference() == rhs.base_reference()
;
}
void fill(){
wchar_t value = * this->base_reference();
const wchar_t *wend;
char *bend;
std::codecvt_base::result r = m_codecvt_facet.out(
m_mbs,
& value, & value + 1, wend,
m_buffer, m_buffer + sizeof(m_buffer), bend
);
BOOST_ASSERT(std::codecvt_base::ok == r);
m_bnext = 0;
m_bend = bend - m_buffer;
}
void increment(){
if(++m_bnext < m_bend)
return;
m_bend =
m_bnext = 0;
++(this->base_reference());
m_full = false;
}
boost::archive::detail::utf8_codecvt_facet m_codecvt_facet;
std::mbstate_t m_mbs;
// buffer to handle pending characters
char m_buffer[9 /* MB_CUR_MAX */];
std::size_t m_bend;
std::size_t m_bnext;
bool m_full;
public:
// make composible buy using templated constructor
template<class T>
mb_from_wchar(T start) :
super_t(Base(static_cast< T >(start))),
m_mbs(std::mbstate_t()),
m_bend(0),
m_bnext(0),
m_full(false)
{}
// intel 7.1 doesn't like default copy constructor
mb_from_wchar(const mb_from_wchar & rhs) :
super_t(rhs.base_reference()),
m_bend(rhs.m_bend),
m_bnext(rhs.m_bnext),
m_full(rhs.m_full)
{}
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_MB_FROM_WCHAR_HPP
@@ -0,0 +1,83 @@
#ifndef BOOST_ARCHIVE_ITERATORS_OSTREAM_ITERATOR_HPP
#define BOOST_ARCHIVE_ITERATORS_OSTREAM_ITERATOR_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// ostream_iterator.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.
// note: this is a custom version of the standard ostream_iterator.
// This is necessary as the standard version doesn't work as expected
// for wchar_t based streams on systems for which wchar_t not a true
// type but rather a synonym for some integer type.
#include <ostream>
#include <boost/iterator/iterator_facade.hpp>
namespace boost {
namespace archive {
namespace iterators {
// given a type, make an input iterator based on a pointer to that type
template<class Elem>
class ostream_iterator :
public boost::iterator_facade<
ostream_iterator<Elem>,
Elem,
std::output_iterator_tag,
ostream_iterator<Elem> &
>
{
friend class boost::iterator_core_access;
typedef ostream_iterator this_t ;
typedef Elem char_type;
typedef std::basic_ostream<char_type> ostream_type;
//emulate the behavior of std::ostream
ostream_iterator & dereference() const {
return const_cast<ostream_iterator &>(*this);
}
bool equal(const this_t & rhs) const {
return m_ostream == rhs.m_ostream;
}
void increment(){}
protected:
ostream_type *m_ostream;
void put_val(char_type e){
if(NULL != m_ostream){
m_ostream->put(e);
if(! m_ostream->good())
m_ostream = NULL;
}
}
public:
this_t & operator=(char_type c){
put_val(c);
return *this;
}
ostream_iterator(ostream_type & os) :
m_ostream (& os)
{}
ostream_iterator() :
m_ostream (NULL)
{}
ostream_iterator(const ostream_iterator & rhs) :
m_ostream (rhs.m_ostream)
{}
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_OSTREAM_ITERATOR_HPP
@@ -0,0 +1,167 @@
#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/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(T start) :
super_t(Base(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
@@ -0,0 +1,176 @@
#ifndef BOOST_ARCHIVE_ITERATORS_TRANSFORM_WIDTH_HPP
#define BOOST_ARCHIVE_ITERATORS_TRANSFORM_WIDTH_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// transform_width.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.
// iterator which takes elements of x bits and returns elements of y bits.
// used to change streams of 8 bit characters into streams of 6 bit characters.
// and vice-versa for implementing base64 encodeing/decoding. Be very careful
// when using and end iterator. end is only reliable detected when the input
// stream length is some common multiple of x and y. E.G. Base64 6 bit
// character and 8 bit bytes. Lowest common multiple is 24 => 4 6 bit characters
// or 3 8 bit characters
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <algorithm> // std::min
namespace boost {
namespace archive {
namespace iterators {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// class used by text archives to translate char strings to wchar_t
// strings of the currently selected locale
template<
class Base,
int BitsOut,
int BitsIn,
class CharType = typename boost::iterator_value<Base>::type // output character
>
class transform_width :
public boost::iterator_adaptor<
transform_width<Base, BitsOut, BitsIn, CharType>,
Base,
CharType,
single_pass_traversal_tag,
CharType
>
{
friend class boost::iterator_core_access;
typedef typename boost::iterator_adaptor<
transform_width<Base, BitsOut, BitsIn, CharType>,
Base,
CharType,
single_pass_traversal_tag,
CharType
> super_t;
typedef transform_width<Base, BitsOut, BitsIn, CharType> this_t;
typedef typename iterator_value<Base>::type base_value_type;
void fill();
CharType dereference() const {
if(!m_buffer_out_full)
const_cast<this_t *>(this)->fill();
return m_buffer_out;
}
bool equal_impl(const this_t & rhs){
if(BitsIn < BitsOut) // discard any left over bits
return this->base_reference() == rhs.base_reference();
else{
// BitsIn > BitsOut // zero fill
if(this->base_reference() == rhs.base_reference()){
m_end_of_sequence = true;
return 0 == m_remaining_bits;
}
return false;
}
}
// standard iterator interface
bool equal(const this_t & rhs) const {
return const_cast<this_t *>(this)->equal_impl(rhs);
}
void increment(){
m_buffer_out_full = false;
}
bool m_buffer_out_full;
CharType m_buffer_out;
// last read element from input
base_value_type m_buffer_in;
// number of bits to left in the input buffer.
unsigned int m_remaining_bits;
// flag to indicate we've reached end of data.
bool m_end_of_sequence;
public:
// make composible buy using templated constructor
template<class T>
transform_width(T start) :
super_t(Base(static_cast< T >(start))),
m_buffer_out_full(false),
// To disable GCC warning, but not truly necessary
//(m_buffer_in will be initialized later before being
//used because m_remaining_bits == 0)
m_buffer_in(0),
m_remaining_bits(0),
m_end_of_sequence(false)
{}
// intel 7.1 doesn't like default copy constructor
transform_width(const transform_width & rhs) :
super_t(rhs.base_reference()),
m_buffer_out_full(rhs.m_buffer_out_full),
m_buffer_out(rhs.m_buffer_out),
m_buffer_in(rhs.m_buffer_in),
m_remaining_bits(rhs.m_remaining_bits),
m_end_of_sequence(false)
{}
};
template<
class Base,
int BitsOut,
int BitsIn,
class CharType
>
void transform_width<Base, BitsOut, BitsIn, CharType>::fill() {
unsigned int missing_bits = BitsOut;
m_buffer_out = 0;
do{
if(0 == m_remaining_bits){
if(m_end_of_sequence){
m_buffer_in = 0;
m_remaining_bits = missing_bits;
}
else{
m_buffer_in = * this->base_reference()++;
m_remaining_bits = BitsIn;
}
}
// append these bits to the next output
// up to the size of the output
unsigned int i = (std::min)(missing_bits, m_remaining_bits);
// shift interesting bits to least significant position
base_value_type j = m_buffer_in >> (m_remaining_bits - i);
// and mask off the un interesting higher bits
// note presumption of twos complement notation
j &= (1 << i) - 1;
// append then interesting bits to the output value
m_buffer_out <<= i;
m_buffer_out |= j;
// and update counters
missing_bits -= i;
m_remaining_bits -= i;
}while(0 < missing_bits);
m_buffer_out_full = true;
}
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_TRANSFORM_WIDTH_HPP
@@ -0,0 +1,89 @@
#ifndef BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP
#define BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// unescape.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/iterator/iterator_adaptor.hpp>
#include <boost/pointee.hpp>
namespace boost {
namespace archive {
namespace iterators {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// class used by text archives to translate char strings to wchar_t
// strings of the currently selected locale
template<class Derived, class Base>
class unescape
: public boost::iterator_adaptor<
unescape<Derived, Base>,
Base,
typename pointee<Base>::type,
single_pass_traversal_tag,
typename pointee<Base>::type
>
{
friend class boost::iterator_core_access;
typedef typename boost::iterator_adaptor<
unescape<Derived, Base>,
Base,
typename pointee<Base>::type,
single_pass_traversal_tag,
typename pointee<Base>::type
> super_t;
typedef unescape<Derived, Base> this_t;
public:
typedef typename this_t::value_type value_type;
typedef typename this_t::reference reference;
private:
value_type dereference_impl() {
if(! m_full){
m_current_value = static_cast<Derived *>(this)->drain();
m_full = true;
}
return m_current_value;
}
reference dereference() const {
return const_cast<this_t *>(this)->dereference_impl();
}
value_type m_current_value;
bool m_full;
void increment(){
++(this->base_reference());
dereference_impl();
m_full = false;
};
public:
unescape(Base base) :
super_t(base),
m_full(false)
{}
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP
@@ -0,0 +1,192 @@
#ifndef BOOST_ARCHIVE_ITERATORS_WCHAR_FROM_MB_HPP
#define BOOST_ARCHIVE_ITERATORS_WCHAR_FROM_MB_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// wchar_from_mb.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 <cctype>
#include <cstddef> // size_t
#include <cwchar> // mbstate_t
#include <algorithm> // copy
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::mbstate_t;
} // namespace std
#endif
#include <boost/array.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/archive/detail/utf8_codecvt_facet.hpp>
#include <boost/archive/iterators/dataflow_exception.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <iostream>
namespace boost {
namespace archive {
namespace iterators {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// class used by text archives to translate char strings to wchar_t
// strings of the currently selected locale
template<class Base>
class wchar_from_mb
: public boost::iterator_adaptor<
wchar_from_mb<Base>,
Base,
wchar_t,
single_pass_traversal_tag,
wchar_t
>
{
friend class boost::iterator_core_access;
typedef typename boost::iterator_adaptor<
wchar_from_mb<Base>,
Base,
wchar_t,
single_pass_traversal_tag,
wchar_t
> super_t;
typedef wchar_from_mb<Base> this_t;
void drain();
wchar_t dereference() const {
if(m_output.m_next == m_output.m_next_available)
return static_cast<wchar_t>(0);
return * m_output.m_next;
}
void increment(){
if(m_output.m_next == m_output.m_next_available)
return;
if(++m_output.m_next == m_output.m_next_available){
if(m_input.m_done)
return;
drain();
}
}
bool equal(this_t const & rhs) const {
return dereference() == rhs.dereference();
}
boost::archive::detail::utf8_codecvt_facet m_codecvt_facet;
std::mbstate_t m_mbs;
template<typename T>
struct sliding_buffer {
boost::array<T, 32> m_buffer;
typename boost::array<T, 32>::const_iterator m_next_available;
typename boost::array<T, 32>::iterator m_next;
bool m_done;
// default ctor
sliding_buffer() :
m_next_available(m_buffer.begin()),
m_next(m_buffer.begin()),
m_done(false)
{}
// copy ctor
sliding_buffer(const sliding_buffer & rhs) :
m_next_available(
std::copy(
rhs.m_buffer.begin(),
rhs.m_next_available,
m_buffer.begin()
)
),
m_next(
m_buffer.begin() + (rhs.m_next - rhs.m_buffer.begin())
),
m_done(rhs.m_done)
{}
};
sliding_buffer<typename iterator_value<Base>::type> m_input;
sliding_buffer<typename iterator_value<this_t>::type> m_output;
public:
// make composible buy using templated constructor
template<class T>
wchar_from_mb(T start) :
super_t(Base(static_cast< T >(start))),
m_mbs(std::mbstate_t())
{
BOOST_ASSERT(std::mbsinit(&m_mbs));
drain();
}
// default constructor used as an end iterator
wchar_from_mb(){}
// copy ctor
wchar_from_mb(const wchar_from_mb & rhs) :
super_t(rhs.base_reference()),
m_mbs(rhs.m_mbs),
m_input(rhs.m_input),
m_output(rhs.m_output)
{}
};
template<class Base>
void wchar_from_mb<Base>::drain(){
BOOST_ASSERT(! m_input.m_done);
for(;;){
typename boost::iterators::iterator_reference<Base>::type c = *(this->base_reference());
// a null character in a multibyte stream is takes as end of string
if(0 == c){
m_input.m_done = true;
break;
}
++(this->base_reference());
* const_cast<typename iterator_value<Base>::type *>(
(m_input.m_next_available++)
) = c;
// if input buffer is full - we're done for now
if(m_input.m_buffer.end() == m_input.m_next_available)
break;
}
const typename boost::iterators::iterator_value<Base>::type * input_new_start;
typename iterator_value<this_t>::type * next_available;
std::codecvt_base::result r = m_codecvt_facet.in(
m_mbs,
m_input.m_buffer.begin(),
m_input.m_next_available,
input_new_start,
m_output.m_buffer.begin(),
m_output.m_buffer.end(),
next_available
);
BOOST_ASSERT(std::codecvt_base::ok == r);
m_output.m_next_available = next_available;
m_output.m_next = m_output.m_buffer.begin();
// we're done with some of the input so shift left.
m_input.m_next_available = std::copy(
input_new_start,
m_input.m_next_available,
m_input.m_buffer.begin()
);
m_input.m_next = m_input.m_buffer.begin();
}
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_WCHAR_FROM_MB_HPP
@@ -0,0 +1,121 @@
#ifndef BOOST_ARCHIVE_ITERATORS_XML_ESCAPE_HPP
#define BOOST_ARCHIVE_ITERATORS_XML_ESCAPE_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_escape.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/archive/iterators/escape.hpp>
namespace boost {
namespace archive {
namespace iterators {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// insert escapes into xml text
template<class Base>
class xml_escape
: public escape<xml_escape<Base>, Base>
{
friend class boost::iterator_core_access;
typedef escape<xml_escape<Base>, Base> super_t;
public:
char fill(const char * & bstart, const char * & bend);
wchar_t fill(const wchar_t * & bstart, const wchar_t * & bend);
template<class T>
xml_escape(T start) :
super_t(Base(static_cast< T >(start)))
{}
// intel 7.1 doesn't like default copy constructor
xml_escape(const xml_escape & rhs) :
super_t(rhs.base_reference())
{}
};
template<class Base>
char xml_escape<Base>::fill(
const char * & bstart,
const char * & bend
){
char current_value = * this->base_reference();
switch(current_value){
case '<':
bstart = "&lt;";
bend = bstart + 4;
break;
case '>':
bstart = "&gt;";
bend = bstart + 4;
break;
case '&':
bstart = "&amp;";
bend = bstart + 5;
break;
case '"':
bstart = "&quot;";
bend = bstart + 6;
break;
case '\'':
bstart = "&apos;";
bend = bstart + 6;
break;
default:
return current_value;
}
return *bstart;
}
template<class Base>
wchar_t xml_escape<Base>::fill(
const wchar_t * & bstart,
const wchar_t * & bend
){
wchar_t current_value = * this->base_reference();
switch(current_value){
case '<':
bstart = L"&lt;";
bend = bstart + 4;
break;
case '>':
bstart = L"&gt;";
bend = bstart + 4;
break;
case '&':
bstart = L"&amp;";
bend = bstart + 5;
break;
case '"':
bstart = L"&quot;";
bend = bstart + 6;
break;
case '\'':
bstart = L"&apos;";
bend = bstart + 6;
break;
default:
return current_value;
}
return *bstart;
}
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_XML_ESCAPE_HPP
@@ -0,0 +1,125 @@
#ifndef BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_HPP
#define BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_unescape.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/throw_exception.hpp>
#include <boost/archive/iterators/unescape.hpp>
#include <boost/archive/iterators/dataflow_exception.hpp>
namespace boost {
namespace archive {
namespace iterators {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// replace &??? xml escape sequences with the corresponding characters
template<class Base>
class xml_unescape
: public unescape<xml_unescape<Base>, Base>
{
friend class boost::iterator_core_access;
typedef xml_unescape<Base> this_t;
typedef unescape<this_t, Base> super_t;
typedef typename boost::iterator_reference<this_t> reference_type;
reference_type dereference() const {
return unescape<xml_unescape<Base>, Base>::dereference();
}
public:
// workaround msvc 7.1 ICU crash
#if defined(BOOST_MSVC)
typedef int value_type;
#else
typedef typename this_t::value_type value_type;
#endif
void drain_residue(const char *literal);
value_type drain();
template<class T>
xml_unescape(T start) :
super_t(Base(static_cast< T >(start)))
{}
// intel 7.1 doesn't like default copy constructor
xml_unescape(const xml_unescape & rhs) :
super_t(rhs.base_reference())
{}
};
template<class Base>
void xml_unescape<Base>::drain_residue(const char * literal){
do{
if(* literal != * ++(this->base_reference()))
boost::serialization::throw_exception(
dataflow_exception(
dataflow_exception::invalid_xml_escape_sequence
)
);
}
while('\0' != * ++literal);
}
// note key constraint on this function is that can't "look ahead" any
// more than necessary into base iterator. Doing so would alter the base
// iterator refenence which would make subsequent iterator comparisons
// incorrect and thereby break the composiblity of iterators.
template<class Base>
typename xml_unescape<Base>::value_type
//int
xml_unescape<Base>::drain(){
value_type retval = * this->base_reference();
if('&' != retval){
return retval;
}
retval = * ++(this->base_reference());
switch(retval){
case 'l': // &lt;
drain_residue("t;");
retval = '<';
break;
case 'g': // &gt;
drain_residue("t;");
retval = '>';
break;
case 'a':
retval = * ++(this->base_reference());
switch(retval){
case 'p': // &apos;
drain_residue("os;");
retval = '\'';
break;
case 'm': // &amp;
drain_residue("p;");
retval = '&';
break;
}
break;
case 'q':
drain_residue("uot;");
retval = '"';
break;
}
return retval;
}
} // namespace iterators
} // namespace archive
} // namespace boost
#endif // BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_HPP
@@ -0,0 +1,49 @@
#ifndef BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_EXCEPTION_HPP
#define BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_EXCEPTION_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_unescape_exception.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/config.hpp>
#ifndef BOOST_NO_EXCEPTIONS
#include <exception>
#include <boost/assert.hpp>
namespace boost {
namespace archive {
namespace iterators {
//////////////////////////////////////////////////////////////////////
// exceptions thrown by xml_unescapes
//
class xml_unescape_exception : public std::exception
{
public:
xml_unescape_exception()
{}
virtual const char *what( ) const throw( )
{
return "xml contained un-recognized escape code";
}
};
} // namespace iterators
} // namespace archive
} // namespace boost
#endif //BOOST_NO_EXCEPTIONS
#endif //BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_EXCEPTION_HPP