1 #ifndef BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_HPP
2 #define BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_HPP
4 // MS compatible compilers support #pragma once
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
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)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 #include <boost/assert.hpp>
21 #include <boost/serialization/throw_exception.hpp>
23 #include <boost/archive/iterators/unescape.hpp>
24 #include <boost/archive/iterators/dataflow_exception.hpp>
30 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
31 // replace &??? xml escape sequences with the corresponding characters
34 : public unescape<xml_unescape<Base>, Base>
36 friend class boost::iterator_core_access;
37 typedef xml_unescape<Base> this_t;
38 typedef unescape<this_t, Base> super_t;
39 typedef typename boost::iterator_reference<this_t> reference_type;
41 reference_type dereference() const {
42 return unescape<xml_unescape<Base>, Base>::dereference();
45 // workaround msvc 7.1 ICU crash
46 #if defined(BOOST_MSVC)
47 typedef int value_type;
49 typedef typename this_t::value_type value_type;
52 void drain_residue(const char *literal);
56 xml_unescape(T start) :
57 super_t(Base(static_cast< T >(start)))
59 // intel 7.1 doesn't like default copy constructor
60 xml_unescape(const xml_unescape & rhs) :
61 super_t(rhs.base_reference())
66 void xml_unescape<Base>::drain_residue(const char * literal){
68 if(* literal != * ++(this->base_reference()))
69 boost::serialization::throw_exception(
71 dataflow_exception::invalid_xml_escape_sequence
75 while('\0' != * ++literal);
78 // note key constraint on this function is that can't "look ahead" any
79 // more than necessary into base iterator. Doing so would alter the base
80 // iterator refenence which would make subsequent iterator comparisons
81 // incorrect and thereby break the composiblity of iterators.
83 typename xml_unescape<Base>::value_type
85 xml_unescape<Base>::drain(){
86 value_type retval = * this->base_reference();
90 retval = * ++(this->base_reference());
101 retval = * ++(this->base_reference());
104 drain_residue("os;");
114 drain_residue("uot;");
121 } // namespace iterators
122 } // namespace archive
125 #endif // BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_HPP