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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2