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