Xport Interface: formatter::layout_style
Sets or retrieves the layout style for a specific tag.
tag_layout_style formatter::layout_style(1st Variety
xhtml_tag_enum tg
);
void layout_style(2st Variety
xhtml_tag_enum tg,
tag_layout_style tls
);
Parameters
tg
A xhtml_tag_enum
enumerator which specifies the tag which to set the layout style.
tls
A tag_layout_style
enumerator which specifies the layout style to apply to the specified tag.
Returns
In the first variety, returns a tag_layout_style
enumerator which reveals the layout style of the specified tag.
Remarks
This operation is used to set or to determine the tag layout style
of a specific tag.
The first variety formats and writes a document
object. The second variety formats and writes a markup
object. Where these
objects are written is determined by the output stream or file which was specified in the formatter's
constructor.
Complexity
Logarithmic
Example
1st Variety
#include "xhtml_doc.h"
#include <iostream>
int main(int argc, char* argv[])
{
using namespace Xport;
formatter fmtr(std::cout);
for (short tg = a; tg < invalid_tag; ++tg) {
std::string lstyle;
tag_layout_style ls = fmtr.layout_style(static_cast<xhtml_tag_enum>(tg));
switch (ls)
{
case inline_layout:
lstyle = "inline"; break;
case block_level_layout:
lstyle = "block level"; break;
case pre_layout:
lstyle = "pre"; break;
default:
lstyle = "other"; break;
}
element elem(static_cast<xhtml_tag_enum>(tg));
if (!elem.tag_name().empty()) {
std::cout << elem.tag_name() << ": " << lstyle << "\n";
}
}
std::cout << "\n\n";
return 0;
}
2nd Variety
#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(ul));
*it << (element(li) << "List item 1");
*it << (element(li) << "List item 2");
*it << (element(li) << "List item 3");
formatter fmtr(std::cout);
fmtr << doc;
std::cout << "\n\n";
std::cout << "Changing li tag style to newline after end tag.";
std::cout << "\n\n";
fmtr.layout_style(li, newline_after_end_tag);
fmtr << doc;
std::cout << "\n\n";
return 0;
}