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_item.h"
#include "stylesheet_declaration.h"
#include "common.h"
#include "stylesheet_formatter.h"
#include <map>
#include <vector>
#include <string>
#include <ostream>

namespace Xport
{
  template<typename T, typename U> class xhtml_stylesheet;
  template<typename T, typename U> class xhtml_stylesheet_rule;

  template<typename CT, typename SBT>
  struct selector_comp
  {
    explicit selector_comp(const std::basic_string<CT>& s) : sel(s) {}
    bool operator() (const SBT* pVec_item) const { return pVec_item->selector() == sel; }

  private:
    const std::basic_string<CT>& sel;
  };

}

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

template<typename CT, typename SBT>
class Xport::xhtml_stylesheet_rule : public SBT
{
  // constructors/destructor
public:
  explicit xhtml_stylesheet_rule(const std::basic_string<CT>& _selector) : rule_selector(_selector), indent_lvl(3) {}
  virtual ~xhtml_stylesheet_rule() {}
private:
  xhtml_stylesheet_rule()  {}

  // typedefs
  typedef typename SBT::iterator        base_iterator_type;         // vc6 compatibility
  typedef typename SBT::const_iterator  const_base_iterator_type;   // vc6 compatibility

public:
  // public interface
  virtual base_iterator_type insert(const stylesheet_declaration<CT>& decl) { return base_iterator_type(SBT::declarations.insert(SBT::declarations.end(), decl)); }
  virtual base_iterator_type insert(const_base_iterator_type pos, const stylesheet_declaration<CT>& decl);
  virtual void push_back(const stylesheet_declaration<CT>& decl) { SBT::declarations.push_back(decl); }

  virtual void erase(const css::css_property property);
  virtual base_iterator_type erase(const const_base_iterator_type& pos);
  virtual base_iterator_type erase(const const_base_iterator_type& pos1, const const_base_iterator_type& pos2);
  virtual ss_item_type stylesheet_item_type() const { return sit_rule; }
  virtual void write(const xhtml_stylesheet_formatter<CT, SBT>& fmtr) const { fmtr.insert_rule(rule_selector, SBT::declarations); }
  virtual std::basic_string<CT> selector() const { return rule_selector; }

private:
  // private interface
  virtual std::basic_string<CT> identifier() const { return rule_selector; }
  virtual SBT* clone() const { return new xhtml_stylesheet_rule<CT, SBT>(*this); }
  

  // data
  std::basic_string<CT> rule_selector;
  mutable short indent_lvl;
    
  // friends
  #if defined(_MSC_VER) && _MSC_VER < 1300
    friend class xhtml_stylesheet<CT, SBT>;
    friend bool operator == (const xhtml_stylesheet_rule<CT, SBT>& lhs, const xhtml_stylesheet_rule<CT, SBT>& rhs );
  #else
    template<typename T, typename U> friend class xhtml_stylesheet;
  #endif
};

#include "stylesheet_rule.inl"


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
Web01 | 2.8.141015.1 | Last Updated 4 May 2008
Article Copyright 2008 by Mitchel Haas
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid