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 karl 1.2.4.5 // This code implements part of PEP#348 - The CMPI infrastructure using SCMO
31 // (Single Chunk Memory Objects).
32 // The design document can be found on the OpenPegasus website openpegasus.org
33 // at https://collaboration.opengroup.org/pegasus/pp/documents/21210/PEP_348.pdf
34 //
|
35 thilo.boehm 1.2 //%/////////////////////////////////////////////////////////////////////////////
36
37 #ifndef Pegasus_SCMOXmlWriter_h
38 #define Pegasus_SCMOXmlWriter_h
39
40 #include <iostream>
41 #include <Pegasus/Common/Config.h>
42 #include <Pegasus/Common/XmlGenerator.h>
43 #include <Pegasus/Common/XmlWriter.h>
44 #include <Pegasus/Common/SCMO.h>
45 #include <Pegasus/Common/SCMOInstance.h>
46 #include <Pegasus/Common/CIMDateTimeInline.h>
47
48 PEGASUS_NAMESPACE_BEGIN
|
49 karl 1.2.4.2 typedef struct propertyFilterNodesArray_s
50 {
51 SCMBClass_Main* classPtrMemBlock;
52 Array<Uint32> nodes;
53 }propertyFilterNodesArray_t;
|
54 thilo.boehm 1.2
55 class PEGASUS_COMMON_LINKAGE SCMOXmlWriter : public XmlWriter
56 {
57 public:
|
58 karl 1.2.4.2 //This function is used to build the propertyFilter node array.
59 //this node array can be build once per class and reused for all
60 //instances.
61 static void buildPropertyFilterNodesArray(
62 Array<Uint32> & nodes,
63 const SCMOClass * classPtr,
64 const CIMPropertyList & propertyList);
65
66 //This function is used to get the propertyFilter node array.
67 static const Array<Uint32> & getFilteredNodesArray(
68 Array<propertyFilterNodesArray_t> & propFilterNodesArrays,
69 const SCMOInstance& scmoInstance,
70 const CIMPropertyList & propertyList);
|
71 thilo.boehm 1.2
72 static void appendValueSCMOInstanceElement(
73 Buffer& out,
|
74 karl 1.2.4.2 const SCMOInstance& scmoInstance,
75 bool filtered,
76 const Array<Uint32> & nodes);
77
78 static void appendValueSCMOInstanceElements(
79 Buffer& out,
80 const Array<SCMOInstance> & _scmoInstances,
81 const CIMPropertyList & propertyList);
|
82 thilo.boehm 1.2
|
83 karl 1.2.4.4 // EXP_PULL_BEGIN
|
84 karl 1.2.4.1 static void appendValueSCMOInstanceWithPathElement(
85 Buffer& out,
|
86 karl 1.2.4.2 const SCMOInstance& scmoInstance,
87 bool filtered,
88 const Array<Uint32> & nodes);
89
90 static void appendValueSCMOInstanceWithPathElements(
91 Buffer& out,
92 const Array<SCMOInstance> & _scmoInstances,
93 const CIMPropertyList & propertyList);
|
94 karl 1.2.4.4 //EXP_PULL_END
|
95 karl 1.2.4.1
|
96 thilo.boehm 1.2 static void appendInstanceNameElement(
97 Buffer& out,
98 const SCMOInstance& scmoInstance);
99
100 static void appendInstanceElement(
101 Buffer& out,
|
102 karl 1.2.4.2 const SCMOInstance& scmoInstance,
103 bool filtered,
104 const Array<Uint32> & nodes);
|
105 thilo.boehm 1.2
106 static void appendQualifierElement(
107 Buffer& out,
108 const SCMBQualifier& theQualifier,
109 const char* base);
110
111 static void appendPropertyElement(
112 Buffer& out,
113 const SCMOInstance& scmoInstance,
114 Uint32 pos);
115
116 static void appendValueElement(
117 Buffer& out,
118 const SCMBValue & value,
119 const char * base);
120
121 static void appendValueReferenceElement(
122 Buffer& out,
123 const SCMOInstance& ref,
124 Boolean putValueWrapper);
125
126 thilo.boehm 1.2 static void appendLocalInstancePathElement(
127 Buffer& out,
128 const SCMOInstance& instancePath);
129
130 static void appendInstancePathElement(
131 Buffer& out,
132 const SCMOInstance& instancePath);
|
133 karl 1.2.4.2
134 static void appendValueObjectWithPathElement(
135 Buffer& out,
136 const Array<SCMOInstance> & objectWithPath,
137 const CIMPropertyList& propertyList);
|
138 thilo.boehm 1.2
|
139 karl 1.2.4.3 //EXP_PULL_BEGIN
|
140 karl 1.2.4.1 static void appendValueInstanceWithPathElement(
141 Buffer& out,
|
142 karl 1.2.4.2 const SCMOInstance& namedInstance,
143 bool filtered,
144 const Array<Uint32> & nodes);
|
145 karl 1.2.4.3 //EXP_PULL_END
|
146 thilo.boehm 1.2 static void appendValueObjectWithPathElement(
147 Buffer& out,
|
148 karl 1.2.4.2 const SCMOInstance& objectWithPath,
149 bool filtered = false ,
150 const Array<Uint32> & nodes = Array<Uint32> (0));
|
151 thilo.boehm 1.2
152 static void appendObjectElement(
153 Buffer& out,
|
154 karl 1.2.4.2 const SCMOInstance& object,
155 bool filtered = false ,
156 const Array<Uint32> & nodes = Array<Uint32> (0));
157
|
158 thilo.boehm 1.2 static void appendClassElement(
159 Buffer& out,
160 const SCMOInstance& cimClass);
161
162 static void appendLocalClassPathElement(
163 Buffer& out,
164 const SCMOInstance& classPath);
165
166 static void appendClassPathElement(
167 Buffer& out,
168 const SCMOInstance& classPath);
169
170 static void appendSCMBUnion(
171 Buffer& out,
172 const SCMBUnion & u,
173 const CIMType & valueType,
174 const char * base);
175
176 static void appendSCMBUnionArray(
177 Buffer& out,
178 const SCMBUnion & u,
179 thilo.boehm 1.2 const CIMType & valueType,
180 Uint32 numElements,
181 const char * base);
182
183 private:
184 SCMOXmlWriter();
185
186 //------------------------------------------------------------------------------
187 //
188 // appendLocalNameSpacePathElement()
189 //
190 // <!ELEMENT LOCALNAMESPACEPATH (NAMESPACE+)>
191 //
192 //------------------------------------------------------------------------------
193 static void appendLocalNameSpacePathElement(
194 Buffer& out,
195 const char * nameSpace,
196 Uint32 nameSpaceLength)
197 {
198 // add one byte for the closing \0
199 nameSpaceLength++;
200 thilo.boehm 1.2 out << STRLIT("<LOCALNAMESPACEPATH>\n");
201
202 char fixed[64];
203 char* nameSpaceCopy;
204 if (nameSpaceLength > 64)
205 {
206 nameSpaceCopy=(char*)malloc(nameSpaceLength);
207 }
208 else
209 {
210 nameSpaceCopy = &(fixed[0]);
211 }
212 memcpy(nameSpaceCopy, nameSpace, nameSpaceLength);
213
214 #if !defined(PEGASUS_COMPILER_MSVC) && !defined(PEGASUS_OS_ZOS)
215 char *last;
216 for (const char* p = strtok_r(nameSpaceCopy, "/", &last); p;
217 p = strtok_r(NULL, "/", &last))
218 #else
219 for (const char* p = strtok(nameSpaceCopy, "/"); p;
220 p = strtok(NULL, "/"))
221 thilo.boehm 1.2 #endif
222 {
223 out << STRLIT("<NAMESPACE NAME=\"") << p << STRLIT("\"/>\n");
224 }
225 if (nameSpaceLength > 64)
226 {
227 free(nameSpaceCopy);
228 }
229 out << STRLIT("</LOCALNAMESPACEPATH>\n");
230 }
231
232 //------------------------------------------------------------------------------
233 //
234 // appendNameSpacePathElement()
235 //
236 // <!ELEMENT NAMESPACEPATH (HOST,LOCALNAMESPACEPATH)>
237 //
238 //------------------------------------------------------------------------------
239
240 static void appendNameSpacePathElement(
241 Buffer& out,
242 thilo.boehm 1.2 const char* host,
243 Uint32 hostLength,
244 const char * nameSpace,
245 Uint32 nameSpaceLength)
246 {
247 out << STRLIT("<NAMESPACEPATH>\n""<HOST>");
248 out.append(host, hostLength);
249 out << STRLIT("</HOST>\n");
250 appendLocalNameSpacePathElement(out, nameSpace, nameSpaceLength);
251 out << STRLIT("</NAMESPACEPATH>\n");
252 }
253
254 //------------------------------------------------------------------------------
255 // appendClassNameElement()
256 // <!ELEMENT CLASSNAME EMPTY>
257 // <!ATTLIST CLASSNAME
258 // %CIMName;>
259 //------------------------------------------------------------------------------
260 static void appendClassNameElement(
261 Buffer& out,
262 const char* className,
263 thilo.boehm 1.2 Uint32 classNameLength)
264 {
265 out << STRLIT("<CLASSNAME NAME=\"");
266 out.append(className, classNameLength);
267 out << STRLIT("\"/>\n");
268 }
269 };
270
271 PEGASUS_NAMESPACE_END
272
273 #endif /* Pegasus_SCMOXmlWriter_h */
|