1 | /*
|
---|
2 | * Copyright 1999-2000,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 | * $Log: SAX2Count.hpp,v $
|
---|
19 | * Revision 1.6 2004/09/08 13:55:33 peiyongz
|
---|
20 | * Apache License Version 2.0
|
---|
21 | *
|
---|
22 | * Revision 1.5 2003/05/30 09:36:36 gareth
|
---|
23 | * Use new macros for iostream.h and std:: issues.
|
---|
24 | *
|
---|
25 | * Revision 1.4 2003/02/05 18:53:23 tng
|
---|
26 | * [Bug 11915] Utility for freeing memory.
|
---|
27 | *
|
---|
28 | * Revision 1.3 2002/02/01 22:38:52 peiyongz
|
---|
29 | * sane_include
|
---|
30 | *
|
---|
31 | * Revision 1.2 2000/08/09 22:40:15 jpolast
|
---|
32 | * updates for changes to sax2 core functionality.
|
---|
33 | *
|
---|
34 | * Revision 1.1 2000/08/08 17:17:20 jpolast
|
---|
35 | * initial checkin of SAX2Count
|
---|
36 | *
|
---|
37 | *
|
---|
38 | */
|
---|
39 |
|
---|
40 |
|
---|
41 | // ---------------------------------------------------------------------------
|
---|
42 | // Includes for all the program files to see
|
---|
43 | // ---------------------------------------------------------------------------
|
---|
44 |
|
---|
45 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
46 | #include <stdlib.h>
|
---|
47 | #include <string.h>
|
---|
48 | #if defined(XERCES_NEW_IOSTREAMS)
|
---|
49 | #include <iostream>
|
---|
50 | #else
|
---|
51 | #include <iostream.h>
|
---|
52 | #endif
|
---|
53 | #include "SAX2CountHandlers.hpp"
|
---|
54 | #include <xercesc/sax2/XMLReaderFactory.hpp>
|
---|
55 | #include <xercesc/sax2/SAX2XMLReader.hpp>
|
---|
56 |
|
---|
57 |
|
---|
58 | // ---------------------------------------------------------------------------
|
---|
59 | // This is a simple class that lets us do easy (though not terribly efficient)
|
---|
60 | // trancoding of XMLCh data to local code page for display.
|
---|
61 | // ---------------------------------------------------------------------------
|
---|
62 | class StrX
|
---|
63 | {
|
---|
64 | public :
|
---|
65 | // -----------------------------------------------------------------------
|
---|
66 | // Constructors and Destructor
|
---|
67 | // -----------------------------------------------------------------------
|
---|
68 | StrX(const XMLCh* const toTranscode)
|
---|
69 | {
|
---|
70 | // Call the private transcoding method
|
---|
71 | fLocalForm = XMLString::transcode(toTranscode);
|
---|
72 | }
|
---|
73 |
|
---|
74 | ~StrX()
|
---|
75 | {
|
---|
76 | XMLString::release(&fLocalForm);
|
---|
77 | }
|
---|
78 |
|
---|
79 | // -----------------------------------------------------------------------
|
---|
80 | // Getter methods
|
---|
81 | // -----------------------------------------------------------------------
|
---|
82 | const char* localForm() const
|
---|
83 | {
|
---|
84 | return fLocalForm;
|
---|
85 | }
|
---|
86 |
|
---|
87 | private :
|
---|
88 | // -----------------------------------------------------------------------
|
---|
89 | // Private data members
|
---|
90 | //
|
---|
91 | // fLocalForm
|
---|
92 | // This is the local code page form of the string.
|
---|
93 | // -----------------------------------------------------------------------
|
---|
94 | char* fLocalForm;
|
---|
95 | };
|
---|
96 |
|
---|
97 | inline XERCES_STD_QUALIFIER ostream& operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
|
---|
98 | {
|
---|
99 | target << toDump.localForm();
|
---|
100 | return target;
|
---|
101 | }
|
---|