(file) Return to SCMOXmlWriter.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  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.2     static void appendValueSCMOInstanceWithPathElements(
 85                             Buffer& out,
 86                             const Array<SCMOInstance> & _scmoInstances,
 87                             const CIMPropertyList & propertyList);
 88 karl        1.2.4.4     //EXP_PULL_END
 89 karl        1.2.4.1 
 90 thilo.boehm 1.2         static void appendInstanceNameElement(
 91                             Buffer& out,
 92                             const SCMOInstance& scmoInstance);
 93                     
 94                         static void appendInstanceElement(
 95                             Buffer& out,
 96 karl        1.2.4.2         const SCMOInstance& scmoInstance,
 97                             bool filtered, 
 98                             const Array<Uint32> & nodes); 
 99 thilo.boehm 1.2     
100                         static void appendQualifierElement(
101                             Buffer& out,
102                             const SCMBQualifier& theQualifier,
103                             const char* base);
104                     
105                         static void appendPropertyElement(
106                             Buffer& out,
107                             const SCMOInstance& scmoInstance,
108                             Uint32 pos);
109                     
110                         static void appendValueElement(
111                             Buffer& out,
112                             const SCMBValue & value,
113                             const char * base);
114                     
115                         static void appendValueReferenceElement(
116                             Buffer& out,
117                             const SCMOInstance& ref,
118                             Boolean putValueWrapper);
119                     
120 thilo.boehm 1.2         static void appendLocalInstancePathElement(
121                             Buffer& out,
122                             const SCMOInstance& instancePath);
123                     
124                         static void appendInstancePathElement(
125                             Buffer& out,
126                             const SCMOInstance& instancePath);
127 karl        1.2.4.2    
128                         static void appendValueObjectWithPathElement(
129                             Buffer& out,
130                             const Array<SCMOInstance> & objectWithPath,
131                             const CIMPropertyList& propertyList);
132 thilo.boehm 1.2     
133 karl        1.2.4.3 //EXP_PULL_BEGIN
134 karl        1.2.4.1     static void appendValueInstanceWithPathElement(
135                             Buffer& out,
136 karl        1.2.4.2         const SCMOInstance& namedInstance,
137                             bool filtered, 
138                             const Array<Uint32> & nodes);
139 karl        1.2.4.3 //EXP_PULL_END
140 thilo.boehm 1.2         static void appendValueObjectWithPathElement(
141                             Buffer& out,
142 karl        1.2.4.2         const SCMOInstance& objectWithPath,
143                             bool filtered = false ,
144                             const Array<Uint32> & nodes = Array<Uint32> (0));
145 thilo.boehm 1.2     
146                         static void appendObjectElement(
147                             Buffer& out,
148 karl        1.2.4.2         const SCMOInstance& object,
149                             bool filtered = false ,
150                             const Array<Uint32> & nodes = Array<Uint32> (0));
151                         
152 thilo.boehm 1.2         static void appendClassElement(
153                             Buffer& out,
154                             const SCMOInstance& cimClass);
155                     
156                         static void appendLocalClassPathElement(
157                             Buffer& out,
158                             const SCMOInstance& classPath);
159                     
160                         static void appendClassPathElement(
161                             Buffer& out,
162                             const SCMOInstance& classPath);
163                     
164                         static void appendSCMBUnion(
165                             Buffer& out,
166                             const SCMBUnion & u,
167                             const CIMType & valueType,
168                             const char * base);
169                     
170                         static void appendSCMBUnionArray(
171                             Buffer& out,
172                             const SCMBUnion & u,
173 thilo.boehm 1.2             const CIMType & valueType,
174                             Uint32 numElements,
175                             const char * base);
176                     
177                     private:
178                         SCMOXmlWriter();
179                     
180                     //------------------------------------------------------------------------------
181                     //
182                     // appendLocalNameSpacePathElement()
183                     //
184                     //     <!ELEMENT LOCALNAMESPACEPATH (NAMESPACE+)>
185                     //
186                     //------------------------------------------------------------------------------
187                         static void appendLocalNameSpacePathElement(
188                             Buffer& out,
189                             const char * nameSpace,
190                             Uint32 nameSpaceLength)
191                         {
192                             // add one byte for the closing \0
193                             nameSpaceLength++;
194 thilo.boehm 1.2             out << STRLIT("<LOCALNAMESPACEPATH>\n");
195                     
196                             char fixed[64];
197                             char* nameSpaceCopy;
198                             if (nameSpaceLength > 64)
199                             {
200                                 nameSpaceCopy=(char*)malloc(nameSpaceLength);
201                             }
202                             else
203                             {
204                                 nameSpaceCopy = &(fixed[0]);
205                             }
206                             memcpy(nameSpaceCopy, nameSpace, nameSpaceLength);
207                     
208                     #if !defined(PEGASUS_COMPILER_MSVC) && !defined(PEGASUS_OS_ZOS)
209                             char *last;
210                             for (const char* p = strtok_r(nameSpaceCopy, "/", &last); p;
211                                 p = strtok_r(NULL, "/", &last))
212                     #else
213                             for (const char* p = strtok(nameSpaceCopy, "/"); p;
214                                 p = strtok(NULL, "/"))
215 thilo.boehm 1.2     #endif
216                             {
217                                 out << STRLIT("<NAMESPACE NAME=\"") << p << STRLIT("\"/>\n");
218                             }
219                             if (nameSpaceLength > 64)
220                             {
221                                 free(nameSpaceCopy);
222                             }
223                             out << STRLIT("</LOCALNAMESPACEPATH>\n");
224                         }
225                     
226                     //------------------------------------------------------------------------------
227                     //
228                     // appendNameSpacePathElement()
229                     //
230                     //     <!ELEMENT NAMESPACEPATH (HOST,LOCALNAMESPACEPATH)>
231                     //
232                     //------------------------------------------------------------------------------
233                     
234                         static void appendNameSpacePathElement(
235                             Buffer& out,
236 thilo.boehm 1.2             const char* host,
237                             Uint32 hostLength,
238                             const char * nameSpace,
239                             Uint32 nameSpaceLength)
240                         {
241                             out << STRLIT("<NAMESPACEPATH>\n""<HOST>");
242                             out.append(host, hostLength);
243                             out << STRLIT("</HOST>\n");
244                             appendLocalNameSpacePathElement(out, nameSpace, nameSpaceLength);
245                             out << STRLIT("</NAMESPACEPATH>\n");
246                         }
247                     
248                     //------------------------------------------------------------------------------
249                     // appendClassNameElement()
250                     //     <!ELEMENT CLASSNAME EMPTY>
251                     //     <!ATTLIST CLASSNAME
252                     //              %CIMName;>
253                     //------------------------------------------------------------------------------
254                         static void appendClassNameElement(
255                             Buffer& out,
256                             const char* className,
257 thilo.boehm 1.2             Uint32 classNameLength)
258                         {
259                             out << STRLIT("<CLASSNAME NAME=\"");
260                             out.append(className, classNameLength);
261                             out << STRLIT("\"/>\n");
262                         }
263                     };
264                     
265                     PEGASUS_NAMESPACE_END
266                     
267                     #endif /* Pegasus_SCMOXmlWriter_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2