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 31 CXPathObjectPtr::CXPathObjectPtr(xmlXPathObject* aObject) 32 : _object(aObject) 33 { 34 } 35 36 CXPathObjectPtr::CXPathObjectPtr():_object(NULL) 37 { 38 } 39 40 CXPathObjectPtr::~CXPathObjectPtr() 41 { 42 xmlXPathFreeObject(_object); 43 } 44 CXPathObjectPtr & CXPathObjectPtr::operator = (xmlXPathObject* pObj) 45 { 46 if (_object == pObj) 47 return *this; 48 49 xmlXPathFreeObject(_object); 50 _object = pObj; 51 return *this; 52 } 53 xmlXPathObject* CXPathObjectPtr::operator ->() 54 55 { 56 return _object; 57 } 58 CXPathObjectPtr::operator xmlXPathObject*() 59 { 60 return _object; 61 } 62 //=========================================================== 63 CXPathContextPtr::CXPathContextPtr(xmlXPathContextPtr aContext) 64 : _object(aContext) 65 { 66 } 67 68 CXPathContextPtr::CXPathContextPtr():_object(NULL) 69 { 70 } 71 72 CXPathContextPtr::~CXPathContextPtr() 73 { 74 xmlXPathFreeContext(_object); 75 } 76 77 CXPathContextPtr & CXPathContextPtr::operator = (xmlXPathContextPtr pObj) 78 { 79 if (_object == pObj) 80 return *this; 81 xmlXPathFreeContext(_object); 82 _object = pObj; 83 return *this; 84 } 85 xmlXPathContext* CXPathContextPtr::operator ->() 86 { 87 return _object; 88 } 89 90 CXPathContextPtr::operator xmlXPathContext*() 91 { 92 return _object; 93 } 94 //=========================================================== 95 CXmlDocPtr::CXmlDocPtr(xmlDoc* aDoc) 96 : _object(aDoc) 97 { 98 } 99 100 CXmlDocPtr::CXmlDocPtr():_object(NULL) 101 { 102 } 103 104 CXmlDocPtr::~CXmlDocPtr() 105 { 106 xmlFreeDoc(_object); 107 } 108 CXmlDocPtr & CXmlDocPtr::operator = (xmlDoc* pObj) 109 { 110 if (_object == pObj) 111 return *this; 112 xmlFreeDoc(_object); 113 _object = pObj; 114 return *this; 115 } 116 117 xmlDoc* CXmlDocPtr::operator ->() 118 { 119 return _object; 120 } 121 122 CXmlDocPtr::operator xmlDoc*() 123 { 124 return _object; 125 } 126 127 //=========================================================== 128 CXmlCharPtr::CXmlCharPtr(xmlChar * aChar) 129 : _object(aChar) 130 { 131 } 132 133 CXmlCharPtr::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 } 139 CXmlCharPtr::CXmlCharPtr():_object(NULL) 140 { 141 } 142 143 CXmlCharPtr::~CXmlCharPtr() 144 { 145 xmlFree(_object); 146 } 147 148 CXmlCharPtr & CXmlCharPtr::operator = (xmlChar* pObj) 149 { 150 if (pObj == _object) 151 return *this; 152 xmlFree(_object); 153 _object = pObj; 154 return *this; 155 } 156 157 CXmlCharPtr::operator xmlChar*() 158 { 159 return _object; 160 } 161 162 CXmlCharPtr::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 173 CXmlCharPtr::operator ::rtl::OString() 174 { 175 return ::rtl::OString((sal_Char*) _object); 176 } 177 178 179 180 } 181