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