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/config.hpp>
20 #include <boost/detail/workaround.hpp>
21 #include <boost/assert.hpp>
23 #include <boost/serialization/throw_exception.hpp>
25 #include <boost/archive/iterators/unescape.hpp>
26 #include <boost/archive/iterators/dataflow_exception.hpp>
32 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
33 // replace &??? xml escape sequences with the corresponding characters
36 : public unescape<xml_unescape<Base>, Base>
38 friend class boost::iterator_core_access;
39 typedef xml_unescape<Base> this_t;
40 typedef unescape<this_t, Base> super_t;
41 typedef typename boost::iterator_reference<this_t> reference_type;
43 reference_type dereference() const {
44 return unescape<xml_unescape<Base>, Base>::dereference();
47 // msvc versions prior to 14.0 crash with and ICE
48 #if BOOST_WORKAROUND(BOOST_MSVC, < 1900)
49 typedef int value_type;
51 typedef typename super_t::value_type value_type;
54 void drain_residue(const char *literal);
58 xml_unescape(T start) :
59 super_t(Base(static_cast< T >(start)))
61 // intel 7.1 doesn't like default copy constructor
62 xml_unescape(const xml_unescape & rhs) :
63 super_t(rhs.base_reference())
68 void xml_unescape<Base>::drain_residue(const char * literal){
70 if(* literal != * ++(this->base_reference()))
71 boost::serialization::throw_exception(
73 dataflow_exception::invalid_xml_escape_sequence
77 while('\0' != * ++literal);
80 // note key constraint on this function is that can't "look ahead" any
81 // more than necessary into base iterator. Doing so would alter the base
82 // iterator refenence which would make subsequent iterator comparisons
83 // incorrect and thereby break the composiblity of iterators.
85 typename xml_unescape<Base>::value_type
87 xml_unescape<Base>::drain(){
88 value_type retval = * this->base_reference();
92 retval = * ++(this->base_reference());
103 retval = * ++(this->base_reference());
106 drain_residue("os;");
116 drain_residue("uot;");
123 } // namespace iterators
124 } // namespace archive
127 #endif // BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_HPP