Xport Interface: stylesheet_formatter::stylesheet_formatter
Constructor for stylesheet_formatter
.
stylesheet_formatter::stylesheet_formatter(1st Variety
const std::string& filename
);
stylesheet_formatter::stylesheet_formatter(2nd Variety
std::ostream& out
);
Parameters
filename
A full file path/filename which specifies the file in which to write the output. Caller must insure the path exists, and the user has access rights
to the directory.
out
A reference to an ouput stream (std::ostream). Can either be a user instanciated stream, including a std::ofstream or std::ostringstream. Or, one of
the standard streams such as std::cout or std::cerr.
Remarks
The formatter
constructor creates a formatting object which is used to output the stylesheet or stylesheet content. A parameter must be
passed to the constructor specifying the output where the formatted content will be sent.
Complexity
Constant
Examples
1st Variety
#include "xhtml_doc.h"
#include <iostream>
int main(int argc, char* argv[])
{
using namespace Xport;
stylesheet ss;
ss << (stylesheet_rule("h1") << declaration(text_align, "center") << declaration(css::color, "red"));
ss << (stylesheet_rule("p") << declaration(margin_top, "10px") << declaration(padding_left, "5px"));
std::cout << "Write the stylesheet to a file.\n";
stylesheet_formatter fmtr("c:/test.css");
fmtr << ss;
std::cout << "\n\n";
}
2nd Variety
#include "xhtml_doc.h"
#include <iostream>
int main(int argc, char* argv[])
{
using namespace Xport;
stylesheet ss;
ss << (stylesheet_rule("h1") << declaration(text_align, "center") << declaration(css::color, "red"));
ss << (stylesheet_rule("p") << declaration(margin_top, "10px") << declaration(padding_left, "5px"));
std::cout << "Specify std::cout as the output.\n";
stylesheet_formatter fmtr(std::cout); fmtr << ss; std::cout << "\n\n";
}