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 27 of file DDLSAX2FileHandler.cc.

References init().

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

Definition at line 42 of file DDLSAX2FileHandler.cc.

43 {}

Member Function Documentation

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

Reimplemented from DDLSAX2Handler.

Definition at line 133 of file DDLSAX2FileHandler.cc.

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

135 {
136  DCOUT_V('P', "DDLSAX2FileHandler::characters started");
137  // std::cout << "character handler started" << std::endl;
138  //DDXMLElement* myElement = NULL;
139  // final way
140  // myElement = xmlelems_.getElement(namesMap_[names_.back()]);
141  //temporary way:
142  // const std::string& myElementName = namesMap_[names_.back()];
143  DDXMLElement* myElement = DDLGlobalRegistry::instance().getElement(self());//myElementName); //namesMap_[names_.back()]);
144  std::string inString = "";
145  for (unsigned int i = 0; i < length; ++i)
146  {
147  char s = chars[i];
148  inString = inString + s;
149  }
150  if (myElement->gotText())
151  myElement->appendText(inString);
152  else
153  myElement->loadText(inString);
154 
155  DCOUT_V('P', "DDLSAX2FileHandler::characters completed");
156 }
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:59
string s
Definition: asciidump.py:422
void DDLSAX2FileHandler::comment ( const XMLCh *const  chars,
const unsigned int  length 
)
virtual

Reimplemented from DDLSAX2Handler.

Definition at line 159 of file DDLSAX2FileHandler.cc.

161 {
162  // ignore, discard, overkill since base class also has this...
163 }
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 170 of file DDLSAX2FileHandler.cc.

References DDConstant::createConstantsFromEvaluator().

Referenced by init().

171 {
173 }
static void createConstantsFromEvaluator()
creates all DDConstants from the variables of the ClhepEvaluator
Definition: DDConstant.cc:36
void DDLSAX2FileHandler::dumpElementTypeCounter ( void  )

This dumps some statistics on elements encountered in the file.

Definition at line 166 of file DDLSAX2FileHandler.cc.

Referenced by DDLParser::parse().

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

Reimplemented from DDLSAX2Handler.

Definition at line 95 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_.

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

Definition at line 35 of file DDLSAX2FileHandler.cc.

References createDDConstants(), names_, and namesMap_.

Referenced by DDLSAX2FileHandler().

36 {
38  namesMap_.push_back("*** root ***");
39  names_.push_back(namesMap_.size() - 1);
40 }
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 176 of file DDLSAX2FileHandler.cc.

References names_, and namesMap_.

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

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

Definition at line 186 of file DDLSAX2FileHandler.cc.

References names_, and namesMap_.

187 {
188  if (names_.size() > 1) {
189  return namesMap_.at(names_.at(names_.size() - 1));
190  }
191  return namesMap_[0];//.at(names_.at(0));
192 }
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 49 of file DDLSAX2FileHandler.cc.

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

53 {
54  DCOUT_V('P', "DDLSAX2FileHandler::startElement started");
55 
56  std::string myElementName(StrX(qname).localForm());
57  size_t i = 0;
58  for (; i < namesMap_.size(); ++i) {
59  if ( myElementName == namesMap_.at(i) ) {
60  names_.push_back(i);
61  break;
62  }
63  }
64  if (i >= namesMap_.size()) {
65  namesMap_.push_back(myElementName);
66  names_.push_back(namesMap_.size() - 1);
67  }
68 
69  ++elementTypeCounter_[myElementName];
70  //final way
71  // DDXMLElement* myElement = xmlelems_.getElement(myElementName); //myRegistry_->getElement(myElementName);
72  //temporary way:
73  DDXMLElement* myElement = DDLGlobalRegistry::instance().getElement(myElementName);
74 
75  unsigned int numAtts = attrs.getLength();
76  std::vector<std::string> attrNames, attrValues;
77 
78  for (unsigned int i = 0; i < numAtts; ++i)
79  {
80  // char* temp2 = XMLString::transcode(attrs.getLocalName(i));
81  // char* temp3 = XMLString::transcode(attrs.getValue(i));
82  attrNames.push_back(std::string(StrX(attrs.getLocalName(i)).localForm()));
83  attrValues.push_back(std::string(StrX(attrs.getValue(i)).localForm()));
84  // XMLString::release(&temp2);
85  // XMLString::release(&temp3);
86  }
87 
88  myElement->loadAttributes(myElementName, attrNames, attrValues, nmspace_, cpv_);
89  // initialize text
90  myElement->loadText(std::string());
91  DCOUT_V('P', "DDLSAX2FileHandler::startElement completed");
92 }
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:44
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:59
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.