summaryrefslogtreecommitdiff
path: root/media/libdrm/mobile2/src/util/xml/ExpatWrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'media/libdrm/mobile2/src/util/xml/ExpatWrapper.cpp')
-rw-r--r--media/libdrm/mobile2/src/util/xml/ExpatWrapper.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/media/libdrm/mobile2/src/util/xml/ExpatWrapper.cpp b/media/libdrm/mobile2/src/util/xml/ExpatWrapper.cpp
new file mode 100644
index 000000000000..fe99a88a0278
--- /dev/null
+++ b/media/libdrm/mobile2/src/util/xml/ExpatWrapper.cpp
@@ -0,0 +1,77 @@
+/*
+ * 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)
+{
+}