Xport pcdata: comment::write
Writes the pcdata
object to a file or stream.
virtual void pcdata::write(
const formatter& fmtr
);
Parameters
fmtr
A formatter
object, which determines the output file or stream, and how the xhtml output will be formatted.
Returns
Nothing.
Remarks
This operation is used to write the pcdata
object to a file or stream.
This operation is used internally when calling document::write()
for all pcdata objects in the document. To use this operation, you must
first create a formatter
object. When creating a formatter
object, you specify the output file or stream, and any format
options for the output.
Complexity
Constant
Example
#include "xhtml_doc.h"
#include <iostream>
int main(int argc, char* argv[])
{
using namespace Xport;
document doc(root_doc);
markup::iterator it = doc.body()->insert(element(p));
*it << "This is the first paragraph in the document. ";
*it << (element(Xport::span, "spn") << "This is content within a span element.");
*it << " This is the last sentence in the paragraph.";
formatter fmtr(std::cout);
fmtr.option(max_line_length, 70);
doc.write(fmtr);
std::cout << "\n\n";
std::cout << "There are " << it->size() << "markup objects in the paragraph above.\n";
std::cout << "They will be written below.\n\n";
markup::iterator pit = it->begin();
for (; pit != it->end(); ++pit) {
if (pit->markup_type() == mt_pcdata) {
formatter pcfmtr(std::cout);
pit->write(pcfmtr);
std::cout << "\n";
}
}
std::cout << "\n\n";
return 0;
}