CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DDLSAX2FileHandler Class Reference

DDLSAX2FileHandler is the SAX2 Handler for XML files found in the configuration file. More...

#include <DDLSAX2FileHandler.h>

Inheritance diagram for DDLSAX2FileHandler:
DDLSAX2Handler DDLSAX2ExpressionHandler

Public Member Functions

void characters (const XMLCh *chars, XMLSize_t length) override
 
void comment (const XMLCh *chars, XMLSize_t length) override
 
void createDDConstants () const
 creates all DDConstant from the evaluator which has been already 'filled' in the first scan of the documents More...
 
 DDLSAX2FileHandler (DDCompactView &cpv, DDLElementRegistry &)
 
void endElement (const XMLCh *uri, const XMLCh *localname, const XMLCh *qname) override
 
void init ()
 
void startElement (const XMLCh *uri, const XMLCh *localname, const XMLCh *qname, const Attributes &attrs) override
 
 ~DDLSAX2FileHandler () override
 
- Public Member Functions inherited from DDLSAX2Handler
void characters (const XMLCh *chars, XMLSize_t length) override
 
void comment (const XMLCh *chars, XMLSize_t length) override
 
 DDLSAX2Handler ()
 
virtual void dumpStats (const std::string &fname)
 
void endElement (const XMLCh *uri, const XMLCh *localname, const XMLCh *qname) override
 
void error (const SAXParseException &exception) override
 
void fatalError (const SAXParseException &exception) override
 
unsigned int getAttrCount () const
 Get the count of attributes processed so far. More...
 
unsigned int getCharacterCount () const
 Get the count of characters processed so far. More...
 
unsigned int getElementCount () const
 Get the count of elements processed so far. More...
 
bool getSawErrors () const
 Did the XML parser see any errors? More...
 
unsigned int getSpaceCount () const
 Get the count of spaces processed so far. More...
 
void ignorableWhitespace (const XMLCh *chars, XMLSize_t length) override
 
void resetDocument () override
 
virtual void setNameSpace (const std::string &nms)
 
virtual void setUserNS (bool userns)
 
void startElement (const XMLCh *uri, const XMLCh *localname, const XMLCh *qname, const Attributes &attrs) override
 
void warning (const SAXParseException &exception) override
 
 ~DDLSAX2Handler () override
 

Protected Member Functions

DDLElementRegistryregistry ()
 

Private Member Functions

virtual const std::string & parent () const
 
virtual const std::string & self () const
 

Private Attributes

DDCompactViewcpv_
 
std::vector< size_t > names_
 
std::vector< std::string > namesMap_
 
DDLElementRegistryregistry_
 

Additional Inherited Members

- Public Types inherited from DDLSAX2Handler
using Attributes = XERCES_CPP_NAMESPACE::Attributes
 
using SAXParseException = XERCES_CPP_NAMESPACE::SAXParseException
 
- Protected Attributes inherited from DDLSAX2Handler
XMLSize_t attrCount_
 
XMLSize_t characterCount_
 
XMLSize_t elementCount_
 
std::string nmspace_
 
bool sawErrors_
 
XMLSize_t spaceCount_
 
bool userNS_
 

Detailed Description

DDLSAX2FileHandler is the SAX2 Handler for XML files found in the configuration file.

Author
Michael Case

DDLSAX2FileHandler.h - description

begin: Tue Oct 23 2001

DDLSAX2FileHandler has the same structure as the DDLSAX2ConfigHandler as they both inherit from DDLSAX2Handler which inherits from Xerces C++ DefaultHandler. SAX2 is event driven. So, when the start of an element is encountered in the XML, then a call is made to the handler's startElement. The same for endElement.

The design of DDXMLElement allows for processing whichever type of Element the XML Parser encounters.

Definition at line 35 of file DDLSAX2FileHandler.h.

Constructor & Destructor Documentation

DDLSAX2FileHandler::DDLSAX2FileHandler ( DDCompactView cpv,
DDLElementRegistry reg 
)

Definition at line 13 of file DDLSAX2FileHandler.cc.

References init().

14  : cpv_(cpv), registry_{reg}
15 {
16  init();
17 }
DDLElementRegistry & registry_
DDCompactView & cpv_
DDLSAX2FileHandler::~DDLSAX2FileHandler ( )
override

Definition at line 26 of file DDLSAX2FileHandler.cc.

27 {}

Member Function Documentation

void DDLSAX2FileHandler::characters ( const XMLCh *  chars,
XMLSize_t  length 
)
override

Definition at line 97 of file DDLSAX2FileHandler.cc.

References DDLElementRegistry::getElement(), mps_fire::i, registry_, alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

99 {
100  auto myElement = registry_.getElement(self());
101  std::string inString = "";
102  for (XMLSize_t i = 0; i < length; ++i)
103  {
104  char s = chars[i];
105  inString = inString + s;
106  }
107  if (myElement->gotText())
108  myElement->appendText(inString);
109  else
110  myElement->loadText(inString);
111 }
DDLElementRegistry & registry_
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
void DDLSAX2FileHandler::comment ( const XMLCh *  chars,
XMLSize_t  length 
)
override

Definition at line 114 of file DDLSAX2FileHandler.cc.

116 {}
void DDLSAX2FileHandler::createDDConstants ( void  ) const

creates all DDConstant from the evaluator which has been already 'filled' in the first scan of the documents

Definition at line 119 of file DDLSAX2FileHandler.cc.

References DDConstant::createConstantsFromEvaluator(), DDLElementRegistry::evaluator(), registry_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by DDLParser::parse(), and DDLParser::parseOneFile().

120 {
122 }
DDLElementRegistry & registry_
ClhepEvaluator & evaluator()
static void createConstantsFromEvaluator(ClhepEvaluator &)
creates all DDConstants from the variables of the ClhepEvaluator
Definition: DDConstant.cc:39
void DDLSAX2FileHandler::endElement ( const XMLCh *  uri,
const XMLCh *  localname,
const XMLCh *  qname 
)
override

Definition at line 65 of file DDLSAX2FileHandler.cc.

References cpv_, cms::xerces::cStr(), DDLElementRegistry::getElement(), names_, DDLSAX2Handler::nmspace_, DDCurrentNamespace::ns(), parent(), registry_, AlCaHLTBitMon_QueryRunRegistry::string, and DDLSAX2Handler::userNS_.

68 {
69  std::string ts(cStr(qname).ptr());
70  const std::string& myElementName = self();
71 
72  auto myElement = registry_.getElement(myElementName);
73 
74  std::string nmspace = nmspace_;
75  // The need for processElement to have the nmspace so that it can
76  // do the necessary gymnastics made things more complicated in the
77  // effort to allow fully user-controlled namespaces. So the "magic"
78  // trick of setting nmspace to "!" is used :(... I don't like this magic trick
79  // -- Michael Case 2008-11-06
80  // OPTIMISE in the near future, like the current nmspace_ impl.
81  // just set nmspace_ to "!" from Parser based on userNS_ so
82  // userNS_ is set by parser ONCE and no if nec. here. MEC: 2009-06-22
83  if ( userNS_ ) {
84  nmspace = "!";
85  }
86 
87  DDCurrentNamespace::ns() = nmspace;
88  // tell the element it's parent name for recording/reporting purposes
89  myElement->setParent(parent());
90  myElement->setSelf(self());
91  myElement->processElement(myElementName, nmspace, cpv_);
92 
93  names_.pop_back();
94 }
virtual const std::string & parent() const
static std::string & ns()
DDLElementRegistry & registry_
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
ZStr< char > cStr(XMLCh const *str)
std::string nmspace_
std::vector< size_t > names_
DDCompactView & cpv_
void DDLSAX2FileHandler::init ( void  )

Definition at line 20 of file DDLSAX2FileHandler.cc.

References names_, and namesMap_.

Referenced by DDLSAX2FileHandler().

21 {
22  namesMap_.emplace_back("*** root ***");
23  names_.emplace_back(namesMap_.size() - 1);
24 }
std::vector< std::string > namesMap_
std::vector< size_t > names_
const std::string & DDLSAX2FileHandler::parent ( void  ) const
privatevirtual

Definition at line 125 of file DDLSAX2FileHandler.cc.

References names_, namesMap_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by Vispa.Gui.ConnectableWidget.ConnectableWidget::addMenuEntry(), Vispa.Views.LineDecayView.LineDecayContainer::applyFilter(), Vispa.Views.BoxDecayView.BoxDecayContainer::arrangeUsingRelations(), Vispa.Views.BoxDecayView.BoxDecayContainer::autolayoutAlgorithm(), Vispa.Gui.ZoomableScrollableWidgetOwner.ZoomableScrollableWidgetOwner::autosizeScrollArea(), Vispa.Views.BoxDecayView.BoxDecayContainer::autosizeScrollArea(), Vispa.Gui.PortWidget.PortWidget::connectionPoint(), Vispa.Main.StartupScreen.StartupScreen::createDescriptionWidget(), Vispa.Views.BoxDecayView.BoxDecayContainer::dataAccessor(), Vispa.Views.LineDecayView.LineDecayContainer::dataAccessor(), Vispa.Views.LineDecayView.DecayLine::dataAccessor(), Vispa.Views.LineDecayView.LineDecayContainer::delete(), Vispa.Views.LineDecayView.DecayNode::delete(), Vispa.Views.LineDecayView.DecayLine::delete(), Vispa.Gui.VispaWidget.VispaWidget::delete(), Vispa.Gui.VispaWidget.VispaWidget::dragWidget(), endElement(), Vispa.Share.ImageExporter.ImageExporter::exportImageDialog(), Vispa.Views.LineDecayView.DecayLine::extendedSize(), Vispa.Gui.VispaWidget.VispaWidget::keyPressEvent(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.ConnectableWidget.ConnectableWidget::leaveEvent(), Vispa.Gui.PortWidget.PortWidget::moduleParent(), Vispa.Gui.WidgetContainer.WidgetContainer::mouseDoubleClickEvent(), Vispa.Gui.VispaWidget.VispaWidget::mouseDoubleClickEvent(), Vispa.Gui.PortConnection.PointToPointConnection::mousePressEvent(), Vispa.Gui.VispaWidget.VispaWidget::mousePressEvent(), Vispa.Views.LineDecayView.ParticleWidget::mousePressEvent(), Vispa.Views.LineDecayView.DecayNode::move(), Vispa.Views.LineDecayView.LineDecayContainer::noDecorationsMode(), Vispa.Views.LineDecayView.LineDecayContainer::operationId(), Vispa.Views.LineDecayView.DecayLine::paint(), Vispa.Gui.VispaWidget.VispaWidget::paintEvent(), Vispa.Gui.ConnectableWidget.ConnectableWidget::positionizeMenuWidget(), Vispa.Views.LineDecayView.DecayLine::qtLineStyle(), registry(), Vispa.Views.WidgetView.WidgetView::restoreSelection(), Vispa.Views.WidgetView.WidgetView::select(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Views.LineDecayView.LineDecayContainer::sizeHint(), Vispa.Views.LineDecayView.LineDecayContainer::tabController(), Vispa.Views.BoxDecayView.BoxDecayContainer::toggleCollapsed(), Vispa.Views.LineDecayView.DecayNode::unite(), Vispa.Views.PropertyView.PropertyView::valueChanged(), Vispa.Views.BoxDecayView.BoxDecayContainer::widgetByObject(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::widgetDoubleClicked(), and Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::widgetDragged().

126 {
127  if (names_.size() > 2)
128  {
129  return namesMap_.at(names_.at(names_.size() - 2));
130  }
131  return namesMap_[0];//.at(names_.at(0));
132 }
std::vector< std::string > namesMap_
std::vector< size_t > names_
DDLElementRegistry& DDLSAX2FileHandler::registry ( )
inlineprotected

Definition at line 59 of file DDLSAX2FileHandler.h.

References parent(), registry_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by DDLSAX2ExpressionHandler::startElement().

59 { return registry_; }
DDLElementRegistry & registry_
const std::string & DDLSAX2FileHandler::self ( void  ) const
privatevirtual

Definition at line 135 of file DDLSAX2FileHandler.cc.

References names_, and namesMap_.

136 {
137  if (names_.size() > 1) {
138  return namesMap_.at(names_.at(names_.size() - 1));
139  }
140  return namesMap_[0];//.at(names_.at(0));
141 }
std::vector< std::string > namesMap_
std::vector< size_t > names_
void DDLSAX2FileHandler::startElement ( const XMLCh *  uri,
const XMLCh *  localname,
const XMLCh *  qname,
const Attributes attrs 
)
override

Definition at line 30 of file DDLSAX2FileHandler.cc.

References cpv_, cms::xerces::cStr(), DDLElementRegistry::getElement(), mps_fire::i, names_, namesMap_, DDLSAX2Handler::nmspace_, registry_, and AlCaHLTBitMon_QueryRunRegistry::string.

34 {
35  std::string myElementName(cStr(qname).ptr());
36  size_t i = 0;
37  for (; i < namesMap_.size(); ++i) {
38  if ( myElementName == namesMap_.at(i) ) {
39  names_.emplace_back(i);
40  break;
41  }
42  }
43  if (i >= namesMap_.size()) {
44  namesMap_.emplace_back(myElementName);
45  names_.emplace_back(namesMap_.size() - 1);
46  }
47 
48  auto myElement = registry_.getElement(myElementName);
49 
50  unsigned int numAtts = attrs.getLength();
51  std::vector<std::string> attrNames, attrValues;
52 
53  for (unsigned int i = 0; i < numAtts; ++i)
54  {
55  attrNames.emplace_back(std::string(cStr(attrs.getLocalName(i)).ptr()));
56  attrValues.emplace_back(std::string(cStr(attrs.getValue(i)).ptr()));
57  }
58 
59  myElement->loadAttributes(myElementName, attrNames, attrValues, nmspace_, cpv_);
60  // initialize text
61  myElement->loadText(std::string());
62 }
std::vector< std::string > namesMap_
DDLElementRegistry & registry_
std::shared_ptr< DDXMLElement > getElement(const std::string &name)
THE most important part. Getting the pointer to a given element type.
ZStr< char > cStr(XMLCh const *str)
std::string nmspace_
std::vector< size_t > names_
DDCompactView & cpv_

Member Data Documentation

DDCompactView& DDLSAX2FileHandler::cpv_
private

Definition at line 68 of file DDLSAX2FileHandler.h.

Referenced by endElement(), and startElement().

std::vector< size_t > DDLSAX2FileHandler::names_
private

Definition at line 67 of file DDLSAX2FileHandler.h.

Referenced by endElement(), init(), parent(), self(), and startElement().

std::vector< std::string > DDLSAX2FileHandler::namesMap_
private

Definition at line 66 of file DDLSAX2FileHandler.h.

Referenced by init(), parent(), self(), and startElement().

DDLElementRegistry& DDLSAX2FileHandler::registry_
private