Click here to Skip to main content
15,880,392 members
Articles / Desktop Programming / Win32

Xport: XHTML Parsing and Objective Reporting Toolkit

Rate me:
Please Sign up or sign in to vote.
4.73/5 (10 votes)
4 May 2008GPL313 min read 60K   682   32  
Open source C++ class template library for generating and parsing xhtml documents.
/************************************************************************
Xport: XHTML Parsing & Objective Reporting Toolkit
Copyright (C) 2007  Mitchel Haas

This file is part of Xport.

Xport is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Xport is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Xport.  If not, see <http://www.gnu.org/licenses/>.

For complete documentation on this library and alternative
licensing options, visit http://www.xportpro.com
Email questions, comments or suggestions to mitchel.haas@xportpro.com
************************************************************************/
#pragma once
#include "markup_iterator.h"
#include <list>

namespace Xport 
{
  template<typename T, typename U> class xhtml_markup;
  template<typename T, typename U, typename V, typename W> class reverse_markup_iterator;
  template<typename T, typename U, typename V, typename W> class descendant_markup_iterator;
}

namespace XportPro
{
  template<typename T, typename U> class xp_markup;
}


/************************************************************************/
/* reverse_markup_iterator                                        */
/************************************************************************/
template<typename node_type, typename CT, typename pointer_type, typename reference_type>
class Xport::reverse_markup_iterator : public Xport::markup_iterator<node_type, CT, pointer_type, reference_type>
{
  typedef markup_iterator<node_type, CT, pointer_type, reference_type> child_iterator_type;
public:
  // constructors/destructor
  reverse_markup_iterator() : child_iterator_type::pIt_parent(0) {}
  // conversion constructor for const_reverse_iterator, copy constructor for reverse_iterator
  reverse_markup_iterator(const reverse_markup_iterator<node_type, CT, node_type*, node_type&>& src) : child_iterator_type(src) {}
  explicit reverse_markup_iterator(const child_iterator_type& _it) : child_iterator_type(_it) {}
  virtual ~reverse_markup_iterator() {}

  // destructor and assignment operator will be compiler generated correctly

public:
  // overloaded operators
  reference_type operator*() const { child_iterator_type tmp(*this); return (*--tmp); }
  pointer_type operator->() const { child_iterator_type tmp(*this); --tmp; return tmp.operator ->(); }

  reverse_markup_iterator& operator ++() { child_iterator_type::operator --(); return *this; }
  reverse_markup_iterator operator ++(int) { reverse_markup_iterator old(*this); ++*this; return old; }
  reverse_markup_iterator& operator --() { child_iterator_type::operator ++(); return *this; }
  reverse_markup_iterator operator --(int) { reverse_markup_iterator old(*this); --*this; return old; }

  child_iterator_type base() { return child_iterator_type(*this); }

  // friends
  #if defined(_MSC_VER) && _MSC_VER < 1300
    friend class xhtml_markup<xhtml_strict, CT>;
    friend class xhtml_markup<xhtml_frameset, CT>;
    friend class xhtml_markup<xhtml_transitional, CT>;
    friend class descendant_markup_iterator<node_type, CT, pointer_type, reference_type>;
  #else
    template<typename T, typename U> friend class xhtml_markup;
    template<typename T, typename U, typename V, typename W> friend class descendant_markup_iterator;
  #endif
  friend class reverse_markup_iterator<node_type, CT, const node_type*, const node_type&>; // needed for conversion constructor
  friend class XportPro::xp_markup<xhtml_strict, CT>;
  friend class XportPro::xp_markup<xhtml_transitional, CT>;
  friend class XportPro::xp_markup<xhtml_frameset, CT>;

};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)



Comments and Discussions