(file) Return to CIMInternalXmlEncoder.cpp 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                 
 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                                XmlWriter::appendValueReferenceElement(buf, cop, true);
 84                                buf.append('\0');
 85 thilo.boehm    1.2 
 86                                out.putUint32(buf.size());
 87                                out.putBytes(buf.getData(), buf.size());
 88                                out.putString(cop.getHost());
 89                                out.putNamespaceName(cop.getNameSpace());
 90                            }
 91                        }
 92                    }
 93                    
 94                    void CIMInternalXmlEncoder::_putXMLNamedInstance(
 95                        CIMBuffer& out,
 96 anusha.kandepu 1.3     const CIMInstance& ci,
 97                        Boolean includeQualifiers,
 98                        Boolean includeClassOrigin,
 99                        const CIMPropertyList& propertyList)
100 thilo.boehm    1.2 {
101                        if (ci.isUninitialized())
102                        {
103                            out.putUint32(0);
104                            out.putUint32(0);
105                            out.putString(String());
106                            out.putNamespaceName(CIMNamespaceName());
107                        }
108                        else
109                        {
110                            Buffer buf(4096);
111                    
112                            // Serialize instance as XML.
113                            {
114 anusha.kandepu 1.3             XmlWriter::appendInstanceElement(
115                                    buf,
116                                    ci,
117                                    includeQualifiers,
118                                    includeClassOrigin,
119                                    propertyList);
120 thilo.boehm    1.2             buf.append('\0');
121                    
122                                out.putUint32(buf.size());
123                                out.putBytes(buf.getData(), buf.size());
124                                buf.clear();
125                            }
126                    
127                            // Serialize object path as XML.
128                    
129                            const CIMObjectPath& cop = ci.getPath();
130                    
131                            if (cop.getClassName().isNull())
132                            {
133                                out.putUint32(0);
134                                out.putString(String());
135                                out.putNamespaceName(CIMNamespaceName());
136                            }
137                            else
138                            {
139                                XmlWriter::appendInstanceNameElement(buf, cop);
140                                buf.append('\0');
141 thilo.boehm    1.2 
142                                out.putUint32(buf.size());
143                                out.putBytes(buf.getData(), buf.size());
144                                out.putString(cop.getHost());
145                                out.putNamespaceName(cop.getNameSpace());
146                            }
147                        }
148                    }
149                    
150                    void CIMInternalXmlEncoder::_putXMLObject(
151                        CIMBuffer& out,
152 anusha.kandepu 1.3     const CIMObject& co,
153                        Boolean includeQualifiers,
154                        Boolean includeClassOrigin,
155                        const CIMPropertyList& propertyList)
156 thilo.boehm    1.2 {
157                        if (co.isUninitialized())
158                        {
159                            out.putUint32(0);
160                            out.putUint32(0);
161                            out.putString(String());
162                            out.putNamespaceName(CIMNamespaceName());
163                        }
164                        else
165                        {
166                            Buffer buf(4096);
167                    
168                            // Serialize instance as XML.
169                            {
170 anusha.kandepu 1.3             XmlWriter::appendObjectElement(
171                                    buf,
172                                    co,
173                                    includeQualifiers,
174                                    includeClassOrigin,
175                                    propertyList);
176 thilo.boehm    1.2             buf.append('\0');
177                    
178                                out.putUint32(buf.size());
179                                out.putBytes(buf.getData(), buf.size());
180                                buf.clear();
181                            }
182                    
183                            // Serialize object path as XML.
184                    
185                            const CIMObjectPath& cop = co.getPath();
186                    
187                            if (cop.getClassName().isNull())
188                            {
189                                out.putUint32(0);
190                                out.putString(String());
191                                out.putNamespaceName(CIMNamespaceName());
192                            }
193                            else
194                            {
195                                _appendValueReferenceElement(buf, cop);
196                                buf.append('\0');
197 thilo.boehm    1.2 
198                                out.putUint32(buf.size());
199                                out.putBytes(buf.getData(), buf.size());
200                                out.putString(cop.getHost());
201                                out.putNamespaceName(cop.getNameSpace());
202                            }
203                        }
204                    }
205                    
206                    
207                    void CIMInternalXmlEncoder::_appendValueReferenceElement(
208                        Buffer& out,
209                        const CIMObjectPath& reference)
210                    {
211                        out << STRLIT("<VALUE.REFERENCE>\n");
212                    
213                        XmlWriter::appendInstanceNameElement(out, reference);
214                    
215                        out << STRLIT("</VALUE.REFERENCE>\n");
216                    }
217                    
218 thilo.boehm    1.2 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2