Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include "libxmlutil.hxx"
21 : :
22 : : namespace jfw
23 : : {
24 : :
25 : 6 : CXPathObjectPtr::CXPathObjectPtr(xmlXPathObject* aObject)
26 : 6 : : _object(aObject)
27 : : {
28 : 6 : }
29 : :
30 : 246 : CXPathObjectPtr::CXPathObjectPtr():_object(NULL)
31 : : {
32 : 246 : }
33 : :
34 : 252 : CXPathObjectPtr::~CXPathObjectPtr()
35 : : {
36 : 252 : xmlXPathFreeObject(_object);
37 : 252 : }
38 : 246 : CXPathObjectPtr & CXPathObjectPtr::operator = (xmlXPathObject* pObj)
39 : : {
40 [ - + ]: 246 : if (_object == pObj)
41 : 0 : return *this;
42 : :
43 : 246 : xmlXPathFreeObject(_object);
44 : 246 : _object = pObj;
45 : 246 : return *this;
46 : : }
47 : 948 : xmlXPathObject* CXPathObjectPtr::operator ->()
48 : :
49 : : {
50 : 948 : return _object;
51 : : }
52 : 0 : CXPathObjectPtr::operator xmlXPathObject*() const
53 : : {
54 : 0 : return _object;
55 : : }
56 : : //===========================================================
57 : 99 : CXPathContextPtr::CXPathContextPtr(xmlXPathContextPtr aContext)
58 : 99 : : _object(aContext)
59 : : {
60 : 99 : }
61 : :
62 : 111 : CXPathContextPtr::CXPathContextPtr():_object(NULL)
63 : : {
64 : 111 : }
65 : :
66 : 210 : CXPathContextPtr::~CXPathContextPtr()
67 : : {
68 : 210 : xmlXPathFreeContext(_object);
69 : 210 : }
70 : :
71 : 111 : CXPathContextPtr & CXPathContextPtr::operator = (xmlXPathContextPtr pObj)
72 : : {
73 [ - + ]: 111 : if (_object == pObj)
74 : 0 : return *this;
75 : 111 : xmlXPathFreeContext(_object);
76 : 111 : _object = pObj;
77 : 111 : return *this;
78 : : }
79 : 0 : xmlXPathContext* CXPathContextPtr::operator ->()
80 : : {
81 : 0 : return _object;
82 : : }
83 : :
84 : 462 : CXPathContextPtr::operator xmlXPathContext*() const
85 : : {
86 : 462 : return _object;
87 : : }
88 : : //===========================================================
89 : 495 : CXmlDocPtr::CXmlDocPtr(xmlDoc* aDoc)
90 : 495 : : _object(aDoc)
91 : : {
92 : 495 : }
93 : :
94 : 111 : CXmlDocPtr::CXmlDocPtr():_object(NULL)
95 : : {
96 : 111 : }
97 : :
98 : 606 : CXmlDocPtr::~CXmlDocPtr()
99 : : {
100 : 606 : xmlFreeDoc(_object);
101 : 606 : }
102 : 111 : CXmlDocPtr & CXmlDocPtr::operator = (xmlDoc* pObj)
103 : : {
104 [ - + ]: 111 : if (_object == pObj)
105 : 0 : return *this;
106 : 111 : xmlFreeDoc(_object);
107 : 111 : _object = pObj;
108 : 111 : return *this;
109 : : }
110 : :
111 : 0 : xmlDoc* CXmlDocPtr::operator ->()
112 : : {
113 : 0 : return _object;
114 : : }
115 : :
116 : 1563 : CXmlDocPtr::operator xmlDoc*() const
117 : : {
118 : 1563 : return _object;
119 : : }
120 : :
121 : : //===========================================================
122 : 108 : CXmlCharPtr::CXmlCharPtr(xmlChar * aChar)
123 : 108 : : _object(aChar)
124 : : {
125 : 108 : }
126 : :
127 : 0 : CXmlCharPtr::CXmlCharPtr(const ::rtl::OUString & s):
128 : 0 : _object(NULL)
129 : : {
130 [ # # ]: 0 : ::rtl::OString o = ::rtl::OUStringToOString(s, RTL_TEXTENCODING_UTF8);
131 [ # # ]: 0 : _object = xmlCharStrdup(o.getStr());
132 : 0 : }
133 : 2097 : CXmlCharPtr::CXmlCharPtr():_object(NULL)
134 : : {
135 : 2097 : }
136 : :
137 : 2205 : CXmlCharPtr::~CXmlCharPtr()
138 : : {
139 : 2205 : xmlFree(_object);
140 : 2205 : }
141 : :
142 : 2889 : CXmlCharPtr & CXmlCharPtr::operator = (xmlChar* pObj)
143 : : {
144 [ - + ]: 2889 : if (pObj == _object)
145 : 0 : return *this;
146 : 2889 : xmlFree(_object);
147 : 2889 : _object = pObj;
148 : 2889 : return *this;
149 : : }
150 : :
151 : 3612 : CXmlCharPtr::operator xmlChar*() const
152 : : {
153 : 3612 : return _object;
154 : : }
155 : :
156 : 1167 : CXmlCharPtr::operator ::rtl::OUString()
157 : : {
158 : 1167 : ::rtl::OUString ret;
159 [ + - ]: 1167 : if (_object != NULL)
160 : : {
161 : 1167 : ::rtl::OString aOStr((sal_Char*)_object);
162 [ + - ]: 1167 : ret = ::rtl::OStringToOUString(aOStr, RTL_TEXTENCODING_UTF8);
163 : : }
164 : 1167 : return ret;
165 : : }
166 : :
167 : 198 : CXmlCharPtr::operator ::rtl::OString()
168 : : {
169 : 198 : return ::rtl::OString((sal_Char*) _object);
170 : : }
171 : :
172 : :
173 : :
174 : : }
175 : :
176 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|