CMS 3D CMS Logo

List of all members | Public 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 *const chars, const XMLSize_t length) override
 
void comment (const XMLCh *const chars, const XMLSize_t length) override
 
 DDLSAX2FileHandler (DDCompactView &cpv)
 
void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname) override
 
void init ()
 
void startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs) override
 
 ~DDLSAX2FileHandler ()
 
- Public Member Functions inherited from DDLSAX2Handler
 DDLSAX2Handler ()
 
virtual void dumpStats (const std::string &fname)
 
virtual void error (const SAXParseException &exception) override
 
virtual 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...
 
virtual void ignorableWhitespace (const XMLCh *const chars, const XMLSize_t length) override
 
virtual void resetDocument () override
 
virtual void setNameSpace (const std::string &nms)
 
virtual void setUserNS (bool userns)
 
virtual void warning (const SAXParseException &exception) override
 
 ~DDLSAX2Handler ()
 

Private Member Functions

void createDDConstants () const
 creates all DDConstant from the evaluator which has been already 'filled' in the first scan of the documents More...
 
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_
 

Additional Inherited Members

- Public Types inherited from DDLSAX2Handler
typedef XERCES_CPP_NAMESPACE::Attributes Attributes
 
typedef XERCES_CPP_NAMESPACE::SAXParseException 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 34 of file DDLSAX2FileHandler.h.

Constructor & Destructor Documentation

DDLSAX2FileHandler::DDLSAX2FileHandler ( DDCompactView cpv)

Definition at line 13 of file DDLSAX2FileHandler.cc.

References init().

14  : cpv_(cpv)
15 {
16  init();
17 }
DDCompactView & cpv_
DDLSAX2FileHandler::~DDLSAX2FileHandler ( void  )

Definition at line 27 of file DDLSAX2FileHandler.cc.

28 {}

Member Function Documentation

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

Reimplemented from DDLSAX2Handler.

Definition at line 98 of file DDLSAX2FileHandler.cc.

References DDXMLElement::appendText(), DDXMLElement::gotText(), i, DDI::Singleton< I >::instance(), DDXMLElement::loadText(), alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

100 {
101  DDXMLElement* myElement = DDLGlobalRegistry::instance().getElement(self());
102  std::string inString = "";
103  for (XMLSize_t i = 0; i < length; ++i)
104  {
105  char s = chars[i];
106  inString = inString + s;
107  }
108  if (myElement->gotText())
109  myElement->appendText(inString);
110  else
111  myElement->loadText(inString);
112 }
int i
Definition: DBlmapReader.cc:9
void appendText(const std::string &inText)
append to the current (i.e. most recently added)
void loadText(const std::string &inText)
Used to load both text and XML comments into this object.
static value_type & instance()
virtual bool gotText(void) const
gotText()? kind of like gotMilk? Yes = text has already been encountered.
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:48
void DDLSAX2FileHandler::comment ( const XMLCh *const  chars,
const XMLSize_t  length 
)
overridevirtual

Reimplemented from DDLSAX2Handler.

Definition at line 115 of file DDLSAX2FileHandler.cc.

117 {}
void DDLSAX2FileHandler::createDDConstants ( void  ) const
private

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

Definition at line 120 of file DDLSAX2FileHandler.cc.

References DDConstant::createConstantsFromEvaluator(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by init().

121 {
123 }
static void createConstantsFromEvaluator()
creates all DDConstants from the variables of the ClhepEvaluator
Definition: DDConstant.cc:38
void DDLSAX2FileHandler::endElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname 
)
overridevirtual

Reimplemented from DDLSAX2Handler.

Definition at line 66 of file DDLSAX2FileHandler.cc.

References cpv_, cms::xerces::cStr(), DDI::Singleton< I >::instance(), names_, DDLSAX2Handler::nmspace_, DDCurrentNamespace::ns(), parent(), DDXMLElement::processElement(), DDXMLElement::setParent(), DDXMLElement::setSelf(), AlCaHLTBitMon_QueryRunRegistry::string, and DDLSAX2Handler::userNS_.

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

Definition at line 20 of file DDLSAX2FileHandler.cc.

References createDDConstants(), names_, and namesMap_.

Referenced by DDLSAX2FileHandler().

21 {
23  namesMap_.push_back("*** root ***");
24  names_.push_back(namesMap_.size() - 1);
25 }
std::vector< std::string > namesMap_
std::vector< size_t > names_
void createDDConstants() const
creates all DDConstant from the evaluator which has been already &#39;filled&#39; in the first scan of the do...
const std::string & DDLSAX2FileHandler::parent ( void  ) const
privatevirtual

Definition at line 126 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(), 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().

127 {
128  if (names_.size() > 2)
129  {
130  return namesMap_.at(names_.at(names_.size() - 2));
131  }
132  return namesMap_[0];//.at(names_.at(0));
133 }
std::vector< std::string > namesMap_
std::vector< size_t > names_
const std::string & DDLSAX2FileHandler::self ( void  ) const
privatevirtual

Definition at line 136 of file DDLSAX2FileHandler.cc.

References names_, and namesMap_.

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

Reimplemented from DDLSAX2Handler.

Definition at line 31 of file DDLSAX2FileHandler.cc.

References cpv_, cms::xerces::cStr(), i, DDI::Singleton< I >::instance(), DDXMLElement::loadAttributes(), DDXMLElement::loadText(), names_, namesMap_, DDLSAX2Handler::nmspace_, and AlCaHLTBitMon_QueryRunRegistry::string.

35 {
36  std::string myElementName(cStr(qname).ptr());
37  size_t i = 0;
38  for (; i < namesMap_.size(); ++i) {
39  if ( myElementName == namesMap_.at(i) ) {
40  names_.push_back(i);
41  break;
42  }
43  }
44  if (i >= namesMap_.size()) {
45  namesMap_.push_back(myElementName);
46  names_.push_back(namesMap_.size() - 1);
47  }
48 
49  DDXMLElement* myElement = DDLGlobalRegistry::instance().getElement(myElementName);
50 
51  unsigned int numAtts = attrs.getLength();
52  std::vector<std::string> attrNames, attrValues;
53 
54  for (unsigned int i = 0; i < numAtts; ++i)
55  {
56  attrNames.push_back(std::string(cStr(attrs.getLocalName(i)).ptr()));
57  attrValues.push_back(std::string(cStr(attrs.getValue(i)).ptr()));
58  }
59 
60  myElement->loadAttributes(myElementName, attrNames, attrValues, nmspace_, cpv_);
61  // initialize text
62  myElement->loadText(std::string());
63 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > namesMap_
void loadText(const std::string &inText)
Used to load both text and XML comments into this object.
static value_type & instance()
void loadAttributes(const std::string &elemName, const std::vector< std::string > &names, const std::vector< std::string > &values, const std::string &nmspace, DDCompactView &cpv)
Load the element attributes.
Definition: DDXMLElement.cc:36
ZStr< char > cStr(XMLCh const *str)
std::string nmspace_
std::vector< size_t > names_
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:48
DDCompactView & cpv_

Member Data Documentation

DDCompactView& DDLSAX2FileHandler::cpv_
private

Definition at line 64 of file DDLSAX2FileHandler.h.

Referenced by endElement(), and startElement().

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

Definition at line 63 of file DDLSAX2FileHandler.h.

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

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

Definition at line 62 of file DDLSAX2FileHandler.h.

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