1 mike 1.1 //BEGIN_LICENSE
2 //
3 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 // DEALINGS IN THE SOFTWARE.
19 //
20 //END_LICENSE
21 //BEGIN_HISTORY
22 mike 1.1 //
23 // Author:
24 //
25 // $Log$
26 //
27 //END_HISTORY
28
29 ////////////////////////////////////////////////////////////////////////////////
30 //
31 // XmlWriter.h
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34
35 #ifndef Pegasus_XmlWriter_h
36 #define Pegasus_XmlWriter_h
37
38 #include <iostream>
39 #include <Pegasus/Common/Config.h>
40 #include <Pegasus/Common/Exception.h>
41 #include <Pegasus/Common/Array.h>
42 #include <Pegasus/Common/String.h>
43 mike 1.1 #include <Pegasus/Common/Indentor.h>
44
45 PEGASUS_NAMESPACE_BEGIN
46
47 class ConstQualifierDecl;
48 class ConstClassDecl;
49
50 class PEGASUS_COMMON_LINKAGE XmlWriter
51 {
52 public:
53
54 static void append(Array<Sint8>& out, Char16 x);
55
56 static void append(Array<Sint8>& out, char x)
57 {
58 append(out, Char16(x));
59 }
60
61 static void append(Array<Sint8>& out, const char* x);
62
63 static void append(Array<Sint8>& out, const String& x);
64 mike 1.1
65 static void append(Array<Sint8>& out, Uint32 x);
66
67 static void appendSpecial(Array<Sint8>& out, Char16 x);
68
69 static void appendSpecial(Array<Sint8>& out, char x);
70
71 static void appendSpecial(Array<Sint8>& out, const char* x);
72
73 static void appendSpecial(Array<Sint8>& out, const String& x);
74
75 static void append(Array<Sint8>& out, const Indentor& x);
76
77 static void appendLocalNameSpaceElement(
78 Array<Sint8>& out,
79 const String& nameSpace);
80
81 static void appendNameSpaceElement(
82 Array<Sint8>& out,
83 const String& nameSpace);
84
85 mike 1.1 static Array<Sint8> formatGetHeader(
86 const char* documentPath);
87
88 static Array<Sint8> formatMPostHeader(
89 const char* host,
90 const char* cimOperation,
91 const char* cimMethod,
92 const String& cimObject,
93 const Array<Sint8>& content);
94
95 static Array<Sint8> formatMethodResponseHeader(
96 const Array<Sint8>& content);
97
98 static Array<Sint8> formatMessageElement(
99 Uint32 messageId,
100 const Array<Sint8>& body);
101
102 static Array<Sint8> formatSimpleReqElement(
103 const Array<Sint8>& body);
104
105 static Array<Sint8> formatSimpleRspElement(
106 mike 1.1 const Array<Sint8>& body);
107
108 static Array<Sint8> formatIMethodCallElement(
109 const char* name,
110 const String& nameSpace,
111 const Array<Sint8>& iParamValues);
112
113 static Array<Sint8> formatIReturnValueElement(
114 const Array<Sint8>& body);
115
116 static Array<Sint8> formatIMethodResponseElement(
117 const char* name,
118 const Array<Sint8>& iParamValues);
119
120 static Array<Sint8>& formatIParamValueElement(
121 Array<Sint8>& out,
122 const char* name,
123 const Array<Sint8>& body);
124
125 static Array<Sint8> formatErrorElement(
126 CimException::Code code,
127 mike 1.1 const char* description);
128
129 static Array<Sint8>& appendBooleanParameter(
130 Array<Sint8>& out,
131 const char* parameterName,
132 Boolean flag);
133
134 static Array<Sint8>& appendClassNameParameter(
135 Array<Sint8>& out,
136 const char* parameterName,
137 const String& className);
138
139 static Array<Sint8>& appendQualifierNameParameter(
140 Array<Sint8>& out,
141 const char* parameterName,
142 const String& qualifierName);
143
144 static Array<Sint8>& appendClassParameter(
145 Array<Sint8>& out,
146 const char* parameterName,
147 const ConstClassDecl& classDecl);
148 mike 1.1
149 static Array<Sint8>& appendQualifierDeclarationParameter(
150 Array<Sint8>& out,
151 const char* parameterName,
152 const ConstQualifierDecl& qualifierDecl);
153
154 static Array<Sint8>& appendClassNameElement(
155 Array<Sint8>& out,
156 const String& className);
157
158 static void indentedPrint(
159 std::ostream& os,
160 const char* text,
161 Uint32 indentChars = 2);
162
163 static Array<Sint8> formatSimpleReqMessage(
164 const char* host,
165 const String& nameSpace,
166 const char* iMethodName,
167 const Array<Sint8>& body);
168
169 mike 1.1 static Array<Sint8> formatSimpleRspMessage(
170 const char* iMethodName,
171 const Array<Sint8>& body);
172
173 static Uint32 getNextMessageId();
174
175 private:
176
177 XmlWriter() { }
178 };
179
180 inline Array<Sint8>& operator<<(Array<Sint8>& out, const char* x)
181 {
182 XmlWriter::append(out, x);
183 return out;
184 }
185
186 inline Array<Sint8>& operator<<(Array<Sint8>& out, char x)
187 {
188 XmlWriter::append(out, x);
189 return out;
190 mike 1.1 }
191
192 inline Array<Sint8>& operator<<(Array<Sint8>& out, Char16 x)
193 {
194 XmlWriter::append(out, x);
195 return out;
196 }
197
198 inline Array<Sint8>& operator<<(Array<Sint8>& out, const String& x)
199 {
200 XmlWriter::append(out, x);
201 return out;
202 }
203
204 inline Array<Sint8>& operator<<(Array<Sint8>& out, const Indentor& x)
205 {
206 XmlWriter::append(out, x);
207 return out;
208 }
209
210 inline Array<Sint8>& operator<<(Array<Sint8>& out, const Array<Sint8>& x)
211 mike 1.1 {
212 out.appendArray(x);
213 return out;
214 }
215
216 inline Array<Sint8>& operator<<(Array<Sint8>& out, Uint32 x)
217 {
218 XmlWriter::append(out, x);
219 return out;
220 }
221
222 PEGASUS_NAMESPACE_END
223
224 #endif /* Pegasus_XmlWriter_h */
|