source: trunk/VUT/GtpVisibilityPreprocessor/support/xercesc/com/IXMLDOMCharacterDataImpl.h @ 188

Revision 188, 6.2 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in
16 *    the documentation and/or other materials provided with the
17 *    distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 *    if any, must include the following acknowledgment: 
21 *       "This product includes software developed by the
22 *        Apache Software Foundation (http://www.apache.org/)."
23 *    Alternately, this acknowledgment may appear in the software itself,
24 *    if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Xerces" and "Apache Software Foundation" must
27 *    not be used to endorse or promote products derived from this
28 *    software without prior written permission. For written
29 *    permission, please contact apache\@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 *    nor may "Apache" appear in their name, without prior written
33 *    permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation, and was
51 * originally based on software copyright (c) 1999, International
52 * Business Machines, Inc., http://www.ibm.com .  For more information
53 * on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57/*
58 * $Log: IXMLDOMCharacterDataImpl.h,v $
59 * Revision 1.3  2003/11/21 12:05:48  amassari
60 * Updated version to 2.4
61 *
62 * Revision 1.2  2003/03/14 12:44:49  tng
63 * [Bug 17147] C++ namespace breaks build of XercesCOM DLL
64 *
65 * Revision 1.1.1.1  2002/02/01 22:21:39  peiyongz
66 * sane_include
67 *
68 * Revision 1.3  2000/07/07 00:12:51  jpolast
69 * bug fixes for non-null terminated strings
70 *
71 * Revision 1.2  2000/03/30 02:00:13  abagchi
72 * Initial checkin of working code with Copyright Notice
73 *
74 */
75
76#ifndef ___ixmldomcharacterdataimpl_h___
77#define ___ixmldomcharacterdataimpl_h___
78
79#include "IXMLDOMNodeImpl.h"
80XERCES_CPP_NAMESPACE_USE
81
82template <class T, const IID* piid, class tihclass = CComTypeInfoHolder>
83class ATL_NO_VTABLE IXMLDOMCharacterDataImpl: public IXMLDOMNodeImpl<T,piid,tihclass>
84{
85private:
86        XMLCh* DOMStringToXMLCh(DOMString str)
87        {
88                XMLCh* cdata = new XMLCh[str.length()+1];
89                for (unsigned int i=0; i < str.length(); i++)
90                        cdata[i] = str.charAt(i);
91                cdata[str.length()] = 0;
92                return cdata;
93        }
94
95public:
96
97        virtual DOM_CharacterData& get_DOM_CharacterData() = 0;
98        virtual DOM_Node& get_DOM_Node() { return get_DOM_CharacterData(); }
99
100        // IXMLDOMCharacterData
101
102STDMETHOD(get_data)(BSTR  *pVal)
103{
104        ATLTRACE(_T("IXMLDOMCharacterDataImpl::get_data\n"));
105
106        if (NULL == pVal)
107                return E_POINTER;
108
109        *pVal = NULL;
110       
111        try
112        {
113                //*pVal = SysAllocString(get_DOM_CharacterData().getData().rawBuffer());
114                *pVal = SysAllocString(DOMStringToXMLCh(get_DOM_CharacterData().getData()));
115        }
116        catch(...)
117        {
118                return E_FAIL;
119        }
120       
121
122        return S_OK;
123}
124
125STDMETHOD(put_data)(BSTR newVal)
126{
127        ATLTRACE(_T("IXMLDOMCharacterDataImpl::put_data\n"));
128
129        try
130        {
131                get_DOM_CharacterData().setData(newVal);
132        }
133        catch(...)
134        {
135                return E_FAIL;
136        }
137       
138
139        return S_OK;
140}
141
142STDMETHOD(get_length)(long  *pVal)
143{
144        ATLTRACE(_T("IXMLDOMCharacterDataImpl::get_length\n"));
145
146        if (NULL == pVal)
147                return E_POINTER;
148
149        *pVal = 0;
150
151        try
152        {
153                *pVal = get_DOM_CharacterData().getLength();
154        }
155        catch(...)
156        {
157                return E_FAIL;
158        }
159
160        return S_OK;
161}
162
163STDMETHOD(substringData)(long offset, long count, BSTR  *data)
164{
165        ATLTRACE(_T("IXMLDOMCharacterDataImpl::substringData\n"));
166
167        if (NULL == data)
168                return E_POINTER;
169
170        *data = NULL;
171
172        try
173        {
174                // need to copy the string to a new buffer since DOMString doesn't null terminate the substring.
175                *data = SysAllocString(DOMStringToXMLCh(get_DOM_CharacterData().substringData(offset, count)));
176        }
177        catch(...)
178        {
179                return E_FAIL;
180        }
181       
182        return S_OK;
183}
184
185STDMETHOD(appendData)(BSTR data)
186{
187        ATLTRACE(_T("IXMLDOMCharacterDataImpl::appendData\n"));
188
189        try
190        {
191                get_DOM_CharacterData().appendData(data);
192        }
193        catch(...)
194        {
195                return E_FAIL;
196        }
197       
198
199        return S_OK;
200}
201
202STDMETHOD(insertData)(long offset, BSTR data)
203{
204        ATLTRACE(_T("IXMLDOMCharacterDataImpl::insertData\n"));
205
206        try
207        {
208                get_DOM_CharacterData().insertData(offset, data);
209        }
210        catch(...)
211        {
212                return E_FAIL;
213        }
214       
215
216        return S_OK;
217}
218
219STDMETHOD(deleteData)(long offset, long count)
220{
221        ATLTRACE(_T("IXMLDOMCharacterDataImpl::deleteData\n"));
222
223        try
224        {
225                get_DOM_CharacterData().deleteData(offset, count);
226        }
227        catch(...)
228        {
229                return E_FAIL;
230        }
231       
232
233        return S_OK;
234}
235
236STDMETHOD(replaceData)(long offset, long count, BSTR data)
237{
238        ATLTRACE(_T("IXMLDOMCharacterDataImpl::replaceData\n"));
239
240        try
241        {
242                get_DOM_CharacterData().replaceData(offset, count, data);
243        }
244        catch(...)
245        {
246                return E_FAIL;
247        }
248       
249        return S_OK;
250}
251
252};
253
254#endif // ___ixmldomcharacterdataimpl_h___
Note: See TracBrowser for help on using the repository browser.