3#include <xercesc/dom/DOMElement.hpp>
4#include <xercesc/dom/DOMDocument.hpp>
6#include "xmlBase/XmlParser.h"
7#include "xmlBase/Dom.h"
8#include "xmlBase/docMan/DocMan.h"
9#include "xmlBase/docMan/DocClient.h"
12XERCES_CPP_NAMESPACE_USE
14 DocMan* DocMan::m_self = 0;
29 bool DocMan::parse(
const std::string& filename,
const std::string& docType) {
33 DOMDocument* doc = m_parser->
parse(filename.c_str(), docType);
34 if (doc == 0)
return false;
38 DOMElement*
root = doc->getDocumentElement();
47 if (list) list->
invoke(child);
63 m_lists.push_back(curList);
65 return curList->
add(client);
69 if (m_meFirst != 0)
return false;
78 for (
ix = 0;
ix < m_lists.size();
ix++) {
80 if (eltName.compare(cur->
getName()) == 0)
return cur;
86 ClientsIt it = m_clients.begin();
87 const std::string& clientName = client->
getName();
88 while (it != m_clients.end() ) {
90 if (clientName.compare((*it)->getName()) == 0 )
return 0;
93 if (front) m_clients.insert(m_clients.begin(), client);
94 else m_clients.push_back(client);
107 ClientsIt it = m_clients.begin();
108 while (it != m_clients.end() ) {
109 (*it)->handleChild(elt);
120 ListsIt it = m_lists.begin();
121 while (it != m_lists.end()) {
virtual void handleChild(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *node)=0
Must be overridden by derived classes.
virtual const std::string & getName()=0
Nested class to keep track of clients for one element type.
void invoke(DomElement *elt)
call back each client in turn
const std::string & getName()
which list are we?
bool add(DocClient *client, bool front=false)
Add a client to list.
bool remove(DocClient *client)
DocMan allows different clients to share a single xml document.
virtual bool regClient(const std::string &eltName, DocClient *client)
static DocMan * getPointer()
Implements singleton.
bool regMeFirst(DocClient *client)
Register privileged client; only available to derived classes.
virtual bool parse(const std::string &filename, const std::string &docType=std::string(""))
ClientList * findList(const std::string &eltName)
static std::string getTagName(const DOMElement *node)
static DOMElement * getSiblingElement(const DOMNode *child)
Return next element sibling, if any.
static DOMElement * getFirstChildElement(const DOMNode *parent)
Get first child which is an element node, if any.
DOMDocument * parse(const char *const filename, const std::string &docType=std::string(""))
Parse an xml file, returning document node if successful.