summaryrefslogtreecommitdiffstats
path: root/media/libdrm/mobile2/src/util/xml
diff options
context:
space:
mode:
Diffstat (limited to 'media/libdrm/mobile2/src/util/xml')
-rw-r--r--media/libdrm/mobile2/src/util/xml/DomExpatAgent.cpp228
-rw-r--r--media/libdrm/mobile2/src/util/xml/ExpatWrapper.cpp77
-rw-r--r--media/libdrm/mobile2/src/util/xml/XMLDocumentImpl.cpp55
-rw-r--r--media/libdrm/mobile2/src/util/xml/XMLElementImpl.cpp136
4 files changed, 0 insertions, 496 deletions
diff --git a/media/libdrm/mobile2/src/util/xml/DomExpatAgent.cpp b/media/libdrm/mobile2/src/util/xml/DomExpatAgent.cpp
deleted file mode 100644
index 4cde706..0000000
--- a/media/libdrm/mobile2/src/util/xml/DomExpatAgent.cpp
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <util/xml/DomExpatAgent.h>
-#include <util/xml/XMLElementImpl.h>
-#include <ustring.h>
-#include <uios.h>
-using namespace ustl;
-
-/** see DomExpatAgent.h */
-DomExpatAgent::DomExpatAgent(XMLDocumentImpl* xmlDocPtr)
-{
- mXMLDocumentPtr = xmlDocPtr;
- mTopElementPtr = NULL;
-}
-
-/** see DomExpatAgent.h */
-DomExpatAgent::~DomExpatAgent()
-{
-
-}
-
-/** see DomExpatAgent.h */
-bool DomExpatAgent::generateDocumentFromXML(istringstream *xmlStream)
-{
- char ch;
- string content;
-
- if (NULL == mXMLDocumentPtr || NULL == xmlStream)
- {
- return false;
- }
-
- while ((ch = xmlStream->get()) != '\0')
- {
- content += ch;
- }
-
- if (ExpatWrapper::decode(content.c_str(), content.length(), 1) == 0)
-
- {
- return false;
- }
- return true;
-}
-
-/** see DomExpatAgent.h */
-void DomExpatAgent::pushTag(const DOMString *name, const XML_Char **atts)
-{
- ElementImpl *elementNode = mXMLDocumentPtr->createElement(name);
-
- if (NULL == elementNode)
- {
- return;
- }
-
- if (NULL != atts)
- {
- while (NULL != *atts)
- {
- //set attributes into element node.
- DOMString key(atts[0]), value(atts[1]);
- elementNode->setAttribute(&key, &value);
- atts += 2;
- }
- }
-
- if (!mStack.empty())
- {
- mTopElementPtr->appendChild(elementNode);
- }
- else
- {
- mXMLDocumentPtr->setFirstChild(elementNode);
- }
-
- mTopElementPtr = (XMLElementImpl *)elementNode;
- mStack.push_back(elementNode);
-}
-
-/** see DomExpatAgent.h */
-void DomExpatAgent::popTag(const DOMString *name)
-{
- if (NULL == name)
- {
- return;
- }
-
- if (mTopElementPtr != NULL)
- {
- if (!name->compare(mTopElementPtr->getTagName()->c_str()))
- {
- mStack.pop_back();
- if (!mStack.empty())
- {
- mTopElementPtr =(XMLElementImpl *) mStack.back();
- }
- else
- {
- mTopElementPtr = NULL;
- }
- }
- }
-}
-
-/** see DomExpatAgent.h */
-void DomExpatAgent::appendText(const DOMString *text)
-{
- if ((mTopElementPtr != NULL) && (text != NULL))
- {
- TextImpl *textNode = mXMLDocumentPtr->createTextNode(text);
-
- if (NULL == textNode)
- {
- return;
- }
-
- mTopElementPtr->appendChild(textNode);
- }
-}
-
-/** see DomExpatAgent.h */
-void DomExpatAgent::startElement(const XML_Char *name, const XML_Char **atts)
-{
- if (name)
- {
- DOMString tagName(name);
-
- pushTag(&tagName, atts);
- }
-}
-
-/** see DomExpatAgent.h */
-void DomExpatAgent::dataHandler(const XML_Char *s, int len)
-{
- if (s != NULL && len >= 1 && *s != '\n')
- {
- DOMString text;
- text.assign((char*)s, len);
- appendText(&text);
- }
-}
-
-/** see DomExpatAgent.h */
-void DomExpatAgent::endElement(const XML_Char *name)
-{
- if (name)
- {
- DOMString tagName(name);
- popTag(&tagName);
- }
-}
-
-/** see DomExpatAgent.h */
-ostringstream* DomExpatAgent::generateXMLFromDocument()
-{
- if (NULL == mXMLDocumentPtr)
- {
- return NULL;
- }
-
- ElementImpl *root = mXMLDocumentPtr->getDocumentElement();
-
- traverse(root);
-
- return &mXMLostream;
-}
-
-/** see DomExpatAgent.h */
-void DomExpatAgent::traverse(ElementImpl *root)
-{
- if (NULL == root)
- {
- return;
- }
-
- mXMLostream << "<" << *(root->getNodeName());
-
- if (root->hasAttributes())
- {
- mXMLostream << endl;
- const DOMStringMap* attrMapPtr = (static_cast<XMLElementImpl*>(root))->getAttributeMap();
- DOMStringMap::const_reverse_iterator pos;
-
- for (pos=attrMapPtr->rbegin(); pos != attrMapPtr->rend(); pos++)
- {
- mXMLostream << pos->first << "=" << "\"" << pos->second << "\"";
-
- if (pos + 1 != attrMapPtr->rend())
- {
- mXMLostream << endl;
- }
- }
- }
-
- mXMLostream << ">" << endl;
-
- NodeImpl *child = root->getFirstChild();
-
- while (child != NULL)
- {
- NodeType what = child->getNodeType();
-
- if (what == ELEMENT_NODE)
- {
- traverse(static_cast<ElementImpl*>(child));
- } else if (what == TEXT_NODE)
- {
- mXMLostream << *(static_cast<TextImpl*>(child)->getData()) << endl;
- }
-
- child = child->getNextSibling();
- }
-
- mXMLostream << "</" << *(root->getNodeName()) << ">" << endl;
-}
diff --git a/media/libdrm/mobile2/src/util/xml/ExpatWrapper.cpp b/media/libdrm/mobile2/src/util/xml/ExpatWrapper.cpp
deleted file mode 100644
index fe99a88..0000000
--- a/media/libdrm/mobile2/src/util/xml/ExpatWrapper.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <util/xml/ExpatWrapper.h>
-#include <ustring.h>
-using namespace ustl;
-
-/** see ExpatWrapper.h */
-ExpatWrapper::ExpatWrapper()
-{
- mParser = XML_ParserCreate(NULL);
- ::XML_SetUserData(mParser, this);
- ::XML_SetElementHandler(mParser, startElementCallback, endElementCallback);
- ::XML_SetCharacterDataHandler(mParser, dataHandlerCallback);
-
-}
-
-/** see ExpatWrapper.h */
-ExpatWrapper::~ExpatWrapper()
-{
- if (mParser)
- {
- ::XML_ParserFree(mParser);
- }
-}
-
-/** see ExpatWrapper.h */
-int ExpatWrapper::decode(const char* buf, int len, int isFinal)
-{
- return ::XML_Parse(mParser, buf, len, isFinal);
-}
-
-/** see ExpatWrapper.h */
-void ExpatWrapper::startElementCallback(void *userData, const XML_Char *name,
- const XML_Char **atts)
-{
- ((ExpatWrapper *)userData)->startElement(name, atts);
-}
-
-/** see ExpatWrapper.h */
-void ExpatWrapper::endElementCallback(void *userData, const XML_Char *name)
-{
- ((ExpatWrapper *)userData)->endElement(name);
-}
-
-/** see ExpatWrapper.h */
-void ExpatWrapper::dataHandlerCallback(void *userData, const XML_Char *s, int len)
-{
- ((ExpatWrapper *)userData)->dataHandler(s, len);
-}
-
-/** see ExpatWrapper.h */
-void ExpatWrapper::startElement(const XML_Char *name, const XML_Char **atts)
-{
-}
-
-/** see ExpatWrapper.h */
-void ExpatWrapper::endElement(const XML_Char *name)
-{
-}
-
-/** see ExpatWrapper.h */
-void ExpatWrapper::dataHandler(const XML_Char *s, int len)
-{
-}
diff --git a/media/libdrm/mobile2/src/util/xml/XMLDocumentImpl.cpp b/media/libdrm/mobile2/src/util/xml/XMLDocumentImpl.cpp
deleted file mode 100644
index c1fbc79..0000000
--- a/media/libdrm/mobile2/src/util/xml/XMLDocumentImpl.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <util/xml/XMLDocumentImpl.h>
-#include <util/xml/XMLElementImpl.h>
-
-/** see XMLDocumentImpl.h */
-XMLDocumentImpl::XMLDocumentImpl()
-{}
-
-/** see XMLDocumentImpl.h */
-XMLDocumentImpl::~XMLDocumentImpl()
-{}
-
-/** see XMLDocumentImpl.h */
-ElementImpl* XMLDocumentImpl::getDocumentElement() const
-{
- XMLElementImpl *element = (XMLElementImpl *)(this->getFirstChild());
- return element;
-}
-
-/** see XMLDocumentImpl.h */
-ElementImpl* XMLDocumentImpl::createElement(const DOMString* tagName) const throw (DOMException)
-{
- if (tagName)
- {
- XMLElementImpl *element = new XMLElementImpl(tagName);
- return element;
- }
- return NULL;
-}
-
-/** see XMLDocumentImpl.h */
-TextImpl* XMLDocumentImpl::createTextNode(const DOMString* data) const
-{
- if (data)
- {
- TextImpl *text = new TextImpl(data);
- return text;
- }
- return NULL;
-}
-
diff --git a/media/libdrm/mobile2/src/util/xml/XMLElementImpl.cpp b/media/libdrm/mobile2/src/util/xml/XMLElementImpl.cpp
deleted file mode 100644
index 5453902..0000000
--- a/media/libdrm/mobile2/src/util/xml/XMLElementImpl.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <util/xml/XMLElementImpl.h>
-#include <util/domcore/TextImpl.h>
-
-/** see XMLElementImpl.h */
-XMLElementImpl::XMLElementImpl(const DOMString *tag)
-{
- if (tag)
- {
- mTagName = *tag;
- }
-}
-
-/** see XMLElementImpl.h */
-XMLElementImpl::~XMLElementImpl()
-{
-}
-
-/** see XMLElementImpl.h */
-const DOMString* XMLElementImpl::getTagName() const
-{
- return &mTagName;
-}
-
-/** see XMLElementImpl.h */
-void XMLElementImpl::setAttribute(const DOMString* name, const DOMString* value)
- throw (DOMException)
-{
- if (name && value)
- {
- mAttributeMap[*name] = *value;
- }
-}
-
-/** see XMLElementImpl.h */
-void XMLElementImpl::removeAttribute(const DOMString* name) throw (DOMException)
-{
- if (name)
- {
- mAttributeMap.erase(*name);
- }
-}
-
-/** see XMLElementImpl.h */
-const DOMString* XMLElementImpl::getAttribute(const DOMString* name) const
-{
- if (name)
- {
- DOMStringMap::const_iterator pos = mAttributeMap.find(*name);
-
- if (pos != mAttributeMap.end())
- {
- return &(pos->second);
- }
-
- }
- return NULL;
-}
-
-/** see XMLElementImpl.h */
-bool XMLElementImpl::hasAttributes() const
-{
- return !mAttributeMap.empty();
-}
-
-/** see XMLElementImpl.h */
-const DOMStringMap* XMLElementImpl::getAttributeMap() const
-{
- return &mAttributeMap;
-}
-
-/** see XMLElementImpl.h */
-const NodeImpl* XMLElementImpl::findSoloChildNode(const char* tag) const
-{
- if (NULL == tag)
- {
- return NULL;
- }
-
- string token;
- NodeListImpl *nodeList = NULL;
- const NodeImpl *childNode = NULL;
-
- token.assign(tag);
- nodeList = getElementsByTagName(&token);
-
- if (nodeList->getLength() > 0)
- {
- childNode = nodeList->item(0);
- }
-
- return childNode;
-}
-
-/** see XMLElementImpl.h */
-const string* XMLElementImpl::getSoloText(const char* tag) const
-{
- const NodeImpl *textNode = this->findSoloChildNode(tag);
-
- if (textNode)
- {
- textNode = textNode->getFirstChild();
- if (textNode)
- {
- return static_cast<const TextImpl*>(textNode)->getData();
- }
- }
-
- return NULL;
-}
-
-/** see XMLElementImpl.h */
-const XMLElementImpl* XMLElementImpl::getSoloElement(const char* tag) const
-{
- const NodeImpl *node = findSoloChildNode(tag);
- if (node)
- {
- return static_cast<const XMLElementImpl*>(node);
- }
-
- return NULL;
-}