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

  1 karl  1.26 //%2006////////////////////////////////////////////////////////////////////////
  2 kumpf 1.1  //
  3 karl  1.20 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4            // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 karl  1.18 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.20 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.23 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.26 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 kumpf 1.1  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15 kumpf 1.6  // of this software and associated documentation files (the "Software"), to
 16            // deal in the Software without restriction, including without limitation the
 17            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18 kumpf 1.1  // sell copies of the Software, and to permit persons to whom the Software is
 19            // furnished to do so, subject to the following conditions:
 20            // 
 21 kumpf 1.6  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 kumpf 1.1  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24 kumpf 1.6  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27 kumpf 1.1  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29            //
 30            //==============================================================================
 31            //
 32            // Author: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 33            //
 34 kumpf 1.8  // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
 35 david.dillard 1.24 //                  (carolann_graves@hp.com)
 36 dave.sudlik   1.21 //              Dave Sudlik, IBM (dsudlik@us.ibm.com)
 37 david.dillard 1.24 //              David Dillard, VERITAS Software Corp.
 38                    //                  (david.dillard@veritas.com)
 39 kumpf         1.1  //
 40                    //%/////////////////////////////////////////////////////////////////////////////
 41                    
 42                    #include <Pegasus/Common/Config.h>
 43                    #include <cstdlib>
 44                    #include <cstdio>
 45                    #include "Constants.h"
 46                    #include "CIMClass.h"
 47                    #include "CIMClassRep.h"
 48                    #include "CIMInstance.h"
 49                    #include "CIMInstanceRep.h"
 50                    #include "CIMProperty.h"
 51                    #include "CIMPropertyRep.h"
 52                    #include "CIMMethod.h"
 53                    #include "CIMMethodRep.h"
 54                    #include "CIMParameter.h"
 55                    #include "CIMParameterRep.h"
 56                    #include "CIMQualifier.h"
 57                    #include "CIMQualifierRep.h"
 58                    #include "CIMQualifierDecl.h"
 59                    #include "CIMQualifierDeclRep.h"
 60 kumpf         1.4  #include "CIMObjectPath.h"
 61 kumpf         1.1  #include "CIMValue.h"
 62 kumpf         1.3  #include "CIMFlavor.h"
 63                    #include "CIMScope.h"
 64 kumpf         1.1  #include "XmlWriter.h"
 65                    #include "MofWriter.h"
 66                    #include "Tracer.h"
 67                    
 68                    PEGASUS_NAMESPACE_BEGIN
 69                    
 70                    //------------------------------------------------------------------------------
 71                    //
 72                    // Helper functions for appendValueElement()
 73                    //
 74                    //------------------------------------------------------------------------------
 75                    
 76 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, Boolean x)
 77 kumpf         1.1  {
 78                        XmlWriter::append(out, x);
 79                    }
 80                    
 81 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, Uint8 x)
 82 kumpf         1.1  {
 83                        XmlWriter::append(out, Uint32(x));
 84                    }
 85                    
 86 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, Sint8 x)
 87 kumpf         1.1  {
 88                        XmlWriter::append(out, Sint32(x));
 89                    }
 90                    
 91 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, Uint16 x)
 92 kumpf         1.1  {
 93                        XmlWriter::append(out, Uint32(x));
 94                    }
 95                    
 96 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, Sint16 x)
 97 kumpf         1.1  {
 98                        XmlWriter::append(out, Sint32(x));
 99                    }
100                    
101 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, Uint32 x)
102 kumpf         1.1  {
103                        XmlWriter::append(out, x);
104                    }
105                    
106 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, Sint32 x)
107 kumpf         1.1  {
108                        XmlWriter::append(out, x);
109                    }
110                    
111 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, Uint64 x)
112 kumpf         1.1  {
113                        XmlWriter::append(out, x);
114                    }
115                    
116 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, Sint64 x)
117 kumpf         1.1  {
118                        XmlWriter::append(out, x);
119                    }
120                    
121 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, Real32 x)
122 kumpf         1.1  {
123                        XmlWriter::append(out, Real64(x));
124                    }
125                    
126 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, Real64 x)
127 kumpf         1.1  {
128                        XmlWriter::append(out, x);
129                    }
130                    
131 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, Char16 x)
132 kumpf         1.1  {
133                        XmlWriter::appendSpecial(out, x);
134                    }
135                    
136                    /** Convert the string back to MOF format and output it.
137                        The conversions are:
138                        \b // \x0008: backspace BS
139                        \t // \x0009: horizontal tab HT
140                        \n // \x000A: linefeed LF
141                        \f // \x000C: form feed FF
142                        \r // \x000D: carriage return CR
143                        \" // \x0022: double quote "
144                        \’ // \x0027: single quote '
145                        \\ // \x005C: backslash \
146                        \x<hex> // where <hex> is one to four hex digits
147                        \X<hex> // where <hex> is one to four hex digits
148                    */
149                    /* ATTN:KS - We need to account for characters greater than x'7f
150                    */
151 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, const String& x)
152 kumpf         1.1  {
153                        out << "\"";
154 david.dillard 1.24     const Uint32 size = x.size();
155                        for (Uint32 i = 0; i < size; i++)
156 kumpf         1.1      {
157 kumpf         1.7          switch (x[i])
158 kumpf         1.1          {
159                            case '\\':
160                                    out.append("\\\\",2);
161                                    break;
162                    
163                                case '\b':
164                                    out.append("\\b",2);
165                                    break;
166                    
167                                case '\t':
168                                    out.append("\\t",2);
169                                    break;
170                    
171                                case '\n':
172                                    out.append("\\n",2);
173                                    break;
174                    
175                                case '\f':
176                                    out.append("\\f",2);
177                                    break;
178                    
179 kumpf         1.1              case '\r':
180                                    out.append("\\r",2);
181                                    break;
182                    
183                               /* case '\'':
184                                    out.append("\\'", 2);
185                                    break;*/
186                    
187                                case '"':
188                                    out.append("\\\"", 2);
189                                    break;
190                    
191                                default:
192 kumpf         1.7                  out.append(Sint8(x[i]));
193 kumpf         1.1          }
194                    
195                        }
196                        out << "\"";
197                    }
198                    
199 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, const CIMDateTime& x)
200 kumpf         1.1  {
201 kumpf         1.19     _mofWriter_appendValue(out, x.toString());
202 kumpf         1.1  }
203                    
204 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, const CIMObjectPath& x)
205 kumpf         1.1  {
206 kumpf         1.19     _mofWriter_appendValue(out, x.toString());
207 kumpf         1.1  }
208                    
209 mike          1.25 inline void _mofWriter_appendValue(Buffer& out, const CIMObject& x)
210 dave.sudlik   1.21 {
211                        _mofWriter_appendValue(out, x.toString());
212                    }
213                    
214 kumpf         1.1  /** Array -
215                        arrayInitializer = "{" constantValue*( "," constantValue)"}"
216                    */
217                    template<class T>
218 mday          1.5  
219 mike          1.25 void _mofWriter_appendValueArrayMof(Buffer& out, const T* p, Uint32 size)
220 kumpf         1.1  {
221                        Boolean isFirstEntry = true;
222                        // if there are any entries in the array output them
223                        if (size)
224                        {
225                            out << "{";
226                            while (size--)
227                            {
228                                // Put comma on all but first entry.
229                                if (!isFirstEntry)
230                                {
231                                    out << ", ";
232                                }
233                                isFirstEntry = false;
234 s.hills       1.17             _mofWriter_appendValue(out, *p++);
235 kumpf         1.1          }
236                            out << "}";
237                        }
238                    }
239                    
240                    //------------------------------------------------------------------------------
241                    //
242                    // appendValueElement()
243                    //
244                    //------------------------------------------------------------------------------
245                    
246                    void MofWriter::appendValueElement(
247 mike          1.25     Buffer& out,
248 kumpf         1.1      const CIMValue& value)
249                    {
250                        // if the CIMValue is Null we return the Null indicator.
251                        if (value.isNull())
252                        {
253                            out << "null";
254                            return;
255                        }
256                    
257                        if (value.isArray())
258                        {
259                            switch (value.getType())
260                            {
261 kumpf         1.8              case CIMTYPE_BOOLEAN:
262 kumpf         1.1              {
263                                    Array<Boolean> a;
264                                    value.get(a);
265 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
266 kumpf         1.1                  break;
267                                }
268                    
269 kumpf         1.8              case CIMTYPE_UINT8:
270 kumpf         1.1              {
271                                    Array<Uint8> a;
272                                    value.get(a);
273 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
274 kumpf         1.1                  break;
275                                }
276                    
277 kumpf         1.8              case CIMTYPE_SINT8:
278 kumpf         1.1              {
279                                    Array<Sint8> a;
280                                    value.get(a);
281 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
282 kumpf         1.1                  break;
283                                }
284                    
285 kumpf         1.8              case CIMTYPE_UINT16:
286 kumpf         1.1              {
287                                    Array<Uint16> a;
288                                    value.get(a);
289 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
290 kumpf         1.1                  break;
291                                }
292                    
293 kumpf         1.8              case CIMTYPE_SINT16:
294 kumpf         1.1              {
295                                    Array<Sint16> a;
296                                    value.get(a);
297 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
298 kumpf         1.1                  break;
299                                }
300                    
301 kumpf         1.8              case CIMTYPE_UINT32:
302 kumpf         1.1              {
303                                    Array<Uint32> a;
304                                    value.get(a);
305 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
306 kumpf         1.1                  break;
307                                }
308                    
309 kumpf         1.8              case CIMTYPE_SINT32:
310 kumpf         1.1              {
311                                    Array<Sint32> a;
312                                    value.get(a);
313 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
314 kumpf         1.1                  break;
315                                }
316                    
317 kumpf         1.8              case CIMTYPE_UINT64:
318 kumpf         1.1              {
319                                    Array<Uint64> a;
320                                    value.get(a);
321 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
322 kumpf         1.1                  break;
323                                }
324                    
325 kumpf         1.8              case CIMTYPE_SINT64:
326 kumpf         1.1              {
327                                    Array<Sint64> a;
328                                    value.get(a);
329 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
330 kumpf         1.1                  break;
331                                }
332                    
333 kumpf         1.8              case CIMTYPE_REAL32:
334 kumpf         1.1              {
335                                    Array<Real32> a;
336                                    value.get(a);
337 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
338 kumpf         1.1                  break;
339                                }
340                    
341 kumpf         1.8              case CIMTYPE_REAL64:
342 kumpf         1.1              {
343                                    Array<Real64> a;
344                                    value.get(a);
345 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
346 kumpf         1.1                  break;
347                                }
348                    
349 kumpf         1.8              case CIMTYPE_CHAR16:
350 kumpf         1.1              {
351                                    Array<Char16> a;
352                                    value.get(a);
353 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
354 kumpf         1.1                  break;
355                                }
356                    
357 kumpf         1.8              case CIMTYPE_STRING:
358 kumpf         1.1              {
359                                    Array<String> a;
360                                    value.get(a);
361 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
362 kumpf         1.1                  break;
363                                }
364                    
365 kumpf         1.8              case CIMTYPE_DATETIME:
366 kumpf         1.1              {
367                                    Array<CIMDateTime> a;
368                                    value.get(a);
369 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
370 kumpf         1.1                  break;
371                                }
372                    
373 kumpf         1.8              case CIMTYPE_REFERENCE:
374 kumpf         1.1              {
375 kumpf         1.4                  Array<CIMObjectPath> a;
376 kumpf         1.1                  value.get(a);
377 s.hills       1.17                 _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
378 kumpf         1.1                  break;
379                                }
380                    
381 dave.sudlik   1.21             case CIMTYPE_OBJECT:
382                                {
383                                    Array<CIMObject> a;
384                                    value.get(a);
385                                    _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
386                                    break;
387                                }
388 a.dunfey      1.27 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
389                                case CIMTYPE_INSTANCE:
390                                {
391                                    Array<CIMInstance> a;
392                                    value.get(a);
393                                    _mofWriter_appendValueArrayMof(out, a.getData(), a.size());
394                                    break;
395                                }
396                    #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT
397 kumpf         1.1              default:
398 kumpf         1.15                 PEGASUS_ASSERT(false);
399 kumpf         1.1          }
400                        }
401                        else
402                        {
403                            switch (value.getType())
404                            {
405 kumpf         1.8              case CIMTYPE_BOOLEAN:
406 kumpf         1.1              {
407                                    Boolean v;
408                                    value.get(v);
409 s.hills       1.17                 _mofWriter_appendValue(out, v);
410 kumpf         1.1                  break;
411                                }
412                    
413 kumpf         1.8              case CIMTYPE_UINT8:
414 kumpf         1.1              {
415                                    Uint8 v;
416                                    value.get(v);
417 s.hills       1.17                 _mofWriter_appendValue(out, v);
418 kumpf         1.1                  break;
419                                }
420                    
421 kumpf         1.8              case CIMTYPE_SINT8:
422 kumpf         1.1              {
423                                    Sint8 v;
424                                    value.get(v);
425 s.hills       1.17                 _mofWriter_appendValue(out, v);
426 kumpf         1.1                  break;
427                                }
428                    
429 kumpf         1.8              case CIMTYPE_UINT16:
430 kumpf         1.1              {
431                                    Uint16 v;
432                                    value.get(v);
433 s.hills       1.17                 _mofWriter_appendValue(out, v);
434 kumpf         1.1                  break;
435                                }
436                    
437 kumpf         1.8              case CIMTYPE_SINT16:
438 kumpf         1.1              {
439                                    Sint16 v;
440                                    value.get(v);
441 s.hills       1.17                 _mofWriter_appendValue(out, v);
442 kumpf         1.1                  break;
443                                }
444                    
445 kumpf         1.8              case CIMTYPE_UINT32:
446 kumpf         1.1              {
447                                    Uint32 v;
448                                    value.get(v);
449 s.hills       1.17                 _mofWriter_appendValue(out, v);
450 kumpf         1.1                  break;
451                                }
452                    
453 kumpf         1.8              case CIMTYPE_SINT32:
454 kumpf         1.1              {
455                                    Sint32 v;
456                                    value.get(v);
457 s.hills       1.17                 _mofWriter_appendValue(out, v);
458 kumpf         1.1                  break;
459                                }
460                    
461 kumpf         1.8              case CIMTYPE_UINT64:
462 kumpf         1.1              {
463                                    Uint64 v;
464                                    value.get(v);
465 s.hills       1.17                 _mofWriter_appendValue(out, v);
466 kumpf         1.1                  break;
467                                }
468                    
469 kumpf         1.8              case CIMTYPE_SINT64:
470 kumpf         1.1              {
471                                    Sint64 v;
472                                    value.get(v);
473 s.hills       1.17                 _mofWriter_appendValue(out, v);
474 kumpf         1.1                  break;
475                                }
476                    
477 kumpf         1.8              case CIMTYPE_REAL32:
478 kumpf         1.1              {
479                                    Real32 v;
480                                    value.get(v);
481 s.hills       1.17                 _mofWriter_appendValue(out, v);
482 kumpf         1.1                  break;
483                                }
484                    
485 kumpf         1.8              case CIMTYPE_REAL64:
486 kumpf         1.1              {
487                                    Real64 v;
488                                    value.get(v);
489 s.hills       1.17                 _mofWriter_appendValue(out, v);
490 kumpf         1.1                  break;
491                                }
492                    
493 kumpf         1.8              case CIMTYPE_CHAR16:
494 kumpf         1.1              {
495                                    Char16 v;
496                                    value.get(v);
497 s.hills       1.17                 _mofWriter_appendValue(out, v);
498 kumpf         1.1                  break;
499                                }
500                    
501 kumpf         1.8              case CIMTYPE_STRING:
502 kumpf         1.1              {
503                                    String v;
504                                    value.get(v);
505 s.hills       1.17                 _mofWriter_appendValue(out, v);
506 kumpf         1.1                  break;
507                                }
508                    
509 kumpf         1.8              case CIMTYPE_DATETIME:
510 kumpf         1.1              {
511                                    CIMDateTime v;
512                                    value.get(v);
513 s.hills       1.17                 _mofWriter_appendValue(out, v);
514 kumpf         1.1                  break;
515                                }
516                    
517 kumpf         1.8              case CIMTYPE_REFERENCE:
518 kumpf         1.1              {
519 kumpf         1.4                  CIMObjectPath v;
520 kumpf         1.1                  value.get(v);
521 s.hills       1.17                 _mofWriter_appendValue(out, v);
522 kumpf         1.1                  break;
523                                }
524                    
525 dave.sudlik   1.21             case CIMTYPE_OBJECT:
526                                {
527                                    CIMObject v;
528                                    value.get(v);
529                                    _mofWriter_appendValue(out, v);
530                                    break;
531                                }
532 a.dunfey      1.27 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
533                                case CIMTYPE_INSTANCE:
534                                {
535                                    CIMInstance v;
536                                    value.get(v);
537                                    _mofWriter_appendValue(out, v);
538                                    break;
539                                }
540                    #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT
541 kumpf         1.1              default:
542 kumpf         1.15                 PEGASUS_ASSERT(false);
543 kumpf         1.1          }
544                        }
545                    }
546                    
547                    //------------------------------------------------------------------------------
548                    //
549                    // appendValueReferenceElement()
550                    //
551                    //------------------------------------------------------------------------------
552                    
553                    void MofWriter::appendValueReferenceElement(
554 mike          1.25     Buffer& out,
555 kumpf         1.4      const CIMObjectPath& reference)
556 kumpf         1.1  {
557 kumpf         1.19     _mofWriter_appendValue(out, reference);
558 kumpf         1.1  }
559                    
560                    //------------------------------------------------------------------------------
561                    //
562                    // appendClassElement()
563                    //
564                    //------------------------------------------------------------------------------
565                    
566                    void MofWriter::appendClassElement(
567 mike          1.25     Buffer& out,
568 kumpf         1.1      const CIMConstClass& cimclass)
569                    {
570                        cimclass._checkRep();
571                        cimclass._rep->toMof(out);
572                    }
573                    
574                    void MofWriter::printClassElement(
575                        const CIMConstClass& cimclass,
576                        PEGASUS_STD(ostream)& os)
577                    {
578 mike          1.25     Buffer tmp;
579 kumpf         1.1      appendClassElement(tmp, cimclass);
580                        tmp.append('\0');
581                        os << tmp.getData() << PEGASUS_STD(endl);
582                    }
583                    
584                    //------------------------------------------------------------------------------
585                    //
586                    // appendInstanceElement()
587                    //
588                    //------------------------------------------------------------------------------
589                    
590                    void MofWriter::appendInstanceElement(
591 mike          1.25     Buffer& out,
592 kumpf         1.1      const CIMConstInstance& instance)
593                    {
594                        instance._checkRep();
595                        instance._rep->toMof(out);
596                    }
597                    
598                    //------------------------------------------------------------------------------
599                    //
600                    // appendPropertyElement()
601                    //
602                    //------------------------------------------------------------------------------
603                    
604                    void MofWriter::appendPropertyElement(
605 karl          1.28     Boolean isDeclaration,
606 mike          1.25     Buffer& out,
607 kumpf         1.1      const CIMConstProperty& property)
608                    {
609                        property._checkRep();
610 karl          1.28     property._rep->toMof(isDeclaration, out);
611 kumpf         1.1  }
612                    
613                    //------------------------------------------------------------------------------
614                    //
615                    // appendMethodElement()
616                    //
617                    //------------------------------------------------------------------------------
618                    
619                    void MofWriter::appendMethodElement(
620 mike          1.25     Buffer& out,
621 kumpf         1.1      const CIMConstMethod& method)
622                    {
623                        method._checkRep();
624                        method._rep->toMof(out);
625                    }
626                    
627                    //------------------------------------------------------------------------------
628                    //
629                    // appendParameterElement()
630                    //
631                    //------------------------------------------------------------------------------
632                    
633                    void MofWriter::appendParameterElement(
634 mike          1.25     Buffer& out,
635 kumpf         1.1      const CIMConstParameter& parameter)
636                    {
637                        parameter._checkRep();
638                        parameter._rep->toMof(out);
639                    }
640                    
641                    //------------------------------------------------------------------------------
642                    //
643                    // appendQualifierElement()
644                    //
645                    //------------------------------------------------------------------------------
646                    
647                    void MofWriter::appendQualifierElement(
648 mike          1.25     Buffer& out,
649 kumpf         1.1      const CIMConstQualifier& qualifier)
650                    {
651                        qualifier._checkRep();
652                        qualifier._rep->toMof(out);
653                    }
654                    
655                    //------------------------------------------------------------------------------
656                    //
657                    // appendQualifierDeclElement()
658                    //
659                    //------------------------------------------------------------------------------
660                    
661                    void MofWriter::appendQualifierDeclElement(
662 mike          1.25     Buffer& out,
663 kumpf         1.1      const CIMConstQualifierDecl& qualifierDecl)
664                    {
665                        qualifierDecl._checkRep();
666                        qualifierDecl._rep->toMof(out);
667 kumpf         1.2  }
668                    
669                    //------------------------------------------------------------------------------
670                    //
671                    // getQualifierFlavor()
672                    //
673                    // Convert the Qualifier flavors to a string of MOF flavor keywords.
674                    //
675                    //   <pre>
676                    //   Keyword            Function                             Default
677                    //     EnableOverride  Qualifier is overridable.               yes
678 kumpf         1.10 //     DisableOverride Qualifier cannot be overridden.         no
679 kumpf         1.2  //     ToSubclass      Qualifier is inherited by any subclass. yes
680                    //     Restricted      Qualifier applies only to the class     no
681                    //                     in which it is declared
682                    //     Translatable    Indicates the value of the qualifier
683 kumpf         1.10 //                     can be specified in multiple languages  no
684 kumpf         1.2  //     NOTE: There is an open issue with the keyword toinstance.
685                    //
686                    //     flavor            = ENABLEOVERRIDE | DISABLEOVERRIDE | RESTRICTED |
687                    //                         TOSUBCLASS | TRANSLATABLE
688 kumpf         1.10 //     DISABLEOVERRIDE   = "disableoverride"
689 kumpf         1.2  //
690                    //     ENABLEOVERRIDE    = "enableoverride"
691                    //
692                    //     RESTRICTED        = "restricted"
693                    //
694                    //     TOSUBCLASS        = "tosubclass"
695                    //
696                    //     TRANSLATABLE      = "translatable"
697                    //    </pre>
698                    //
699                    //    The keyword toinstance is not in the CIM specification. For the moment 
700                    //    we are assuming that it is the same as the toSubclass. We had a choice
701                    //    of using one entity for both or separating them and letting the
702                    //    compiler set both.
703                    //
704                    //------------------------------------------------------------------------------
705                    
706 kumpf         1.10 String MofWriter::getQualifierFlavor(const CIMFlavor & flavor)
707 kumpf         1.2  {
708 david.dillard 1.24     String tmp;
709 kumpf         1.2  
710 kumpf         1.10     if (!(flavor.hasFlavor (CIMFlavor::OVERRIDABLE)))
711 kumpf         1.14         tmp.append("DisableOverride, ");
712 kumpf         1.2  
713 kumpf         1.10     if (!(flavor.hasFlavor (CIMFlavor::TOSUBCLASS)))
714 kumpf         1.14         tmp.append("Restricted, ");
715 kumpf         1.2  
716                        // ATTN-RK-P3-20020515: FUTURE: Need to check toInstance flavor?
717 kumpf         1.10     //if (!(flavor.hasFlavor (CIMFlavor::TOINSTANCE)))
718 kumpf         1.14     //    tmp.append("Restricted, ");
719 kumpf         1.2  
720 kumpf         1.10     if (flavor.hasFlavor (CIMFlavor::TRANSLATABLE))
721 kumpf         1.14         tmp.append("Translatable, ");
722 kumpf         1.2  
723                        if (tmp.size())
724                            tmp.remove(tmp.size() - 2);
725                    
726                        return tmp;
727 kumpf         1.3  }
728                    
729                    //------------------------------------------------------------------------------
730                    //
731                    // getQualifierScope()
732                    //
733                    //------------------------------------------------------------------------------
734                    
735 kumpf         1.9  String MofWriter::getQualifierScope (const CIMScope & scope)
736 kumpf         1.3  {
737 kumpf         1.11     if (scope.equal (CIMScope::ANY))
738 kumpf         1.3      {
739                            return "any";
740                        }
741                        else
742                        {
743 kumpf         1.9          String tmp = scope.toString ();
744 kumpf         1.3          tmp.toLower();
745                            return tmp;
746                        }
747 kumpf         1.1  }
748                    
749                    PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2