1 thilo.boehm 1.2 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 thilo.boehm 1.2 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //////////////////////////////////////////////////////////////////////////
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32
33 #include "CIMInternalXmlEncoder.h"
34 #include "XmlWriter.h"
35
36 PEGASUS_NAMESPACE_BEGIN
37
38 void CIMInternalXmlEncoder::_putXMLInstance(
39 CIMBuffer& out,
|
40 anusha.kandepu 1.3 const CIMInstance& ci,
41 Boolean includeQualifiers,
42 Boolean includeClassOrigin,
43 const CIMPropertyList& propertyList)
|
44 thilo.boehm 1.2 {
45 if (ci.isUninitialized())
46 {
47 out.putUint32(0);
48 out.putUint32(0);
49 out.putString(String());
50 out.putNamespaceName(CIMNamespaceName());
51 }
52 else
53 {
54 Buffer buf(4096);
55
56 // Serialize instance as XML.
57 {
|
58 anusha.kandepu 1.3 XmlWriter::appendInstanceElement(
59 buf,
60 ci,
61 includeQualifiers,
62 includeClassOrigin,
63 propertyList);
|
64 thilo.boehm 1.2 buf.append('\0');
65
66 out.putUint32(buf.size());
67 out.putBytes(buf.getData(), buf.size());
68 buf.clear();
69 }
70
71 // Serialize object path as XML.
72
73 const CIMObjectPath& cop = ci.getPath();
74
75 if (cop.getClassName().isNull())
76 {
77 out.putUint32(0);
78 out.putString(String());
79 out.putNamespaceName(CIMNamespaceName());
80 }
81 else
82 {
|
83 karl 1.4 // add ValueReferenceElement with VALUE.REFERENCE as instancePath
84 // and with VALUE.REFERENCE wrapper
85 XmlWriter::appendValueReferenceElement(buf, cop, false, true);
|
86 thilo.boehm 1.2 buf.append('\0');
87
88 out.putUint32(buf.size());
89 out.putBytes(buf.getData(), buf.size());
90 out.putString(cop.getHost());
91 out.putNamespaceName(cop.getNameSpace());
92 }
93 }
94 }
95
96 void CIMInternalXmlEncoder::_putXMLNamedInstance(
97 CIMBuffer& out,
|
98 anusha.kandepu 1.3 const CIMInstance& ci,
99 Boolean includeQualifiers,
100 Boolean includeClassOrigin,
101 const CIMPropertyList& propertyList)
|
102 thilo.boehm 1.2 {
103 if (ci.isUninitialized())
104 {
105 out.putUint32(0);
106 out.putUint32(0);
107 out.putString(String());
108 out.putNamespaceName(CIMNamespaceName());
109 }
110 else
111 {
112 Buffer buf(4096);
113
114 // Serialize instance as XML.
115 {
|
116 anusha.kandepu 1.3 XmlWriter::appendInstanceElement(
117 buf,
118 ci,
119 includeQualifiers,
120 includeClassOrigin,
121 propertyList);
|
122 thilo.boehm 1.2 buf.append('\0');
123
124 out.putUint32(buf.size());
125 out.putBytes(buf.getData(), buf.size());
126 buf.clear();
127 }
128
129 // Serialize object path as XML.
130
131 const CIMObjectPath& cop = ci.getPath();
132
133 if (cop.getClassName().isNull())
134 {
135 out.putUint32(0);
136 out.putString(String());
137 out.putNamespaceName(CIMNamespaceName());
138 }
139 else
140 {
141 XmlWriter::appendInstanceNameElement(buf, cop);
142 buf.append('\0');
143 thilo.boehm 1.2
144 out.putUint32(buf.size());
145 out.putBytes(buf.getData(), buf.size());
146 out.putString(cop.getHost());
147 out.putNamespaceName(cop.getNameSpace());
148 }
149 }
150 }
151
152 void CIMInternalXmlEncoder::_putXMLObject(
153 CIMBuffer& out,
|
154 anusha.kandepu 1.3 const CIMObject& co,
155 Boolean includeQualifiers,
156 Boolean includeClassOrigin,
157 const CIMPropertyList& propertyList)
|
158 thilo.boehm 1.2 {
159 if (co.isUninitialized())
160 {
161 out.putUint32(0);
162 out.putUint32(0);
163 out.putString(String());
164 out.putNamespaceName(CIMNamespaceName());
165 }
166 else
167 {
168 Buffer buf(4096);
169
170 // Serialize instance as XML.
171 {
|
172 anusha.kandepu 1.3 XmlWriter::appendObjectElement(
173 buf,
174 co,
175 includeQualifiers,
176 includeClassOrigin,
177 propertyList);
|
178 thilo.boehm 1.2 buf.append('\0');
179
180 out.putUint32(buf.size());
181 out.putBytes(buf.getData(), buf.size());
182 buf.clear();
183 }
184
185 // Serialize object path as XML.
186
187 const CIMObjectPath& cop = co.getPath();
188
189 if (cop.getClassName().isNull())
190 {
191 out.putUint32(0);
192 out.putString(String());
193 out.putNamespaceName(CIMNamespaceName());
194 }
195 else
196 {
197 _appendValueReferenceElement(buf, cop);
198 buf.append('\0');
199 thilo.boehm 1.2
200 out.putUint32(buf.size());
201 out.putBytes(buf.getData(), buf.size());
202 out.putString(cop.getHost());
203 out.putNamespaceName(cop.getNameSpace());
204 }
205 }
206 }
207
208
|
209 karl 1.4 // Calls appendInstanceName the other calls appendValueReference
210 // This is a shortcut function that puts VALUE.REFERENCE around
211 // InstanceNameElement directly. It bypasses host and namespace components
212 // and assumes that it is an instance. Note mechanisms above to add
213 // host and namespace info different per function
|
214 thilo.boehm 1.2 void CIMInternalXmlEncoder::_appendValueReferenceElement(
215 Buffer& out,
216 const CIMObjectPath& reference)
217 {
218 out << STRLIT("<VALUE.REFERENCE>\n");
219
220 XmlWriter::appendInstanceNameElement(out, reference);
221
222 out << STRLIT("</VALUE.REFERENCE>\n");
223 }
224
225 PEGASUS_NAMESPACE_END
|