Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Xport: XHTML Parsing and Objective Reporting Toolkit

, 4 May 2008 GPL3
Open source C++ class template library for generating and parsing xhtml documents.
xport_1.6.1.zip
descendant_markup_iterator.inl
stylesheet.inl
stylesheet_formatter.inl
stylesheet_rule.inl
tag.inl
tag_trait.inl
tag_traits.inl
xhtml_comment.inl
xhtml_doc.inl
xhtml_element.inl
xhtml_formatter.inl
xhtml_frameset.inl
xhtml_markup.inl
xhtml_parser.inl
xhtml_processing_instruction.inl
xhtml_strict.inl
xhtml_transitional.inl
xport_1.6.5.zip
descendant_markup_iterator.inl
stylesheet.inl
stylesheet_formatter.inl
stylesheet_rule.inl
tag.inl
tag_trait.inl
tag_traits.inl
xhtml_comment.inl
xhtml_doc.inl
xhtml_element.inl
xhtml_formatter.inl
xhtml_frameset.inl
xhtml_markup.inl
xhtml_parser.inl
xhtml_processing_instruction.inl
xhtml_strict.inl
xhtml_transitional.inl
xport_1.6.7.zip
descendant_markup_iterator.inl
stylesheet.inl
stylesheet_formatter.inl
stylesheet_rule.inl
tag.inl
tag_trait.inl
tag_traits.inl
xhtml_comment.inl
xhtml_doc.inl
xhtml_element.inl
xhtml_formatter.inl
xhtml_frameset.inl
xhtml_markup.inl
xhtml_parser.inl
xhtml_processing_instruction.inl
xhtml_strict.inl
xhtml_transitional.inl
xport_documentation.zip
Xport.chm
xport_htmlhelp.zip
Xport.chm
/************************************************************************
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 "stylesheet_rule.h"
#include <vector>
#include <iterator>


namespace Xport 
{
  template<typename T, typename U, typename V> class stylesheet_rule_iterator;
  template<typename T> class xhtml_stylesheet_item;
}

namespace XportPro
{
  template<typename T> class xp_stylesheet_item;
}

template<typename CT, typename pointer_type, typename reference_type>
class Xport::stylesheet_rule_iterator 
#if defined(_MSC_VER) && _MSC_VER < 1300
  : public std::iterator<std::random_access_iterator_tag, Xport::stylesheet_declaration<CT> >
#else
  : public std::iterator<std::random_access_iterator_tag, Xport::stylesheet_declaration<CT>, ptrdiff_t, pointer_type, reference_type>
#endif
{
public:
  stylesheet_rule_iterator() {}
  // conversion constructor for const_iterator, copy constructor for iterator
  stylesheet_rule_iterator(const stylesheet_rule_iterator<CT, stylesheet_declaration<CT>*, stylesheet_declaration<CT>&>& src) : it(src.it) {}
  virtual ~stylesheet_rule_iterator() {}
protected:
  explicit stylesheet_rule_iterator(typename std::vector<stylesheet_declaration<CT> >::const_iterator _it) : it(_it) {}

public:
  // typedefs
  #if defined(_MSC_VER) && _MSC_VER < 1300
    typedef ptrdiff_t difference_type;
  #else
    typedef typename std::iterator_traits<stylesheet_rule_iterator>::difference_type difference_type;
  #endif

  // overloaded operators
  reference_type operator*() const { return  *it; }
  pointer_type operator->() const { return &(*it); }

  bool operator ==(const stylesheet_rule_iterator<CT, const stylesheet_declaration<CT>*, const stylesheet_declaration<CT>&>& rhs) const { return it == rhs.it; }
  bool operator !=(const stylesheet_rule_iterator<CT, const stylesheet_declaration<CT>*, const stylesheet_declaration<CT>&>& rhs) const { return !(*this == rhs); }
  bool operator < (const stylesheet_rule_iterator<CT, const stylesheet_declaration<CT>*, const stylesheet_declaration<CT>&>& rhs) const { return it < rhs.it; }
  #if !defined(_MSC_VER) || _MSC_VER >= 1300
    bool operator ==(const stylesheet_rule_iterator<CT, stylesheet_declaration<CT>*, stylesheet_declaration<CT>&>& rhs) const { return it == rhs.it; }
    bool operator !=(const stylesheet_rule_iterator<CT, stylesheet_declaration<CT>*, stylesheet_declaration<CT>&>& rhs) const { return !(*this == rhs); }
    bool operator <(const stylesheet_rule_iterator<CT, stylesheet_declaration<CT>*, stylesheet_declaration<CT>&>& rhs) const { return it < rhs.it; }
  #endif
  difference_type operator -(const stylesheet_rule_iterator& rhs) const { return it - rhs.it; }

  stylesheet_rule_iterator& operator ++() { ++it; return *this; }
  stylesheet_rule_iterator operator ++(int) { stylesheet_rule_iterator old(*this); ++*this; return old; }
  stylesheet_rule_iterator& operator --() { --it; return *this; }
  stylesheet_rule_iterator operator --(int) { stylesheet_rule_iterator old(*this); --*this; return old; }

protected:
  // data
  typename std::vector<stylesheet_declaration<CT> >::const_iterator it;

  // friends
  #if defined(_MSC_VER) && _MSC_VER < 1300
    friend class xhtml_stylesheet_item<CT>;
    friend class xhtml_stylesheet_rule<CT, xhtml_stylesheet_item<CT> >;
  #else
    template<typename T> friend class xhtml_stylesheet_item;
    template<typename T, typename U> friend class xhtml_stylesheet_rule;
  #endif
  friend class stylesheet_rule_iterator<CT, const stylesheet_declaration<CT>*, const stylesheet_declaration<CT>&>;  // needed for conversion constructor & equality operator
  friend class stylesheet_rule_iterator<CT, stylesheet_declaration<CT>*, stylesheet_declaration<CT>&>;  // needed for equality operator
  friend class XportPro::xp_stylesheet_item<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)

Share

About the Author

Mitchel Haas
Software Developer Datasoft Solutions
United States United States
I'm a c++ programmer in the midwest, now using VC7 at work and at home. I enjoy creating generic libraries, and template based programming.
 
I also enjoy web development (xhtml, css, javascript, php).

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 4 May 2008
Article Copyright 2008 by Mitchel Haas
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid