CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected 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 unsigned int length)
 
void comment (const XMLCh *const chars, const unsigned int length)
 
 DDLSAX2FileHandler (DDCompactView &cpv)
 
void dumpElementTypeCounter ()
 This dumps some statistics on elements encountered in the file. More...
 
void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
 
void init ()
 
virtual const std::string & parent () const
 
virtual const std::string & self () const
 
void startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
 
 ~DDLSAX2FileHandler ()
 
- Public Member Functions inherited from DDLSAX2Handler
 DDLSAX2Handler ()
 
virtual void dumpStats (const std::string &fname)
 
virtual void error (const SAXParseException &exception)
 
virtual void fatalError (const SAXParseException &exception)
 
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 unsigned int length)
 
virtual void resetDocument ()
 
virtual void setNameSpace (const std::string &nms)
 
virtual void setUserNS (bool userns)
 
virtual void warning (const SAXParseException &exception)
 
 ~DDLSAX2Handler ()
 

Protected Member Functions

void createDDConstants () const
 creates all DDConstant from the evaluator which has been already 'filled' in the first scan of the documents More...
 

Protected Attributes

DDCompactViewcpv_
 
std::map< std::string, int > elementTypeCounter_
 
std::vector< size_t > names_
 
std::vector< std::string > namesMap_
 
DDLElementRegistry xmlelems_
 
- Protected Attributes inherited from DDLSAX2Handler
unsigned int attrCount_
 
unsigned int characterCount_
 
unsigned int elementCount_
 
std::string nmspace_
 
bool sawErrors_
 
unsigned int spaceCount_
 
bool userNS_
 

Additional Inherited Members

- Public Types inherited from DDLSAX2Handler
typedef
XERCES_CPP_NAMESPACE::Attributes 
Attributes
 
typedef
XERCES_CPP_NAMESPACE::SAXParseException 
SAXParseException
 

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 email: case@.nosp@m.ucdh.nosp@m.ep.uc.nosp@m.davi.nosp@m.s.edu

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 40 of file DDLSAX2FileHandler.h.

Constructor & Destructor Documentation

DDLSAX2FileHandler::DDLSAX2FileHandler ( DDCompactView cpv)

Definition at line 26 of file DDLSAX2FileHandler.cc.

References init().

27  : cpv_(cpv),
28  xmlelems_()
29 {
30  init();
31 }
DDLElementRegistry xmlelems_
DDCompactView & cpv_
DDLSAX2FileHandler::~DDLSAX2FileHandler ( void  )

Definition at line 41 of file DDLSAX2FileHandler.cc.

42 {}

Member Function Documentation

void DDLSAX2FileHandler::characters ( const XMLCh *const  chars,
const unsigned int  length 
)
virtual

Reimplemented from DDLSAX2Handler.

Definition at line 132 of file DDLSAX2FileHandler.cc.

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

134 {
135  DCOUT_V('P', "DDLSAX2FileHandler::characters started");
136  // std::cout << "character handler started" << std::endl;
137  //DDXMLElement* myElement = NULL;
138  // final way
139  // myElement = xmlelems_.getElement(namesMap_[names_.back()]);
140  //temporary way:
141  // const std::string& myElementName = namesMap_[names_.back()];
142  DDXMLElement* myElement = DDLGlobalRegistry::instance().getElement(self());//myElementName); //namesMap_[names_.back()]);
143  std::string inString = "";
144  for (unsigned int i = 0; i < length; ++i)
145  {
146  char s = chars[i];
147  inString = inString + s;
148  }
149  if (myElement->gotText())
150  myElement->appendText(inString);
151  else
152  myElement->loadText(inString);
153 
154  DCOUT_V('P', "DDLSAX2FileHandler::characters completed");
155 }
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.
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:58
void DDLSAX2FileHandler::comment ( const XMLCh *const  chars,
const unsigned int  length 
)
virtual

Reimplemented from DDLSAX2Handler.

Definition at line 158 of file DDLSAX2FileHandler.cc.

160 {
161  // ignore, discard, overkill since base class also has this...
162 }
void DDLSAX2FileHandler::createDDConstants ( void  ) const
protected

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

Definition at line 169 of file DDLSAX2FileHandler.cc.

References DDConstant::createConstantsFromEvaluator().

Referenced by init().

170 {
172 }
static void createConstantsFromEvaluator()
creates all DDConstants from the variables of the ClhepEvaluator
Definition: DDConstant.cc:34
void DDLSAX2FileHandler::dumpElementTypeCounter ( void  )

This dumps some statistics on elements encountered in the file.

Definition at line 165 of file DDLSAX2FileHandler.cc.

Referenced by DDLParser::parse().

166 {}
void DDLSAX2FileHandler::endElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname 
)
virtual

Reimplemented from DDLSAX2Handler.

Definition at line 94 of file DDLSAX2FileHandler.cc.

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

97 {
98  std::string ts(StrX(qname).localForm());
99  const std::string& myElementName = self();
100  DCOUT_V('P', "DDLSAX2FileHandler::endElement started");
101  DCOUT_V('P', " " + myElementName);
102  //final way
103  // DDXMLElement* myElement = xmlelems_.getElement(myElementName); //myRegistry_->getElement(myElementName);
104  //temporary way:
105  DDXMLElement* myElement = DDLGlobalRegistry::instance().getElement(myElementName);
106 
107  // DDLParser* beingParsed = DDLParser::instance();
108  // std::string nmspace = getnmspace(extractFileName( beingParsed->getCurrFileName()));
109  std::string nmspace = nmspace_;
110  // The need for processElement to have the nmspace so that it can
111  // do the necessary gymnastics made things more complicated in the
112  // effort to allow fully user-controlled namespaces. So the "magic"
113  // trick of setting nmspace to "!" is used :(... I don't like this magic trick
114  // -- Michael Case 2008-11-06
115  // OPTIMISE in the near future, like the current nmspace_ impl.
116  // just set nmspace_ to "!" from Parser based on userNS_ so
117  // userNS_ is set by parser ONCE and no if nec. here. MEC: 2009-06-22
118  if ( userNS_ ) {
119  nmspace = "!";
120  }
121  // std::cout << "namespace " << nmspace_ << std::endl;
122  DDCurrentNamespace::ns() = nmspace;
123  // tell the element it's parent name for recording/reporting purposes
124  myElement->setParent(parent());
125  myElement->setSelf(self());
126  myElement->processElement(myElementName, nmspace, cpv_);
127  DCOUT_V('P', "DDLSAX2FileHandler::endElement completed");
128  names_.pop_back();
129 }
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()
std::string nmspace_
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
std::vector< size_t > names_
def qname
Definition: asciidump.py:315
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:58
DDCompactView & cpv_
Definition: StrX.h:32
void DDLSAX2FileHandler::init ( void  )

Definition at line 34 of file DDLSAX2FileHandler.cc.

References createDDConstants(), names_, and namesMap_.

Referenced by DDLSAX2FileHandler().

35 {
37  namesMap_.push_back("*** root ***");
38  names_.push_back(namesMap_.size() - 1);
39 }
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
virtual

Definition at line 175 of file DDLSAX2FileHandler.cc.

References names_, and namesMap_.

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().

176 {
177  if (names_.size() > 2)
178  {
179  return namesMap_.at(names_.at(names_.size() - 2));
180  }
181  return namesMap_[0];//.at(names_.at(0));
182 }
std::vector< std::string > namesMap_
std::vector< size_t > names_
const std::string & DDLSAX2FileHandler::self ( void  ) const
virtual

Definition at line 185 of file DDLSAX2FileHandler.cc.

References names_, and namesMap_.

186 {
187  if (names_.size() > 1) {
188  return namesMap_.at(names_.at(names_.size() - 1));
189  }
190  return namesMap_[0];//.at(names_.at(0));
191 }
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 
)
virtual

Reimplemented from DDLSAX2Handler.

Definition at line 48 of file DDLSAX2FileHandler.cc.

References cpv_, DCOUT_V, elementTypeCounter_, i, DDI::Singleton< I >::instance(), DDXMLElement::loadAttributes(), DDXMLElement::loadText(), names_, namesMap_, and DDLSAX2Handler::nmspace_.

52 {
53  DCOUT_V('P', "DDLSAX2FileHandler::startElement started");
54 
55  std::string myElementName(StrX(qname).localForm());
56  size_t i = 0;
57  for (; i < namesMap_.size(); ++i) {
58  if ( myElementName == namesMap_.at(i) ) {
59  names_.push_back(i);
60  break;
61  }
62  }
63  if (i >= namesMap_.size()) {
64  namesMap_.push_back(myElementName);
65  names_.push_back(namesMap_.size() - 1);
66  }
67 
68  ++elementTypeCounter_[myElementName];
69  //final way
70  // DDXMLElement* myElement = xmlelems_.getElement(myElementName); //myRegistry_->getElement(myElementName);
71  //temporary way:
72  DDXMLElement* myElement = DDLGlobalRegistry::instance().getElement(myElementName);
73 
74  unsigned int numAtts = attrs.getLength();
75  std::vector<std::string> attrNames, attrValues;
76 
77  for (unsigned int i = 0; i < numAtts; ++i)
78  {
79  // char* temp2 = XMLString::transcode(attrs.getLocalName(i));
80  // char* temp3 = XMLString::transcode(attrs.getValue(i));
81  attrNames.push_back(std::string(StrX(attrs.getLocalName(i)).localForm()));
82  attrValues.push_back(std::string(StrX(attrs.getValue(i)).localForm()));
83  // XMLString::release(&temp2);
84  // XMLString::release(&temp3);
85  }
86 
87  myElement->loadAttributes(myElementName, attrNames, attrValues, nmspace_, cpv_);
88  // initialize text
89  myElement->loadText(std::string());
90  DCOUT_V('P', "DDLSAX2FileHandler::startElement completed");
91 }
int i
Definition: DBlmapReader.cc:9
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:41
std::string nmspace_
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
std::vector< std::string > namesMap_
std::vector< size_t > names_
def qname
Definition: asciidump.py:315
std::map< std::string, int > elementTypeCounter_
This is a base class for processing XML elements in the DDD.
Definition: DDXMLElement.h:58
DDCompactView & cpv_
Definition: StrX.h:32

Member Data Documentation

DDCompactView& DDLSAX2FileHandler::cpv_
protected

Definition at line 85 of file DDLSAX2FileHandler.h.

Referenced by endElement(), and startElement().

std::map< std::string, int> DDLSAX2FileHandler::elementTypeCounter_
protected

Definition at line 82 of file DDLSAX2FileHandler.h.

Referenced by DDLSAX2ExpressionHandler::startElement(), and startElement().

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

Definition at line 84 of file DDLSAX2FileHandler.h.

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

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

Definition at line 83 of file DDLSAX2FileHandler.h.

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

DDLElementRegistry DDLSAX2FileHandler::xmlelems_
protected

Definition at line 86 of file DDLSAX2FileHandler.h.