Xport Interface: stylesheet_rule::erase
Erases zero or more declarations from the called
stylesheet_rule object.
virtual stylesheet_item::iterator stylesheet_rule::erase(1st Variety
const stylesheet_item::const_iterator& pos
);
virtual stylesheet_item::iterator stylesheet_rule::erase( 2nd Variety
const stylesheet_item::const_iterator& beg_pos
const stylesheet_item::const_iterator& end_pos
);
stylesheet_item::iterator stylesheet_rule::erase(3rd Variety
css_property property
);
Parameters
pos
A stylesheet_item iterator which points to the declaration
to be erased. Caller must insure the iterator position is valid.
beg_pos
A stylesheet_item iterator which points to the first declaration in the range to be erased. Caller must insure the iterator position is valid.
end_pos
A stylesheet_item iterator which points just past the last declaration in the range to be erased. Caller must insure the iterator position is valid.
property
A css_property
enumerator which specifies the property in
the declaration to be erased.
Returns
In the first 2 varieties, a stylesheet_item iterator is returned which points just past the erased declaration, or range of declarations. In the 3rd
variety, returns true if the declaration was found and erased, false otherwise.
Remarks
This operation is used to remove declarations from the called stylesheet_rule. The first variety accepts a single iterator which points to the
declaration to be erased. The second variety accepts an iterator range which specifies the range of declarations to be erased. The third variety
accepts a string which specifies a css property which to find in a declaration within the stylesheet rule, and erased.
Complexity
Logarithmic
Examples
1st Variety
#include "xhtml_doc.h"
#include <iostream>
int main(int argc, char* argv[])
{
using namespace Xport;
stylesheet_rule rule("h1");
rule.insert(declaration(text_align, "center"));
rule.insert(declaration(css::color, "red"));
rule.insert(declaration(margin_left, "10px"));
rule.insert(declaration(font_size, "10pt"));
stylesheet_formatter fmtr(std::cout);
rule.write(fmtr);
std::cout << "\n\n";
stylesheet_item::const_iterator it = rule.begin();
++it;
std::cout << "Erasing the 2nd declaration.\n\n";
rule.erase(it);
rule.write(fmtr);
}
2nd Variety
#include "xhtml_doc.h"
#include <iostream>
int main(int argc, char* argv[])
{
using namespace Xport;
stylesheet_rule rule("h1");
rule.insert(declaration(text_align, "center"));
rule.insert(declaration(css::color, "red"));
rule.insert(declaration(margin_left, "10px"));
rule.insert(declaration(font_size, "10pt"));
stylesheet_formatter fmtr(std::cout);
rule.write(fmtr);
std::cout << "\n\n";
stylesheet_item::const_iterator it = rule.begin();
++it;
++it;
std::cout << "Erasing the last 2 declarations.\n\n";
rule.erase(it, rule.end());
rule.write(fmtr);
}
3rd Variety
#include "xhtml_doc.h"
#include <iostream>
int main(int argc, char* argv[])
{
using namespace Xport;
stylesheet_rule rule("h1");
rule.insert(declaration(text_align, "center"));
rule.insert(declaration(css::color, "red"));
rule.insert(declaration(margin_left, "10px"));
rule.insert(declaration(font_size, "10pt"));
stylesheet_formatter fmtr(std::cout);
rule.write(fmtr);
std::cout << "\n\n";
std::cout << "Erasing the margin_left declarations.\n\n";
rule.erase(margin_left);
rule.write(fmtr);
}