|
/************************************************************************
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> class xhtml_stylesheet;
template<typename T> class xhtml_stylesheet_rule;
template<typename CT>
struct selector_comp
{
explicit selector_comp(const std::basic_string<CT>& s) : sel(s) {}
bool operator() (const xhtml_stylesheet_item<CT>* pVec_item) const { return pVec_item->selector() == sel; }
private:
const std::basic_string<CT>& sel;
};
}
template<typename CT = char>
class Xport::xhtml_stylesheet_rule : public Xport::xhtml_stylesheet_item<CT>
{
// 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 xhtml_stylesheet_item<CT>::iterator stylesheet_item_iterator;
public:
// public interface
virtual typename xhtml_stylesheet_item<CT>::iterator insert(const stylesheet_declaration<CT>& decl) { return stylesheet_item_iterator(xhtml_stylesheet_item<CT>::declarations.insert(xhtml_stylesheet_item<CT>::declarations.end(), decl)); }
virtual typename xhtml_stylesheet_item<CT>::iterator insert(typename xhtml_stylesheet_item<CT>::const_iterator pos, const stylesheet_declaration<CT>& decl);
virtual void push_back(const stylesheet_declaration<CT>& decl) { xhtml_stylesheet_item<CT>::declarations.push_back(decl); }
virtual void erase(const css::css_property property);
virtual typename xhtml_stylesheet_item<CT>::iterator erase(const typename xhtml_stylesheet_item<CT>::const_iterator& pos);
virtual typename xhtml_stylesheet_item<CT>::iterator erase(const typename xhtml_stylesheet_item<CT>::const_iterator& pos1, const typename xhtml_stylesheet_item<CT>::const_iterator& pos2);
virtual ss_item_type stylesheet_item_type() const { return sit_rule; }
virtual void write(const xhtml_stylesheet_formatter<CT>& fmtr) const { fmtr.insert_rule(rule_selector, xhtml_stylesheet_item<CT>::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 xhtml_stylesheet_item<CT>* clone() const { return new xhtml_stylesheet_rule<CT>(*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>;
friend bool operator == (const xhtml_stylesheet_rule<CT>& lhs, const xhtml_stylesheet_rule<CT>& rhs );
#else
template<typename T> 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.