#include <vtkNestingExpatBase.h>
Inheritance diagram for vtkNestingExpatBase:
vtkNestingExpatBase is a subclass to support a hierarchy of nesting parser objects, where a top-level (or root) parser object may create sub-parsers for different pieces of markup in a file.
The currently active child parser object is owned (i.e. the parent instance calls Register
on it) and is UnRegistered
by in the destructor, so error handling can propagate up the tree, closing parsers, without leaks.
// carries on using our parser, is self-deleting new UserChildParser(this)
// if want to get values back after end parsing RedirectInternalParser(someVar = new UserChildParser(this))
// will be new top-level parser, nothing to do with our XML new UserChildParser()
then it will be automatically self-deleting in itsnew UserChildParser(this)
ReturnToParent
method and will invoke DisownChild
to clear our Child
.
RedirectInternalParser
(new UserChildParser()); then the user child parser will start with a new XML parser instance created by the vtkExpatBase
constructor. This is safe but slightly wasteful of processing as SetParent
will discard and replace the child's newly created expat XML parser.RedirectInternalParser
(somevar = new UserChildParser(this)) allows you to get values back out of a child parser, in the context of the parent, e.g.: void MultiFilterParser::startElement (const XML_Char* name, const XML_Char** attrs) { if (strcmp(name, "FilterRequest")==0) { // We now own and will have to explicitly delete the child. this->RedirectInternalParser( this->CurrentFilterParser = new FilterRequestParser(this, attrs) ); ... } ... void MultiFilterParser::endElement (const XML_Char* name) { if (strcmp(name, "FilterRequest")==0) { assert(this->CurrentFilterParser != 0); // retrieve data built by sub-parser FilterData* newData = this->CurrentFilterParser->orphanBuiltData(); ... this->CurrentFilterParser = 0; this->SetChild(NULL); } }
Definition at line 114 of file vtkNestingExpatBase.h.
Public Member Functions | |
vtkTypeRevisionMacro (vtkNestingExpatBase, vtkExpatBase) | |
void | PrintSelf (ostream &, vtkIndent) |
void | RedirectInternalParser (vtkNestingExpatBase *aChild) |
Hand off current document to a child parser that understands the next segment of XML. | |
virtual vtkNestingExpatBase * | ReturnToParent (void) |
Called by NestedEndElementCb if this is NOT the root parser. | |
virtual vtkNestingExpatBase * | GetChild (void) const |
Get the child parser. | |
Static Public Member Functions | |
Interface functions for callbacks. | |
void | NestedStartElementCb (void *aPtr, const XML_Char *aName, const XML_Char **aAttrs) |
Start element callback for nesting parsers. | |
void | NestedEndElementCb (void *aPtr, const XML_Char *aName) |
End element callback for nesting parsers. | |
Protected Member Functions | |
vtkNestingExpatBase (vtkNestingExpatBase *parent=NULL) | |
Default constructor. | |
~vtkNestingExpatBase () | |
virtual void | SetupHandlers (void) |
Set the handlers used by expat callbacks. | |
virtual void | SetChild (vtkNestingExpatBase *child) |
Called from child constructors when passed a parent pointer as well as from RedirectInternalParser , in which case it may be the 2nd time we're called for a given child (see scenarios in vtkNestingExpatBase class comment). | |
virtual void | DeleteChild (void) |
Must use before early disposal of holding adopted child parser. | |
void | GrabInternalParserFromParent (void) |
Use parent's underlying expat parser. | |
void | SetParent (vtkNestingExpatBase *aParent) |
Called by RedirectInternalParser to indicate a newly created child parser object is now the currently active child for aParent and the child isn't expected to self-delete. | |
void | OrphanChild (vtkNestingExpatBase *aCallingChild) |
Honor request from aCallingChild to relinquish responsibility for it. | |
Protected Attributes | |
Nesting parser object data | |
vtkNestingExpatBase * | Parent |
Parent owns this object (NULL for root parser objects). | |
int | Depth |
Number of levels nested below the root parser. | |
bool | SelfDeleting |
Only valid if Parent is not NULL . | |
vtkNestingExpatBase * | Child |
Owned, optional currently active child. |
|
Default constructor.
|
|
|
|
Must use before early disposal of holding adopted child parser.
|
|
Get the child parser.
Reimplemented in vtkPaletteElementParser. |
|
Use parent's underlying expat parser.
Definition at line 255 of file vtkNestingExpatBase.h. References vtkExpatBase::GrabInternalParser(), vtkObject::Modified(), Parent, and vtkExpatBase::Parser. Referenced by SetParent(). |
|
End element callback for nesting parsers.
Definition at line 355 of file vtkNestingExpatBase.h. References Depth, vtkExpatBase::EndElement(), NestedEndElementCb(), and ReturnToParent(). Referenced by NestedEndElementCb(). |
|
Start element callback for nesting parsers.
Definition at line 341 of file vtkNestingExpatBase.h. References Depth, NestedStartElementCb(), and vtkExpatBase::StartElement(). Referenced by NestedStartElementCb(). |
|
Honor request from
i.e. Simply set Definition at line 303 of file vtkNestingExpatBase.h. References Child, vtkObject::Modified(), and OrphanChild(). Referenced by OrphanChild(), and ReturnToParent(). |
|
Reimplemented from vtkExpatBase. Reimplemented in vtkPaletteColorBaseParser, and vtkPaletteElementParser. |
|
Hand off current document to a child parser that understands the next segment of XML.
User code (typically the
Control will be returned to the original (parent) parser when the end of the child element is reached. In its lifetime a 'parent' parser may switch control to several child parsers (one at a time of course) as it moves through the document encountering various types of child element.
Definition at line 291 of file vtkNestingExpatBase.h. References RedirectInternalParser(), SetChild(), and SetParent(). Referenced by RedirectInternalParser(). |
|
Called by
Reimplemented in vtkPaletteColorBaseParser. Definition at line 316 of file vtkNestingExpatBase.h. References vtkObjectBase::Delete(), vtkExpatBase::GrabInternalParser(), OrphanChild(), Parent, and SelfDeleting. Referenced by NestedEndElementCb(). |
|
Called from child constructors when passed a parent pointer as well as from
The parameter data is checked against the instance data, so that Referenced by RedirectInternalParser(). |
|
Called by Normal code to create an owned child would be either: where this is the currently active parent parser and wants to be responsible for deleting the new child, or to have a child parser self-delete.
Definition at line 269 of file vtkNestingExpatBase.h. References GrabInternalParserFromParent(), vtkObject::Modified(), Parent, vtkExpatBase::ReleaseParser(), SelfDeleting, and SetParent(). Referenced by RedirectInternalParser(), and SetParent(). |
|
Set the handlers used by expat callbacks.
Reimplemented from vtkExpatBase. Reimplemented in vtkPaletteColorBaseParser, and vtkPaletteElementParser. |
|
|
|
Owned, optional currently active child.
Definition at line 238 of file vtkNestingExpatBase.h. Referenced by OrphanChild(). |
|
Number of levels nested below the root parser.
Definition at line 232 of file vtkNestingExpatBase.h. Referenced by NestedEndElementCb(), and NestedStartElementCb(). |
|
Definition at line 229 of file vtkNestingExpatBase.h. Referenced by GrabInternalParserFromParent(), ReturnToParent(), and SetParent(). |
|
Only valid if
Definition at line 235 of file vtkNestingExpatBase.h. Referenced by ReturnToParent(), and SetParent(). |