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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2