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

Xport: XHTML Parsing and Objective Reporting Toolkit

, 4 May 2008
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_iterator.h"
#include <string>
#include <ostream>

namespace Xport
{
  template<typename T> class xhtml_stylesheet;
  template<typename T> class xhtml_stylesheet_item;
  template<typename T> class xhtml_stylesheet_rule;
  template<typename T> class xhtml_stylesheet_import;
  template<typename T> class xhtml_stylesheet_comment;
  template<typename T> class xhtml_stylesheet_formatter;
  template<typename T> struct deref_comp;
  enum ss_item_type { sit_unknown, sit_rule, sit_comment, sit_import };

  template<typename T> bool operator == (const xhtml_stylesheet_item<T>& lhs, const xhtml_stylesheet_item<T>& rhs) { return lhs.stylesheet_item_type() == rhs.stylesheet_item_type() && lhs.identifier() == rhs.identifier() && lhs.declarations == rhs.declarations; }
  template<typename T> bool operator != (const xhtml_stylesheet_item<T>& lhs, const xhtml_stylesheet_item<T>& rhs) { return !(lhs == rhs); }
}



/************************************************************************/
/* xhtml_stylesheet_item                                                */
/************************************************************************/
template<typename CT = char>
class Xport::xhtml_stylesheet_item
{
protected:
  xhtml_stylesheet_item() {}
  virtual ~xhtml_stylesheet_item() {}

public:
  // typedefs
  typedef stylesheet_declaration<CT> value_type;
  typedef stylesheet_declaration<CT>& reference_type;
  typedef const stylesheet_declaration<CT>& const_reference_type;
  typedef stylesheet_declaration<CT>* pointer_type;
  typedef const stylesheet_declaration<CT>* const_pointer_type;
  typedef ptrdiff_t difference_type;
  typedef size_t size_type;

  // iterators
  typedef stylesheet_rule_iterator<CT, stylesheet_declaration<CT>*, stylesheet_declaration<CT>&>              iterator;
  typedef stylesheet_rule_iterator<CT, const stylesheet_declaration<CT>*, const stylesheet_declaration<CT>&>  const_iterator;


  // iterator operations
  iterator begin() { return iterator(declarations.begin()); }
  const_iterator begin() const { return const_iterator(declarations.begin()); }
  iterator end() { return iterator(declarations.end()); }
  const_iterator end() const { return const_iterator(declarations.end()); }

  // public interface
  virtual iterator insert(const stylesheet_declaration<CT>& decl) { return iterator(declarations.end()); }
  virtual iterator insert(const_iterator pos, const stylesheet_declaration<CT>& decl) { return iterator(declarations.end()); }
  virtual void push_back(const stylesheet_declaration<CT>& decl) { }
  xhtml_stylesheet_item& operator << (const stylesheet_declaration<CT>& decl) { this->insert(decl); return *this; }

  stylesheet_declaration<CT>& operator[](size_type n) { return declarations[n]; }
  const stylesheet_declaration<CT>& operator[](size_type n) const { return declarations[n]; }
  stylesheet_declaration<CT>& at(size_type n) { return declarations.at(n); }
  const stylesheet_declaration<CT>& at(size_type n) const { return declarations.at(n); }
  bool empty() const { return declarations.empty(); }
  void clear() { declarations.clear(); }
  size_type size() const { return declarations.size(); }
  virtual void erase(const css::css_property property) { }
  virtual iterator erase(const const_iterator& pos) { return iterator(declarations.end()); }
  virtual iterator erase(const const_iterator& pos1, const iterator& pos2) { return iterator(declarations.end()); }
  virtual void write(const xhtml_stylesheet_formatter<CT>& fmtr) const { }
  virtual std::basic_string<CT> selector() const { return typed_string<CT>(""); }

  virtual ss_item_type stylesheet_item_type() const { return sit_unknown; }

private:
  // implementation
  virtual std::basic_string<CT> identifier() const { return typed_string<CT>(""); }
  virtual xhtml_stylesheet_item<CT>* clone() const { return NULL; }

protected:
  // data
  std::vector<stylesheet_declaration<CT> > declarations;


  // friends
  #if defined(_MSC_VER) && _MSC_VER < 1300
    friend class xhtml_stylesheet<CT>;
    friend bool operator == (const xhtml_stylesheet_item& lhs, const xhtml_stylesheet_item& rhs);
  #else
    template<typename T> friend class xhtml_stylesheet;
    friend bool operator ==<> (const xhtml_stylesheet_item& lhs, const xhtml_stylesheet_item& rhs);
  #endif
};



/************************************************************************/
/* xhtml_stylesheet_import                                              */
/************************************************************************/
template<typename CT = char>
class Xport::xhtml_stylesheet_import : public Xport::xhtml_stylesheet_item<CT>
{
public:
  explicit xhtml_stylesheet_import(const std::basic_string<CT>& path) : import_path(path) {}
  virtual ~xhtml_stylesheet_import() {}
  virtual ss_item_type stylesheet_item_type() const { return sit_import; }
  virtual void write(const xhtml_stylesheet_formatter<CT>& fmtr) const { fmtr.insert_import(import_path); }

private:
  // implementation
  virtual std::basic_string<CT> identifier() const {return import_path;}
  virtual xhtml_stylesheet_item<CT>* clone() const { return new xhtml_stylesheet_import<CT>(*this); }

  // data
  std::basic_string<CT> import_path;

  // friends
  friend class xhtml_stylesheet<CT>;
};

/************************************************************************/
/* xhtml_stylesheet_comment                                             */
/************************************************************************/
template<typename CT = char>
class Xport::xhtml_stylesheet_comment : public Xport::xhtml_stylesheet_item<CT> 
{
public:
  explicit xhtml_stylesheet_comment(const std::basic_string<CT>& commnt) : data(commnt) {}
  virtual ~xhtml_stylesheet_comment() {}
  virtual ss_item_type stylesheet_item_type() const { return sit_comment; }
  virtual void write(const xhtml_stylesheet_formatter<CT>& fmtr) const { fmtr.insert_comment(data); }

private:
  // implementation
  virtual std::basic_string<CT> identifier() const { return data; }
  virtual xhtml_stylesheet_item<CT>* clone() const { return new xhtml_stylesheet_comment<CT>(*this); }

  // data
  std::basic_string<CT> data;

  // friends
  friend class xhtml_stylesheet<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 | Mobile
Web03 | 2.8.140916.1 | Last Updated 4 May 2008
Article Copyright 2008 by Mitchel Haas
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid