1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_jvmfwk.hxx" 26 #include "libxmlutil.hxx" 27 28 namespace jfw 29 { 30 CXPathObjectPtr(xmlXPathObject * aObject)31CXPathObjectPtr::CXPathObjectPtr(xmlXPathObject* aObject) 32 : _object(aObject) 33 { 34 } 35 CXPathObjectPtr()36CXPathObjectPtr::CXPathObjectPtr():_object(NULL) 37 { 38 } 39 ~CXPathObjectPtr()40CXPathObjectPtr::~CXPathObjectPtr() 41 { 42 xmlXPathFreeObject(_object); 43 } operator =(xmlXPathObject * pObj)44CXPathObjectPtr & CXPathObjectPtr::operator = (xmlXPathObject* pObj) 45 { 46 if (_object == pObj) 47 return *this; 48 49 xmlXPathFreeObject(_object); 50 _object = pObj; 51 return *this; 52 } operator ->()53xmlXPathObject* CXPathObjectPtr::operator ->() 54 55 { 56 return _object; 57 } operator xmlXPathObject*()58CXPathObjectPtr::operator xmlXPathObject*() 59 { 60 return _object; 61 } 62 //=========================================================== CXPathContextPtr(xmlXPathContextPtr aContext)63CXPathContextPtr::CXPathContextPtr(xmlXPathContextPtr aContext) 64 : _object(aContext) 65 { 66 } 67 CXPathContextPtr()68CXPathContextPtr::CXPathContextPtr():_object(NULL) 69 { 70 } 71 ~CXPathContextPtr()72CXPathContextPtr::~CXPathContextPtr() 73 { 74 xmlXPathFreeContext(_object); 75 } 76 operator =(xmlXPathContextPtr pObj)77CXPathContextPtr & CXPathContextPtr::operator = (xmlXPathContextPtr pObj) 78 { 79 if (_object == pObj) 80 return *this; 81 xmlXPathFreeContext(_object); 82 _object = pObj; 83 return *this; 84 } operator ->()85xmlXPathContext* CXPathContextPtr::operator ->() 86 { 87 return _object; 88 } 89 operator xmlXPathContext*()90CXPathContextPtr::operator xmlXPathContext*() 91 { 92 return _object; 93 } 94 //=========================================================== CXmlDocPtr(xmlDoc * aDoc)95CXmlDocPtr::CXmlDocPtr(xmlDoc* aDoc) 96 : _object(aDoc) 97 { 98 } 99 CXmlDocPtr()100CXmlDocPtr::CXmlDocPtr():_object(NULL) 101 { 102 } 103 ~CXmlDocPtr()104CXmlDocPtr::~CXmlDocPtr() 105 { 106 xmlFreeDoc(_object); 107 } operator =(xmlDoc * pObj)108CXmlDocPtr & CXmlDocPtr::operator = (xmlDoc* pObj) 109 { 110 if (_object == pObj) 111 return *this; 112 xmlFreeDoc(_object); 113 _object = pObj; 114 return *this; 115 } 116 operator ->()117xmlDoc* CXmlDocPtr::operator ->() 118 { 119 return _object; 120 } 121 operator xmlDoc*()122CXmlDocPtr::operator xmlDoc*() 123 { 124 return _object; 125 } 126 127 //=========================================================== CXmlCharPtr(xmlChar * aChar)128CXmlCharPtr::CXmlCharPtr(xmlChar * aChar) 129 : _object(aChar) 130 { 131 } 132 CXmlCharPtr(const::rtl::OUString & s)133CXmlCharPtr::CXmlCharPtr(const ::rtl::OUString & s): 134 _object(NULL) 135 { 136 ::rtl::OString o = ::rtl::OUStringToOString(s, RTL_TEXTENCODING_UTF8); 137 _object = xmlCharStrdup(o.getStr()); 138 } CXmlCharPtr()139CXmlCharPtr::CXmlCharPtr():_object(NULL) 140 { 141 } 142 ~CXmlCharPtr()143CXmlCharPtr::~CXmlCharPtr() 144 { 145 xmlFree(_object); 146 } 147 operator =(xmlChar * pObj)148CXmlCharPtr & CXmlCharPtr::operator = (xmlChar* pObj) 149 { 150 if (pObj == _object) 151 return *this; 152 xmlFree(_object); 153 _object = pObj; 154 return *this; 155 } 156 operator xmlChar*()157CXmlCharPtr::operator xmlChar*() 158 { 159 return _object; 160 } 161 operator ::rtl::OUString()162CXmlCharPtr::operator ::rtl::OUString() 163 { 164 ::rtl::OUString ret; 165 if (_object != NULL) 166 { 167 ::rtl::OString aOStr((sal_Char*)_object); 168 ret = ::rtl::OStringToOUString(aOStr, RTL_TEXTENCODING_UTF8); 169 } 170 return ret; 171 } 172 operator ::rtl::OString()173CXmlCharPtr::operator ::rtl::OString() 174 { 175 return ::rtl::OString((sal_Char*) _object); 176 } 177 178 179 180 } 181