Xalan-C++ API Reference 1.12.0
MsgCreator.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#if !defined(MSG_CREATOR_1357924680)
20#define MSG_CREATOR_1357924680
21
23
24#include <xercesc/util/XMLString.hpp>
25
26
27#include <cstring>
28#include <cstdlib>
29
30#include <iostream>
31
32using namespace xercesc;
33
34// ---------------------------------------------------------------------------
35// This is a simple class that lets us do easy (though not terribly efficient)
36// trancoding of XMLCh data to local code page for display.
37// ---------------------------------------------------------------------------
38class StrX
39{
40public :
41 // -----------------------------------------------------------------------
42 // Constructors and Destructor
43 // -----------------------------------------------------------------------
44 StrX(const XMLCh* const toTranscode)
45 {
46 using xercesc::XMLString;
47
48 // Call the private transcoding method
49 fLocalForm = XMLString::transcode(toTranscode);
50 }
51
53 {
54 using xercesc::XMLString;
55
56 XMLString::release(&fLocalForm);
57 }
58
59 // -----------------------------------------------------------------------
60 // Getter methods
61 // -----------------------------------------------------------------------
62 const char* localForm() const
63 {
64 return fLocalForm;
65 }
66
67private :
68 // -----------------------------------------------------------------------
69 // Private data members
70 //
71 // fLocalForm
72 // This is the local code page form of the string.
73 // -----------------------------------------------------------------------
74 char* fLocalForm;
75};
76
77inline std::ostream& operator<<(std::ostream& target, const StrX& toDump)
78{
79 target << toDump.localForm();
80 return target;
81}
82
83
84#endif //MSG_CREATOR_1357924680
85
86
87
std::ostream & operator<<(std::ostream &target, const StrX &toDump)
const char * localForm() const
StrX(const XMLCh *const toTranscode)