1 mike 1.21 //%/////////////////////////////////////////////////////////////////////////////
2 //
|
3 mike 1.22 // Copyright (c) 2000, 2001 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
|
5 mike 1.21 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to
8 // deal in the Software without restriction, including without limitation the
9 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
14 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
15 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
16 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 //
22 //==============================================================================
23 //
24 // Author: Mike Brasher (mbrasher@bmc.com)
25 //
|
26 mike 1.22 // Modified By:
27 // Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
28 // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
29 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
30 kumpf 1.45 // Carol Ann Krug Graves, Hewlett-Packard Company
31 // (carolann_graves@hp.com)
|
32 mike 1.21 //
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 #include <Pegasus/Common/Indentor.h>
|
44 kumpf 1.41 #include <Pegasus/Common/CIMObject.h>
45 #include <Pegasus/Common/CIMClass.h>
46 #include <Pegasus/Common/CIMInstance.h>
47 #include <Pegasus/Common/CIMProperty.h>
48 #include <Pegasus/Common/CIMMethod.h>
49 #include <Pegasus/Common/CIMParameter.h>
50 #include <Pegasus/Common/CIMQualifier.h>
51 #include <Pegasus/Common/CIMQualifierDecl.h>
52 #include <Pegasus/Common/CIMValue.h>
|
53 kumpf 1.44 #include <Pegasus/Common/CIMObjectPath.h>
|
54 mike 1.22 #include <Pegasus/Common/CIMPropertyList.h>
|
55 kumpf 1.29 #include <Pegasus/Common/CIMParamValue.h>
|
56 mike 1.21
57 PEGASUS_NAMESPACE_BEGIN
58
59 class PEGASUS_COMMON_LINKAGE XmlWriter
60 {
61 public:
62
63 static void append(Array<Sint8>& out, Char16 x);
64
65 static void append(Array<Sint8>& out, char x)
66 {
67 append(out, Char16(x));
68 }
69
|
70 kumpf 1.39 static void append(Array<Sint8>& out, Boolean x);
71
|
72 kumpf 1.26 static void append(Array<Sint8>& out, Uint32 x);
73
|
74 kumpf 1.39 static void append(Array<Sint8>& out, Sint32 x);
75
76 static void append(Array<Sint8>& out, Uint64 x);
77
78 static void append(Array<Sint8>& out, Sint64 x);
79
80 static void append(Array<Sint8>& out, Real64 x);
81
|
82 kumpf 1.26 static void append(Array<Sint8>& out, const char* str);
|
83 mike 1.21
|
84 kumpf 1.26 static void append(Array<Sint8>& out, const String& str);
|
85 mike 1.21
|
86 kumpf 1.26 static void append(Array<Sint8>& out, const Indentor& x);
|
87 mike 1.21
88 static void appendSpecial(Array<Sint8>& out, Char16 x);
89
90 static void appendSpecial(Array<Sint8>& out, char x);
91
|
92 kumpf 1.26 static void appendSpecial(Array<Sint8>& out, const char* str);
|
93 mike 1.21
|
94 kumpf 1.26 static void appendSpecial(Array<Sint8>& out, const String& str);
|
95 mike 1.21
|
96 kumpf 1.28 static void appendLocalNameSpacePathElement(
|
97 mike 1.21 Array<Sint8>& out,
98 const String& nameSpace);
99
|
100 kumpf 1.28 static void appendNameSpacePathElement(
101 Array<Sint8>& out,
102 const String& host,
103 const String& nameSpace);
|
104 mike 1.21
|
105 kumpf 1.28 static void appendClassNameElement(
|
106 kumpf 1.26 Array<Sint8>& out,
|
107 kumpf 1.28 const String& className);
|
108 mike 1.21
|
109 kumpf 1.28 static void appendInstanceNameElement(
|
110 kumpf 1.26 Array<Sint8>& out,
|
111 kumpf 1.44 const CIMObjectPath& instanceName);
|
112 kumpf 1.26
|
113 kumpf 1.28 static void appendClassPathElement(
|
114 kumpf 1.26 Array<Sint8>& out,
|
115 kumpf 1.44 const CIMObjectPath& classPath);
|
116 mike 1.21
|
117 kumpf 1.28 static void appendInstancePathElement(
|
118 kumpf 1.26 Array<Sint8>& out,
|
119 kumpf 1.44 const CIMObjectPath& instancePath);
|
120 mike 1.21
|
121 kumpf 1.28 static void appendLocalClassPathElement(
|
122 kumpf 1.26 Array<Sint8>& out,
|
123 kumpf 1.44 const CIMObjectPath& classPath);
|
124 mike 1.21
|
125 kumpf 1.28 static void appendLocalInstancePathElement(
|
126 kumpf 1.26 Array<Sint8>& out,
|
127 kumpf 1.44 const CIMObjectPath& instancePath);
|
128 mike 1.21
|
129 kumpf 1.29 static void appendLocalObjectPathElement(
130 Array<Sint8>& out,
|
131 kumpf 1.44 const CIMObjectPath& objectPath);
|
132 kumpf 1.39
133 static void appendValueElement(
134 Array<Sint8>& out,
135 const CIMValue& value);
136
137 static void printValueElement(
138 const CIMValue& value,
139 PEGASUS_STD(ostream)& os=PEGASUS_STD(cout));
|
140 kumpf 1.29
|
141 kumpf 1.41 static void appendValueObjectWithPathElement(
142 Array<Sint8>& out,
143 const CIMObjectWithPath& objectWithPath);
144
145 static void appendValueReferenceElement(
146 Array<Sint8>& out,
|
147 kumpf 1.44 const CIMObjectPath& reference,
|
148 kumpf 1.41 Boolean putValueWrapper);
149
150 static void printValueReferenceElement(
|
151 kumpf 1.44 const CIMObjectPath& reference,
|
152 kumpf 1.41 PEGASUS_STD(ostream)& os=PEGASUS_STD(cout));
153
154 static void appendValueNamedInstanceElement(
155 Array<Sint8>& out,
|
156 kumpf 1.45 const CIMInstance& namedInstance);
|
157 kumpf 1.41
|
158 kumpf 1.40 static void appendClassElement(
159 Array<Sint8>& out,
160 const CIMConstClass& cimclass);
161
162 static void printClassElement(
163 const CIMConstClass& cimclass,
164 PEGASUS_STD(ostream)& os=PEGASUS_STD(cout));
165
166 static void appendInstanceElement(
167 Array<Sint8>& out,
168 const CIMConstInstance& instance);
169
170 static void printInstanceElement(
171 const CIMConstInstance& instance,
|
172 kumpf 1.41 PEGASUS_STD(ostream)& os=PEGASUS_STD(cout));
173
174 static void appendObjectElement(
175 Array<Sint8>& out,
176 const CIMConstObject& object);
177
178 static void appendPropertyElement(
179 Array<Sint8>& out,
180 const CIMConstProperty& property);
181
182 static void printPropertyElement(
183 const CIMConstProperty& property,
184 PEGASUS_STD(ostream)& os=PEGASUS_STD(cout));
185
186 static void appendMethodElement(
187 Array<Sint8>& out,
188 const CIMConstMethod& method);
189
190 static void printMethodElement(
191 const CIMConstMethod& method,
192 PEGASUS_STD(ostream)& os=PEGASUS_STD(cout));
193 kumpf 1.41
194 static void appendParameterElement(
195 Array<Sint8>& out,
196 const CIMConstParameter& parameter);
197
198 static void printParameterElement(
199 const CIMConstParameter& parameter,
200 PEGASUS_STD(ostream)& os=PEGASUS_STD(cout));
201
202 static void appendParamValueElement(
203 Array<Sint8>& out,
204 const CIMParamValue& paramValue);
205
206 static void printParamValueElement(
207 const CIMParamValue& paramValue,
208 PEGASUS_STD(ostream)& os=PEGASUS_STD(cout));
209
210 static void appendQualifierElement(
211 Array<Sint8>& out,
212 const CIMConstQualifier& qualifier);
213
214 kumpf 1.41 static void printQualifierElement(
215 const CIMConstQualifier& qualifier,
216 PEGASUS_STD(ostream)& os=PEGASUS_STD(cout));
217
218 static void appendQualifierDeclElement(
219 Array<Sint8>& out,
220 const CIMConstQualifierDecl& qualifierDecl);
221
222 static void printQualifierDeclElement(
223 const CIMConstQualifierDecl& qualifierDecl,
|
224 kumpf 1.40 PEGASUS_STD(ostream)& os=PEGASUS_STD(cout));
225
|
226 kumpf 1.42 static void appendQualifierFlavorEntity(
227 Array<Sint8>& out,
228 Uint32 flavor);
229
|
230 kumpf 1.43 static void appendScopeElement(
231 Array<Sint8>& out,
232 Uint32 scope);
233
|
234 kumpf 1.28 static void appendMethodCallHeader(
|
235 kumpf 1.26 Array<Sint8>& out,
|
236 kumpf 1.28 const char* host,
237 const char* cimMethod,
238 const String& cimObject,
239 const String& authenticationHeader,
240 Uint32 contentLength);
|
241 mike 1.21
|
242 kumpf 1.28 static void appendMethodResponseHeader(
|
243 mike 1.21 Array<Sint8>& out,
|
244 kumpf 1.28 Uint32 contentLength);
|
245 mike 1.21
|
246 kumpf 1.34 static void appendHttpErrorResponseHeader(
247 Array<Sint8>& out,
248 const String& status,
249 const String& cimError = String::EMPTY,
|
250 kumpf 1.35 const String& errorDetail = String::EMPTY);
|
251 kumpf 1.34
|
252 kumpf 1.28 static void appendUnauthorizedResponseHeader(
|
253 kumpf 1.26 Array<Sint8>& out,
|
254 kumpf 1.28 const String& content);
|
255 mike 1.21
|
256 kumpf 1.26 static void appendReturnValueElement(
257 Array<Sint8>& out,
258 const CIMValue& value);
259
260 static void appendBooleanIParameter(
|
261 mike 1.21 Array<Sint8>& out,
|
262 kumpf 1.26 const char* name,
|
263 mike 1.21 Boolean flag);
264
|
265 kumpf 1.26 static void appendStringIParameter(
|
266 mike 1.21 Array<Sint8>& out,
|
267 kumpf 1.26 const char* name,
|
268 mike 1.21 const String& str);
269
|
270 kumpf 1.26 static void appendQualifierNameIParameter(
271 Array<Sint8>& out,
272 const char* name,
273 const String& qualifierName);
274
275 static void appendClassNameIParameter(
|
276 mike 1.21 Array<Sint8>& out,
|
277 kumpf 1.26 const char* name,
|
278 mike 1.21 const String& className);
279
|
280 kumpf 1.26 static void appendInstanceNameIParameter(
|
281 mike 1.21 Array<Sint8>& out,
|
282 kumpf 1.26 const char* name,
|
283 kumpf 1.44 const CIMObjectPath& instanceName);
|
284 mike 1.21
|
285 kumpf 1.26 static void appendObjectNameIParameter(
|
286 mike 1.21 Array<Sint8>& out,
|
287 kumpf 1.26 const char* name,
|
288 kumpf 1.44 const CIMObjectPath& objectName);
|
289 mike 1.21
|
290 kumpf 1.26 static void appendClassIParameter(
|
291 mike 1.21 Array<Sint8>& out,
|
292 kumpf 1.26 const char* name,
293 const CIMConstClass& cimClass);
|
294 mike 1.21
|
295 kumpf 1.26 static void appendInstanceIParameter(
|
296 mike 1.21 Array<Sint8>& out,
|
297 kumpf 1.26 const char* name,
|
298 mike 1.21 const CIMConstInstance& instance);
299
|
300 kumpf 1.26 static void appendNamedInstanceIParameter(
|
301 mike 1.22 Array<Sint8>& out,
|
302 kumpf 1.26 const char* name,
|
303 mday 1.46 const CIMInstance& namedInstance) ;
|
304 mike 1.22
|
305 kumpf 1.26 static void appendPropertyNameIParameter(
|
306 mike 1.21 Array<Sint8>& out,
|
307 kumpf 1.26 const String& propertyName);
|
308 mike 1.21
|
309 kumpf 1.26 static void appendPropertyValueIParameter(
|
310 mike 1.21 Array<Sint8>& out,
|
311 kumpf 1.26 const char* name,
312 const CIMValue& value);
|
313 mike 1.21
|
314 kumpf 1.26 static void appendPropertyListIParameter(
|
315 mike 1.21 Array<Sint8>& out,
|
316 kumpf 1.26 const CIMPropertyList& propertyList);
|
317 mike 1.21
|
318 kumpf 1.26 static void appendQualifierDeclarationIParameter(
|
319 mike 1.21 Array<Sint8>& out,
|
320 kumpf 1.26 const char* name,
321 const CIMConstQualifierDecl& qualifierDecl);
|
322 kumpf 1.34
323 static Array<Sint8> formatHttpErrorRspMessage(
324 const String& status,
325 const String& cimError = String::EMPTY,
|
326 kumpf 1.35 const String& errorDetail = String::EMPTY);
|
327 mike 1.21
|
328 kumpf 1.26 static Array<Sint8> formatSimpleMethodReqMessage(
329 const char* host,
|
330 kumpf 1.33 const String& nameSpace,
|
331 kumpf 1.44 const CIMObjectPath& path,
|
332 kumpf 1.26 const char* methodName,
|
333 kumpf 1.29 const Array<CIMParamValue>& parameters,
|
334 kumpf 1.26 const String& messageId,
|
335 kumpf 1.29 const String& authenticationHeader);
|
336 mike 1.21
|
337 kumpf 1.26 static Array<Sint8> formatSimpleMethodRspMessage(
338 const char* methodName,
339 const String& messageId,
340 const Array<Sint8>& body);
|
341 mike 1.21
|
342 kumpf 1.27 static Array<Sint8> formatSimpleMethodErrorRspMessage(
343 const String& methodName,
344 const String& messageId,
|
345 kumpf 1.36 const CIMException& cimException);
|
346 kumpf 1.27
|
347 mike 1.22 static Array<Sint8> formatSimpleIMethodReqMessage(
|
348 mike 1.21 const char* host,
349 const String& nameSpace,
350 const char* iMethodName,
|
351 mike 1.22 const String& messageId,
352 const String& authenticationHeader,
|
353 mike 1.21 const Array<Sint8>& body);
354
|
355 kumpf 1.26 static Array<Sint8> formatSimpleIMethodRspMessage(
|
356 mike 1.21 const char* iMethodName,
357 const String& messageId,
358 const Array<Sint8>& body);
359
|
360 kumpf 1.27 static Array<Sint8> formatSimpleIMethodErrorRspMessage(
361 const String& iMethodName,
|
362 mike 1.22 const String& messageId,
|
363 kumpf 1.36 const CIMException& cimException);
|
364 mike 1.22
|
365 kumpf 1.26 static void appendEMethodRequestHeader(
366 Array<Sint8>& out,
|
367 kumpf 1.38 const char* requestUri,
|
368 mike 1.22 const char* host,
369 const char* cimMethod,
370 const String& authenticationHeader,
|
371 kumpf 1.26 Uint32 contentLength);
|
372 mike 1.22
|
373 kumpf 1.26 static void appendEMethodResponseHeader(
374 Array<Sint8>& out,
375 Uint32 contentLength);
|
376 mike 1.22
|
377 kumpf 1.26 static Array<Sint8> formatSimpleEMethodReqMessage(
|
378 kumpf 1.38 const char* requestUri,
|
379 mike 1.22 const char* host,
|
380 kumpf 1.26 const char* eMethodName,
|
381 mike 1.22 const String& messageId,
|
382 kumpf 1.26 const String& authenticationHeader,
|
383 mike 1.22 const Array<Sint8>& body);
384
|
385 kumpf 1.26 static Array<Sint8> formatSimpleEMethodRspMessage(
386 const char* eMethodName,
|
387 mike 1.22 const String& messageId,
388 const Array<Sint8>& body);
|
389 kumpf 1.27
390 static Array<Sint8> formatSimpleEMethodErrorRspMessage(
391 const String& eMethodName,
392 const String& messageId,
|
393 kumpf 1.36 const CIMException& cimException);
|
394 mike 1.22
|
395 kumpf 1.26 static void indentedPrint(
396 PEGASUS_STD(ostream)& os,
397 const char* text,
398 Uint32 indentChars = 2);
|
399 mike 1.22
|
400 kumpf 1.26 static String getNextMessageId();
|
401 mike 1.21
402 private:
|
403 kumpf 1.28
404 static void _appendMessageElementBegin(
405 Array<Sint8>& out,
406 const String& messageId);
407 static void _appendMessageElementEnd(
408 Array<Sint8>& out);
409
410 static void _appendSimpleReqElementBegin(Array<Sint8>& out);
411 static void _appendSimpleReqElementEnd(Array<Sint8>& out);
412
413 static void _appendMethodCallElementBegin(
414 Array<Sint8>& out,
415 const char* name);
416 static void _appendMethodCallElementEnd(
417 Array<Sint8>& out);
418
419 static void _appendIMethodCallElementBegin(
420 Array<Sint8>& out,
421 const char* name);
422 static void _appendIMethodCallElementEnd(
423 Array<Sint8>& out);
424 kumpf 1.28
425 static void _appendIParamValueElementBegin(
426 Array<Sint8>& out,
427 const char* name);
428 static void _appendIParamValueElementEnd(
429 Array<Sint8>& out);
430
431 static void _appendSimpleRspElementBegin(Array<Sint8>& out);
432 static void _appendSimpleRspElementEnd(Array<Sint8>& out);
433
434 static void _appendMethodResponseElementBegin(
435 Array<Sint8>& out,
436 const char* name);
437 static void _appendMethodResponseElementEnd(
438 Array<Sint8>& out);
439
440 static void _appendIMethodResponseElementBegin(
441 Array<Sint8>& out,
442 const char* name);
443 static void _appendIMethodResponseElementEnd(
444 Array<Sint8>& out);
445 kumpf 1.28
446 static void _appendErrorElement(
447 Array<Sint8>& out,
|
448 kumpf 1.36 const CIMException& cimException);
|
449 kumpf 1.28
450 static void _appendIReturnValueElementBegin(Array<Sint8>& out);
451 static void _appendIReturnValueElementEnd(Array<Sint8>& out);
452
453 static void _appendSimpleExportReqElementBegin(Array<Sint8>& out);
454 static void _appendSimpleExportReqElementEnd(Array<Sint8>& out);
455
456 static void _appendEMethodCallElementBegin(
457 Array<Sint8>& out,
458 const char* name);
459 static void _appendEMethodCallElementEnd(
460 Array<Sint8>& out);
461
462 static void _appendSimpleExportRspElementBegin(Array<Sint8>& out);
463 static void _appendSimpleExportRspElementEnd(Array<Sint8>& out);
464
465 static void _appendEMethodResponseElementBegin(
466 Array<Sint8>& out,
467 const char* name);
468 static void _appendEMethodResponseElementEnd(
469 Array<Sint8>& out);
|
470 mike 1.21
471 XmlWriter() { }
472 };
473
474 PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<(
475 Array<Sint8>& out,
476 const char* x);
477
478 PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<(Array<Sint8>& out, char x);
479
480 PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<(Array<Sint8>& out, Char16 x);
481
482 PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<(
483 Array<Sint8>& out,
484 const String& x);
485
486 PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<(
487 Array<Sint8>& out,
488 const Indentor& x);
489
490 PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<(
491 mike 1.21 Array<Sint8>& out,
492 const Array<Sint8>& x);
493
494 PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<(
495 Array<Sint8>& out,
496 Uint32 x);
497
498 PEGASUS_NAMESPACE_END
499
500 #endif /* Pegasus_XmlWriter_h */
|