A document_formation emumerator, which determines if the document will have root
elements present after being cleared. This optional argument can be one of two values, the default value of document_formation(0), and root_doc.
If the document object is to be cleared of all elements, no argument should be supplied. Supply the root_doc argument to have the document
contain the root elements after being cleared, thus making the document a root
document.
Returns
Nothing.
Remarks
Use this operation to clear the contents of the document. When no argument is present, this operation will leave the document empty of all markup
objects. When the root_doc argument is present, this operation will clear the contents, then insert the root elements.
Complexity
Linear
Example
#include "xhtml_doc.h"
#include "xport_brochure.h"
#include <iostream>
#include <algorithm>
// create a unary predicate which always returns true
bool ret_true(Xport::markup&) {return true; }
int main(int argc, char* argv[])
{
using namespace Xport;
// create an xhtml strict root doc
document doc(root_doc);
stylesheet ss;
// create xport brochure
xport_brochure brochure;
brochure.create(doc, ss);
// use the std::count algorithm with a descendant iterator to count the markup objects in the document
markup::size_type markup_count = std::count_if(doc.descendant_begin(), doc.descendant_end(), ret_true);
std::cout << "Xport Brochure contains " << markup_count << " markup objects.\n";
// clear document of all elements but root elements
std::cout << "Clearing document, leaving root elements\n";
doc.clear(root_doc);
// count again
markup_count = std::count_if(doc.descendant_begin(), doc.descendant_end(), ret_true);
std::cout << "Xport Brochure now contains " << markup_count << " markup objects.\n";
return 0;
}
Datasoft Solutions is proud to present their landmark product, Work Time Studio. Utilizing the tree container library, Work Time Studio provides
unparalleled features in personal time, project and task management
software. If you're looking for a way to increase your productivity,
visit Work Time Studio's product website, and start being more productive
today.