source: NonGTP/Xerces/xerces/samples/PSVIWriter/PSVIWriter.hpp @ 358

Revision 358, 2.7 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2003,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18#if !defined(PSVIWRITER_HPP)
19#define PSVIWRITER_HPP
20
21// ---------------------------------------------------------------------------
22//  Includes for all the program files to see
23// ---------------------------------------------------------------------------
24
25#include "PSVIWriterHandlers.hpp"
26#include <stdlib.h>
27#include <string.h>
28#include <xercesc/util/PlatformUtils.hpp>
29#include <xercesc/util/XMLUni.hpp>
30#include <xercesc/sax2/XMLReaderFactory.hpp>
31#include <xercesc/sax2/SAX2XMLReader.hpp>
32#if defined(XERCES_NEW_IOSTREAMS)
33#include <iostream>
34#else
35#include <iostream.h>
36#endif
37
38
39// ---------------------------------------------------------------------------
40//  This is a simple class that lets us do easy (though not terribly efficient)
41//  trancoding of XMLCh data to local code page for display.
42// ---------------------------------------------------------------------------
43class StrX
44{
45public :
46    // -----------------------------------------------------------------------
47    //  Constructors and Destructor
48    // -----------------------------------------------------------------------
49    StrX(const XMLCh* const toTranscode)
50    {
51        // Call the private transcoding method
52        fLocalForm = XMLString::transcode(toTranscode);
53    }
54
55    ~StrX()
56    {
57        XMLString::release(&fLocalForm);
58    }
59
60    // -----------------------------------------------------------------------
61    //  Getter methods
62    // -----------------------------------------------------------------------
63    const char* localForm() const
64    {
65        return fLocalForm;
66    }
67
68private :
69    // -----------------------------------------------------------------------
70    //  Private data members
71    //
72    //  fLocalForm
73    //      This is the local code page form of the string.
74    // -----------------------------------------------------------------------
75    char*   fLocalForm;
76};
77
78inline XERCES_STD_QUALIFIER ostream& operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
79{
80    target << toDump.localForm();
81    return target;
82}
83
84#endif
Note: See TracBrowser for help on using the repository browser.