#include <XHTMLMaker.h>
Public Types | |
typedef std::map< std::string, std::string > | AttrMap |
typedef xercesc::DOMElement | Node |
Public Member Functions | |
void | addBool (Node *parent, const bool &) |
void | addDouble (Node *parent, const double &value, const unsigned int &precision=2) |
void | addHex (Node *parent, const unsigned long &) |
void | addInt (Node *parent, const unsigned int &) |
void | addInt (Node *parent, const int &) |
void | addInt (Node *parent, const long &) |
void | addInt (Node *parent, const unsigned long &) |
void | addInt (Node *parent, const long long &) |
void | addInt (Node *parent, const unsigned long long &) |
Node * | addNode (const std::string &name, Node *parent, const AttrMap &attrs) |
Node * | addNode (const std::string &name) |
Node * | addNode (const std::string &name, const AttrMap &attrs) |
Node * | addNode (const std::string &name, Node *parent) |
void | addText (Node *parent, const std::string &) |
Node * | getHead () const |
void | out (std::ostream &dest) |
void | out (const std::string &dest) |
void | out (std::string &dest) |
void | out () |
Node * | start (const std::string &title) |
XHTMLMaker () | |
~XHTMLMaker () | |
Private Member Functions | |
void | setWriterFeatures_ () |
Private Attributes | |
xercesc::DOMDocument * | doc_ |
Node * | head_ |
bool | pageStarted_ |
xercesc::DOMDocumentType * | typ_ |
xercesc::DOMWriter * | writer_ |
Helper class to build XHTML pages
Definition at line 27 of file XHTMLMaker.h.
typedef std::map<std::string,std::string> stor::XHTMLMaker::AttrMap |
Definition at line 36 of file XHTMLMaker.h.
typedef xercesc::DOMElement stor::XHTMLMaker::Node |
Typedefs
Definition at line 35 of file XHTMLMaker.h.
XHTMLMaker::XHTMLMaker | ( | ) |
Constructor
Definition at line 37 of file XHTMLMaker.cc.
References dtNoiseDBValidation_cfg::cerr, fetchall_from_DQM_v2::release, s_id, and BeamSplash_cfg::version.
{ XMLCh* xls = xs_("ls"); DOMImplementation* imp = DOMImplementationRegistry::getDOMImplementation(xls); XMLCh* xhtml_s =xs_("html") ; XMLCh* p_id = xs_( "-//W3C//DTD XHTML 1.0 Strict//EN" ); XMLCh* s_id = xs_( "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" ); typ_ = imp->createDocumentType( xhtml_s, p_id, s_id ); XMLCh* ns_uri = xs_( "http://www.w3.org/1999/xhtml" ); doc_ = imp->createDocument( ns_uri, xhtml_s, typ_ ); if( !doc_ ) { std::cerr << "Cannot create document" << std::endl; return; } XMLCh* encoding = xs_("utf-8"); doc_->setEncoding(encoding); //doc_->setStandalone( true ); XMLCh* version = xs_("1.0"); doc_->setVersion(version); pageStarted_ = false; writer_ = ( (DOMImplementationLS*)imp )->createDOMWriter(); XMLString::release(&xls); XMLString::release(&xhtml_s); XMLString::release(&p_id); XMLString::release(&s_id); XMLString::release(&ns_uri); XMLString::release(&encoding); XMLString::release(&version); if( !writer_ ) { std::cerr << "Cannot create DOM writer" << std::endl; return; } }
XHTMLMaker::~XHTMLMaker | ( | ) |
Destructor
Definition at line 90 of file XHTMLMaker.cc.
void XHTMLMaker::addBool | ( | Node * | parent, |
const bool & | value | ||
) |
Add a boolean
Definition at line 264 of file XHTMLMaker.cc.
void XHTMLMaker::addDouble | ( | Node * | parent, |
const double & | value, | ||
const unsigned int & | precision = 2 |
||
) |
Add a double
Definition at line 254 of file XHTMLMaker.cc.
References relativeConstraints::value.
Referenced by stor::SMWebPageHelper::addDOMforRunMonitor(), stor::SMWebPageHelper::addDOMforSummaryInformation(), stor::SMWebPageHelper::addFilterUnitList(), stor::SMWebPageHelper::addOutputModuleStatistics(), stor::SMWebPageHelper::addResourceBrokerDetails(), stor::SMWebPageHelper::addResourceBrokerList(), stor::SMWebPageHelper::addRowForBandwidth(), smproxy::SMPSWebPageHelper::addRowForEventServer(), smproxy::SMPSWebPageHelper::addRowForEventType(), stor::SMWebPageHelper::addRowForLatency(), stor::SMWebPageHelper::addRowForMaxBandwidth(), stor::SMWebPageHelper::addRowForMinBandwidth(), stor::SMWebPageHelper::addRowForRate(), stor::SMWebPageHelper::addRowForThroughputStatistics(), stor::SMWebPageHelper::addRowForTotalVolume(), stor::SMWebPageHelper::addRowsForThroughputUsage(), smproxy::SMPSWebPageHelper::addSummaryRowForEventServer(), smproxy::SMPSWebPageHelper::addSummaryRowForThroughput(), and stor::SMWebPageHelper::listStreamRecordsStats().
void XHTMLMaker::addHex | ( | Node * | parent, |
const unsigned long & | value | ||
) |
Add an unsigned long in hex format
Definition at line 244 of file XHTMLMaker.cc.
References relativeConstraints::value.
Referenced by stor::SMWebPageHelper::addDOMforFiles().
void XHTMLMaker::addInt | ( | Node * | parent, |
const unsigned int & | value | ||
) |
Add an unsigned int
Definition at line 194 of file XHTMLMaker.cc.
References relativeConstraints::value.
void XHTMLMaker::addInt | ( | Node * | parent, |
const long & | value | ||
) |
void XHTMLMaker::addInt | ( | Node * | parent, |
const unsigned long & | value | ||
) |
Add an unsigned long
Definition at line 214 of file XHTMLMaker.cc.
References relativeConstraints::value.
void XHTMLMaker::addInt | ( | Node * | parent, |
const unsigned long long & | value | ||
) |
Add an unsigned long long
Definition at line 234 of file XHTMLMaker.cc.
References relativeConstraints::value.
void XHTMLMaker::addInt | ( | Node * | parent, |
const int & | value | ||
) |
Add an int
Definition at line 184 of file XHTMLMaker.cc.
References relativeConstraints::value.
Referenced by smproxy::SMPSWebPageHelper::addDOMforConnectionInfo(), stor::SMWebPageHelper::addDOMforFiles(), stor::SMWebPageHelper::addDOMforRunMonitor(), stor::SMWebPageHelper::addFilterUnitList(), stor::SMWebPageHelper::addOutputModuleStatistics(), stor::SMWebPageHelper::addOutputModuleSummary(), stor::SMWebPageHelper::addResourceBrokerDetails(), stor::SMWebPageHelper::addResourceBrokerList(), stor::SMWebPageHelper::addRowForFramesReceived(), stor::SMWebPageHelper::addRowsForSataBeast(), stor::SMWebPageHelper::addRowsForWorkers(), and stor::SMWebPageHelper::listStreamRecordsStats().
void XHTMLMaker::addInt | ( | Node * | parent, |
const long long & | value | ||
) |
Add a long long
Definition at line 224 of file XHTMLMaker.cc.
References relativeConstraints::value.
XHTMLMaker::Node * XHTMLMaker::addNode | ( | const std::string & | name, |
XHTMLMaker::Node * | parent, | ||
const AttrMap & | attrs | ||
) |
Add child
Definition at line 146 of file XHTMLMaker.cc.
References i, and fetchall_from_DQM_v2::release.
Referenced by stor::SMWebPageHelper::addDOMforConfigString(), smproxy::SMPSWebPageHelper::addDOMforConnectionInfo(), smproxy::SMPSWebPageHelper::addDOMforEventServers(), stor::SMWebPageHelper::addDOMforFiles(), stor::SMWebPageHelper::addDOMforFragmentMonitor(), smproxy::SMPSWebPageHelper::addDOMforHyperLinks(), stor::SMWebPageHelper::addDOMforHyperLinks(), stor::SMWebPageHelper::addDOMforResourceUsage(), stor::SMWebPageHelper::addDOMforRunMonitor(), smproxy::SMPSWebPageHelper::addDOMforSMhost(), stor::SMWebPageHelper::addDOMforStoredData(), stor::SMWebPageHelper::addDOMforSummaryInformation(), smproxy::SMPSWebPageHelper::addDOMforThroughputPerEventType(), stor::SMWebPageHelper::addDOMforThroughputStatistics(), stor::SMWebPageHelper::addFilterUnitList(), stor::SMWebPageHelper::addFragmentStats(), addNode(), stor::SMWebPageHelper::addOutputModuleStatistics(), stor::SMWebPageHelper::addOutputModuleSummary(), stor::SMWebPageHelper::addResourceBrokerDetails(), stor::SMWebPageHelper::addResourceBrokerList(), stor::SMWebPageHelper::addRowForBandwidth(), smproxy::SMPSWebPageHelper::addRowForEventServer(), smproxy::SMPSWebPageHelper::addRowForEventType(), stor::SMWebPageHelper::addRowForFramesReceived(), stor::SMWebPageHelper::addRowForLatency(), stor::SMWebPageHelper::addRowForMaxBandwidth(), stor::SMWebPageHelper::addRowForMinBandwidth(), stor::SMWebPageHelper::addRowForRate(), stor::SMWebPageHelper::addRowForThroughputStatistics(), stor::SMWebPageHelper::addRowForTotalVolume(), stor::SMWebPageHelper::addRowsForSataBeast(), stor::SMWebPageHelper::addRowsForThroughputUsage(), stor::SMWebPageHelper::addRowsForWorkers(), smproxy::SMPSWebPageHelper::addSummaryRowForEventServer(), smproxy::SMPSWebPageHelper::addSummaryRowForThroughput(), stor::SMWebPageHelper::addTableForDiskUsages(), stor::SMWebPageHelper::addTableForResourceUsages(), smproxy::SMPSWebPageHelper::dataRetrieverWebPage(), smproxy::SMPSWebPageHelper::defaultWebPage(), stor::SMWebPageHelper::listStreamRecordsStats(), stor::SMWebPageHelper::resourceBrokerOverview(), and stor::SMWebPageHelper::storedDataWebPage().
{ XMLCh* xname = xs_(name); Node* el = doc_->createElement(xname); XMLString::release(&xname); parent->appendChild( el ); for( AttrMap::const_iterator i = attrs.begin(); i != attrs.end(); ++i ) { XMLCh* xfirst = xs_(i->first); XMLCh* xsecond = xs_(i->second); el->setAttribute(xfirst, xsecond); XMLString::release(&xfirst); XMLString::release(&xsecond); } return el; }
Add child without attributes
Definition at line 79 of file XHTMLMaker.h.
References addNode(), and relativeConstraints::empty.
Node* stor::XHTMLMaker::addNode | ( | const std::string & | name | ) | [inline] |
void XHTMLMaker::addText | ( | Node * | parent, |
const std::string & | data | ||
) |
Add text
Definition at line 173 of file XHTMLMaker.cc.
References fetchall_from_DQM_v2::release.
Referenced by stor::SMWebPageHelper::addDOMforConfigString(), smproxy::SMPSWebPageHelper::addDOMforConnectionInfo(), smproxy::SMPSWebPageHelper::addDOMforEventServers(), stor::SMWebPageHelper::addDOMforFiles(), stor::SMWebPageHelper::addDOMforFragmentMonitor(), smproxy::SMPSWebPageHelper::addDOMforHyperLinks(), stor::SMWebPageHelper::addDOMforHyperLinks(), stor::SMWebPageHelper::addDOMforRunMonitor(), smproxy::SMPSWebPageHelper::addDOMforSMhost(), stor::SMWebPageHelper::addDOMforStoredData(), stor::SMWebPageHelper::addDOMforSummaryInformation(), smproxy::SMPSWebPageHelper::addDOMforThroughputPerEventType(), stor::SMWebPageHelper::addDOMforThroughputStatistics(), stor::SMWebPageHelper::addFilterUnitList(), stor::SMWebPageHelper::addFragmentStats(), stor::SMWebPageHelper::addOutputModuleStatistics(), stor::SMWebPageHelper::addOutputModuleSummary(), stor::SMWebPageHelper::addResourceBrokerDetails(), stor::SMWebPageHelper::addResourceBrokerList(), stor::SMWebPageHelper::addRowForBandwidth(), smproxy::SMPSWebPageHelper::addRowForEventServer(), smproxy::SMPSWebPageHelper::addRowForEventType(), stor::SMWebPageHelper::addRowForFramesReceived(), stor::SMWebPageHelper::addRowForLatency(), stor::SMWebPageHelper::addRowForMaxBandwidth(), stor::SMWebPageHelper::addRowForMinBandwidth(), stor::SMWebPageHelper::addRowForRate(), stor::SMWebPageHelper::addRowForThroughputStatistics(), stor::SMWebPageHelper::addRowForTotalVolume(), stor::SMWebPageHelper::addRowsForSataBeast(), stor::SMWebPageHelper::addRowsForThroughputUsage(), stor::SMWebPageHelper::addRowsForWorkers(), smproxy::SMPSWebPageHelper::addSummaryRowForThroughput(), stor::SMWebPageHelper::addTableForDiskUsages(), stor::SMWebPageHelper::addTableForResourceUsages(), and stor::SMWebPageHelper::listStreamRecordsStats().
{ XMLCh* xdata = xs_(data); DOMText* txt = doc_->createTextNode(xdata); XMLString::release(&xdata); parent->appendChild( txt ); }
Node* stor::XHTMLMaker::getHead | ( | ) | const [inline] |
Useful for css and javascript
Definition at line 56 of file XHTMLMaker.h.
References head_.
{ return head_; }
void XHTMLMaker::out | ( | std::string & | dest | ) |
void XHTMLMaker::out | ( | std::ostream & | dest | ) |
Dump the page into an output stream
Definition at line 338 of file XHTMLMaker.cc.
{ setWriterFeatures_(); MemBufFormatTarget* ftar = new MemBufFormatTarget(); writer_->writeNode( ftar, *doc_ ); dest << ftar->getRawBuffer(); delete ftar; }
void XHTMLMaker::out | ( | const std::string & | dest | ) |
Dump the page to a local file
Definition at line 315 of file XHTMLMaker.cc.
References fetchall_from_DQM_v2::release.
{ setWriterFeatures_(); XMLCh* xfilename = xs_(filename); XMLFormatTarget* ftar = new LocalFileFormatTarget(xfilename); writer_->writeNode( ftar, *doc_ ); XMLString::release(&xfilename); delete ftar; }
void XHTMLMaker::out | ( | ) |
Dump the page to stdout
Definition at line 303 of file XHTMLMaker.cc.
Referenced by smproxy::SMPSWebPageHelper::dataRetrieverWebPage(), stor::SMWebPageHelper::defaultWebPage(), smproxy::SMPSWebPageHelper::defaultWebPage(), smproxy::SMPSWebPageHelper::dqmEventStatisticsWebPage(), stor::SMWebPageHelper::dqmEventWebPage(), stor::SMWebPageHelper::filesWebPage(), stor::SMWebPageHelper::inputWebPage(), stor::SMWebPageHelper::resourceBrokerDetail(), stor::SMWebPageHelper::resourceBrokerOverview(), stor::SMWebPageHelper::storedDataWebPage(), and stor::SMWebPageHelper::throughputWebPage().
{ setWriterFeatures_(); XMLFormatTarget* ftar = new StdOutFormatTarget(); fflush( stdout ); writer_->writeNode( ftar, *doc_ ); delete ftar; }
void XHTMLMaker::setWriterFeatures_ | ( | ) | [private] |
Set DOMWriter features
Definition at line 273 of file XHTMLMaker.cc.
{ //writer_->setNewLine( (const XMLCh*)( L"\n" ) ); if( writer_->canSetFeature( XMLUni::fgDOMWRTSplitCdataSections, true ) ) { writer_->setFeature( XMLUni::fgDOMWRTSplitCdataSections, true ); } if( writer_->canSetFeature( XMLUni::fgDOMWRTDiscardDefaultContent, true ) ) { writer_->setFeature( XMLUni::fgDOMWRTDiscardDefaultContent, true ); } if( writer_->canSetFeature( XMLUni::fgDOMWRTFormatPrettyPrint, true ) ) { writer_->setFeature( XMLUni::fgDOMWRTFormatPrettyPrint, true ); } if( writer_->canSetFeature( XMLUni::fgDOMWRTBOM, true ) ) { writer_->setFeature( XMLUni::fgDOMWRTBOM, true ); } }
XHTMLMaker::Node * XHTMLMaker::start | ( | const std::string & | title | ) |
Initialize page and return body element
Definition at line 101 of file XHTMLMaker.cc.
References dtNoiseDBValidation_cfg::cerr, h, and fetchall_from_DQM_v2::release.
{ if( pageStarted_ ) { std::cerr << "Page already started" << std::endl; return (Node*)0; } pageStarted_ = true; // Root element: Node* el_xhtml = doc_->getDocumentElement(); // Head: XMLCh* h = xs_("head"); head_ = doc_->createElement(h); XMLString::release(&h); el_xhtml->appendChild( head_ ); // Title: XMLCh* xtitle = xs_("title"); Node* el_title = doc_->createElement(xtitle); XMLString::release(&xtitle); head_->appendChild( el_title ); xtitle = xs_(title); DOMText* txt_title = doc_->createTextNode(xtitle); XMLString::release(&xtitle); el_title->appendChild( txt_title ); // Body: XMLCh* xbody = xs_("body"); Node* el_body = doc_->createElement(xbody); XMLString::release(&xbody); el_xhtml->appendChild( el_body ); return el_body; }
xercesc::DOMDocument* stor::XHTMLMaker::doc_ [private] |
Definition at line 166 of file XHTMLMaker.h.
Node* stor::XHTMLMaker::head_ [private] |
Definition at line 170 of file XHTMLMaker.h.
Referenced by getHead().
bool stor::XHTMLMaker::pageStarted_ [private] |
Definition at line 172 of file XHTMLMaker.h.
xercesc::DOMDocumentType* stor::XHTMLMaker::typ_ [private] |
Definition at line 168 of file XHTMLMaker.h.
xercesc::DOMWriter* stor::XHTMLMaker::writer_ [private] |
Definition at line 167 of file XHTMLMaker.h.