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

Diff for /pegasus/src/Pegasus/Common/CIMValue.cpp between version 1.2 and 1.24

version 1.2, 2001/02/26 04:33:28 version 1.24, 2002/04/01 19:06:03
Line 1 
Line 1 
 //BEGIN_LICENSE  //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM  // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a  // Permission is hereby granted, free of charge, to any person obtaining a copy
 // copy of this software and associated documentation files (the "Software"),  // of this software and associated documentation files (the "Software"), to
 // to deal in the Software without restriction, including without limitation  // deal in the Software without restriction, including without limitation the
 // the rights to use, copy, modify, merge, publish, distribute, sublicense,  // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 // and/or sell copies of the Software, and to permit persons to whom the  // sell copies of the Software, and to permit persons to whom the Software is
 // Software is furnished to do so, subject to the following conditions:  // furnished to do so, subject to the following conditions:
   //
   // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
   // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
   // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
   // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
   // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
   // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // //
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  //==============================================================================
 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  
 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL  
 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING  
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER  
 // DEALINGS IN THE SOFTWARE.  
 // //
 //END_LICENSE  // Author: Mike Brasher (mbrasher@bmc.com)
 //BEGIN_HISTORY  
 // //
 // Author:  // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
   //              Karl Schopmeyer, (k.schopmeyer@opengroup.org)
 // //
 // $Log$  //%/////////////////////////////////////////////////////////////////////////////
 // Revision 1.2  2001/02/26 04:33:28  mike  
 // Fixed many places where cim names were be compared with operator==(String,String).  
 // Changed all of these to use CIMName::equal()  
 //  
 // Revision 1.1  2001/02/18 18:39:06  mike  
 // new  
 //  
 // Revision 1.1  2001/02/16 02:07:06  mike  
 // Renamed many classes and headers (using new CIM prefixes).  
 //  
 // Revision 1.1.1.1  2001/01/14 19:53:20  mike  
 // Pegasus import  
 //  
 //  
 //END_HISTORY  
  
 #include <cstring> #include <cstring>
 #include <cstdio> #include <cstdio>
Line 50 
Line 38 
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
   #define PEGASUS_ARRAY_T CIMValue
   # include "ArrayImpl.h"
   #undef PEGASUS_ARRAY_T
   
 template<class T> template<class T>
 inline void _Inc(ArrayRep<T>* rep) inline void _Inc(ArrayRep<T>* rep)
 { {
Line 68 
Line 60 
 // //
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
  
   // Too complicated.  Commented out in favor of sprintf("%lld"/"%llu").
   #if 0
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // _SignedIntToStr() // _SignedIntToStr()
Line 86 
Line 80 
         return;         return;
     }     }
  
     char buffer[256];      char buffer[32];
     Uint32 len = 0;     Uint32 len = 0;
     Boolean negative = false;     Boolean negative = false;
  
     for (Uint32 i = 0; 1; i++)      while (x)
     {     {
         Sint64 q = x / 10;  
         Sint32 r = x % 10;         Sint32 r = x % 10;
           x = x / 10;
         if (q == 0 && r == 0)  
             break;  
  
         if (r < 0)         if (r < 0)
         {         {
Line 105 
Line 96 
         }         }
  
         buffer[len++] = r + '0';         buffer[len++] = r + '0';
   
         x = q ;  
     }     }
  
     buffer[len] = '\0';     buffer[len] = '\0';
Line 146 
Line 135 
         return;         return;
     }     }
  
     char buffer[256];      char buffer[32];
     Uint32 len = 0;     Uint32 len = 0;
     Boolean negative = false;  
  
     for (Uint32 i = 0; 1; i++)      while (x)
     {     {
         Sint64 q = x / 10;          Uint32 r = x % 10;
         Sint32 r = x % 10;          x = x / 10;
   
         if (q == 0 && r == 0)  
             break;  
  
         buffer[len++] = r + '0';         buffer[len++] = r + '0';
   
         x = q ;  
     }     }
  
     buffer[len] = '\0';     buffer[len] = '\0';
Line 176 
Line 159 
  
     *q++ = '\0';     *q++ = '\0';
 } }
   #endif
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // _toXml() routines:  // _toString, _toXml(), and _toMof routines:
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 inline void _toXml(Array<Sint8>& out, Boolean x)  inline void _toString(Array<Sint8>& out, Boolean x)
 { {
     out << (x ? "TRUE" : "FALSE");     out << (x ? "TRUE" : "FALSE");
 } }
  
 template<class T>  inline void _toXml(Array<Sint8>& out, Boolean x) { _toString(out, x); }
 inline void _integerToXml(Array<Sint8>& out, const T& x)  inline void _toMof(Array<Sint8>& out, Boolean x) { _toString(out, x); }
   
   inline void _integerToString(Array<Sint8>& out, Sint32 x)
 { {
     char buffer[32];     char buffer[32];
     sprintf(buffer, "%d", x);     sprintf(buffer, "%d", x);
     out << (char*)buffer;     out << (char*)buffer;
 } }
  
 inline void _toXml(Array<Sint8>& out, Uint8 x) { _integerToXml(out, x); }  inline void _unsignedIntegerToString(Array<Sint8>& out, Uint32 x)
   
 inline void _toXml(Array<Sint8>& out, Sint8 x) { _integerToXml(out, x); }  
   
 inline void _toXml(Array<Sint8>& out, Uint16 x) { _integerToXml(out, x); }  
   
 inline void _toXml(Array<Sint8>& out, Sint16 x) { _integerToXml(out, x); }  
   
 inline void _toXml(Array<Sint8>& out, Uint32 x) { _integerToXml(out, x); }  
   
 inline void _toXml(Array<Sint8>& out, Sint32 x) { _integerToXml(out, x); }  
   
 inline void _toXml(Array<Sint8>& out, Uint64 x)  
 { {
     char buffer[128];      char buffer[32];
     _UnsignedIntToStr(x, buffer);      sprintf(buffer, "%u", x);
     out << buffer;      out << (char*)buffer;
 } }
  
 inline void _toXml(Array<Sint8>& out, Sint64 x)  inline void _toString(Array<Sint8>& out, Uint8 x) { _unsignedIntegerToString(out, x); }
 {  inline void _toXml(Array<Sint8>& out, Uint8 x) { _toString(out, x); }
     char buffer[128];  inline void _toMof(Array<Sint8>& out, Uint8 x) { _toString(out, x); }
     _SignedIntToStr(x, buffer);  
   inline void _toString(Array<Sint8>& out, Sint8 x) { _integerToString(out, x); }
   inline void _toXml(Array<Sint8>& out, Sint8 x) { _toString(out, x); }
   inline void _toMof(Array<Sint8>& out, Sint8 x) { _toString(out, x); }
   
   inline void _toString(Array<Sint8>& out, Uint16 x) { _unsignedIntegerToString(out, x); }
   inline void _toXml(Array<Sint8>& out, Uint16 x) { _toString(out, x); }
   inline void _toMof(Array<Sint8>& out, Uint16 x) { _toString(out, x); }
   
   inline void _toString(Array<Sint8>& out, Sint16 x) { _integerToString(out, x); }
   inline void _toXml(Array<Sint8>& out, Sint16 x) { _toString(out, x); }
   inline void _toMof(Array<Sint8>& out, Sint16 x) { _toString(out, x); }
   
   inline void _toString(Array<Sint8>& out, Uint32 x) { _unsignedIntegerToString(out, x); }
   inline void _toXml(Array<Sint8>& out, Uint32 x) { _toString(out, x); }
   inline void _toMof(Array<Sint8>& out, Uint32 x) { _toString(out, x); }
   
   inline void _toString(Array<Sint8>& out, Sint32 x) { _integerToString(out, x); }
   inline void _toXml(Array<Sint8>& out, Sint32 x) { _toString(out, x); }
   inline void _toMof(Array<Sint8>& out, Sint32 x) { _toString(out, x); }
   
   inline void _toString(Array<Sint8>& out, Uint64 x)
   {
       char buffer[32];  // Should need 21 chars max
       // I know I shouldn't put platform flags here, but the other was is too hard
   #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
       sprintf(buffer, "%I64u", x);
   #else
       sprintf(buffer, "%llu", x);
   #endif
     out << buffer;     out << buffer;
 } }
  
 void _toXml(Array<Sint8>& out, Real32 x)  inline void _toXml(Array<Sint8>& out, Uint64 x) { _toString(out, x); }
   inline void _toMof(Array<Sint8>& out, Uint64 x) { _toString(out, x); }
   
   inline void _toString(Array<Sint8>& out, Sint64 x)
 { {
     // ATTN: Does this format match the CIM/XML format?      char buffer[32];  // Should need 21 chars max
     char buffer[128];      // I know I shouldn't put platform flags here, but the other was is too hard
     sprintf(buffer, "%f", x);  #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
       sprintf(buffer, "%I64d", x);
   #else
       sprintf(buffer, "%lld", x);
   #endif
     out << buffer;     out << buffer;
 } }
  
 void _toXml(Array<Sint8>& out, Real64 x)  inline void _toXml(Array<Sint8>& out, Sint64 x) { _toString(out, x); }
   inline void _toMof(Array<Sint8>& out, Sint64 x) { _toString(out, x); }
   
   void _toString(Array<Sint8>& out, Real64 x)
 { {
     char buffer[128];     char buffer[128];
     sprintf(buffer, "%f", x);      // %e gives '[-]m.dddddde+/-xx', which seems compatible with CIM/XML spec
       sprintf(buffer, "%e", x);
     out << buffer;     out << buffer;
 } }
  
   inline void _toXml(Array<Sint8>& out, Real64 x) { _toString(out, x); }
   inline void _toMof(Array<Sint8>& out, Real64 x) { _toString(out, x); }
   
   inline void _toString(Array<Sint8>& out, Real32 x) { _toString(out, Real64(x)); }
   inline void _toXml(Array<Sint8>& out, Real32 x) { _toString(out, x); }
   inline void _toMof(Array<Sint8>& out, Real32 x) { _toString(out, x); }
   
   inline void _toString(Array<Sint8>& out, Char16 x)
   {
       // ATTN: How to convert 16-bit characters to printable form?
       out.append(Sint8(x));
   }
 inline void _toXml(Array<Sint8>& out, Char16 x) inline void _toXml(Array<Sint8>& out, Char16 x)
 { {
     XmlWriter::appendSpecial(out, x);     XmlWriter::appendSpecial(out, x);
 } }
   inline void _toMof(Array<Sint8>& out, Char16 x)
   {
       XmlWriter::appendSpecial(out, x);
   }
   
   inline void _toString(Array<Sint8>& out, const String& x)
   {
       out << x;
   }
  
 inline void _toXml(Array<Sint8>& out, const String& x) inline void _toXml(Array<Sint8>& out, const String& x)
 { {
     XmlWriter::appendSpecial(out, x);     XmlWriter::appendSpecial(out, x);
 } }
  
 inline void _toXml(Array<Sint8>& out, const CIMDateTime& x)  /** _toMof Internal function to convert the string back
       to MOF format and output it.
       The conversions are:
       \b // \x0008: backspace BS
       \t // \x0009: horizontal tab HT
       \n // \x000A: linefeed LF
       \f // \x000C: form feed FF
       \r // \x000D: carriage return CR
       \" // \x0022: double quote "
       \’ // \x0027: single quote '
       \\ // \x005C: backslash \
       \x<hex> // where <hex> is one to four hex digits
       \X<hex> // where <hex> is one to four hex digits
   */
   /* ATTN:KS - We need to account for characters greater than x'7f
   */
   inline void _toMof(Array<Sint8>& out, const String& x)
   {
       out << "\"";
       const Char16* tmp = x.getData();
       char c;
       while ((c = *tmp++))
       {
           switch (c)
           {
           case '\\':
                   out.append("\\\\",2);
                   break;
   
               case '\b':
                   out.append("\\b",2);
                   break;
   
               case '\t':
                   out.append("\\t",2);
                   break;
   
               case '\n':
                   out.append("\\n",2);
                   break;
   
               case '\f':
                   out.append("\\f",2);
                   break;
   
               case '\r':
                   out.append("\\r",2);
                   break;
   
              /* case '\'':
                   out.append("\\'", 2);
                   break;*/
   
               case '"':
                   out.append("\\\"", 2);
                   break;
   
               default:
                   out.append(Sint8(c));
           }
   
       }
       out << "\"";
   }
   
   inline void _toString(Array<Sint8>& out, const CIMDateTime& x)
 { {
     out << x.getString();     out << x.getString();
 } }
  
   inline void _toXml(Array<Sint8>& out, const CIMDateTime& x) { _toString(out, x); }
   inline void _toMof(Array<Sint8>& out, const CIMDateTime& x) { _toString(out, x); }
   
   inline void _toString(Array<Sint8>& out, const CIMReference& x)
   {
       out << x.toString();
   }
   inline void _toXml(Array<Sint8>& out, const CIMReference& x)
   {
       x.toXml(out);
   }
   inline void _toMof(Array<Sint8>& out, const CIMReference& x)
   {
       x.toMof(out);
   }
   
   template<class T>
   void _toString(Array<Sint8>& out, const T* p, Uint32 size)
   {
       while (size--)
       {
           _toString(out, *p++);
           out << " ";
       }
   }
   
   void _toXml(Array<Sint8>& out, const CIMReference* p, Uint32 size)
   {
       out << "<VALUE.REFARRAY>\n";
       while (size--)
       {
           _toXml(out, *p++);
       }
       out << "</VALUE.REFARRAY>\n";
   }
   
 template<class T> template<class T>
 void _toXml(Array<Sint8>& out, const T* p, Uint32 size) void _toXml(Array<Sint8>& out, const T* p, Uint32 size)
 { {
       out << "<VALUE.ARRAY>\n";
   
     while (size--)     while (size--)
     {     {
         out << "<VALUE>";         out << "<VALUE>";
Line 263 
Line 401 
  
         out << "</VALUE>\n";         out << "</VALUE>\n";
     }     }
   
       out << "</VALUE.ARRAY>\n";
 } }
   /** _toMof Array -
       arrayInitializer  = "{" constantValue*( "," constantValue)"}"
  
   */
 template<class T> template<class T>
 void _toStr(Array<Sint8>& out, const T* p, Uint32 size)  void _toMof(Array<Sint8>& out, const T* p, Uint32 size)
 { {
       Boolean isFirstEntry = true;
       // if there are any entries in the array output them
       if (size)
       {
           out << "{";
     while (size--)     while (size--)
     {     {
         _toXml(out, *p++);              // Put comma on all but first entry.
         out << " ";              if (!isFirstEntry)
               {
                   out << ", ";
               }
               isFirstEntry = false;
               _toMof(out, *p++);
           }
           out << "}";
   
     }     }
 } }
  
Line 286 
Line 442 
     _init();     _init();
 } }
  
   CIMValue::CIMValue(CIMType type, Boolean isArray, Uint32 arraySize)
   {
       _init();
       setNullValue(type, isArray, arraySize);
   }
   
 CIMValue::CIMValue(const CIMValue& x) CIMValue::CIMValue(const CIMValue& x)
 { {
     _init();     _init();
Line 306 
Line 468 
  
     _type = x._type;     _type = x._type;
     _isArray = x._isArray;     _isArray = x._isArray;
       _isNull = x._isNull;
     _u._voidPtr = 0;     _u._voidPtr = 0;
  
     if (_isArray)     if (_isArray)
Line 367 
Line 530 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 _Inc(_u._dateTimeArray = x._u._dateTimeArray);                 _Inc(_u._dateTimeArray = x._u._dateTimeArray);
                 break;                 break;
   
               case CIMType::REFERENCE:
                   _Inc(_u._referenceArray = x._u._referenceArray);
                   break;
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
     else     else
Line 436 
Line 605 
                 _u._referenceValue                 _u._referenceValue
                     = new CIMReference(*(x._u._referenceValue));                     = new CIMReference(*(x._u._referenceValue));
                 break;                 break;
   
               // Should never get here. testing complete enum
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
 } }
Line 508 
Line 681 
             break;             break;
  
         case CIMType::REFERENCE:         case CIMType::REFERENCE:
             return 0;              return _u._referenceArray->size;
               break;
           // Should never get here. switch on complete enum
           default:
               throw CIMValueInvalidType();
     }     }
  
     // Unreachable!     // Unreachable!
       PEGASUS_ASSERT(false);
     return 0;     return 0;
 } }
  
   //ATTN: P1  KS Problem with Compiler when I added the defaults to clear, the compiler
   // gets an exception very early.  Disabled the exceptions to keep compiler running for
   // the minute. Note that the case statement is not complete. None missing.
 void CIMValue::clear() void CIMValue::clear()
 { {
       // ATTN: KS P1 should we be setting NULL=true here????. Right now it only
       // clears the value component. Note that the last thing we do is init
       // and that does the isNull=false.
       //
     if (_isArray)     if (_isArray)
     {     {
         switch (_type)         switch (_type)
Line 576 
Line 761 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 _Dec(_u._dateTimeArray);                 _Dec(_u._dateTimeArray);
                 break;                 break;
   
               case CIMType::REFERENCE:
                   _Dec(_u._referenceArray);
                   break;
   
               //default:
                   //throw CIMValueInvalidType();
         }         }
     }     }
     else     else
Line 607 
Line 799 
             case CIMType::REFERENCE:             case CIMType::REFERENCE:
                 delete _u._referenceValue;                 delete _u._referenceValue;
                 break;                 break;
               //default:
                   //throw CIMValueInvalidType();
         }         }
     }     }
  
     _init();     _init();
 } }
  
 void CIMValue::toXml(Array<Sint8>& out) const  void CIMValue::toXml(Array<Sint8>& out, Boolean forceTag) const
   {
       /* If the CIMValue is Null, no element is returned.
        Note that it output absolutely nothing. This works for
        everything except qualifiers where the value tag is required in
        any case per the XML specification
       */
   
       if (_isNull)
 { {
           if (forceTag)
               if (_isArray)
                   out << "<VALUE.ARRAY></VALUE.ARRAY>\n";
               else
                   out << "<VALUE></VALUE>\n";
           return;
       }
     if (_isArray)     if (_isArray)
     {     {
         out << "<VALUE.ARRAY>\n";  
   
         switch (_type)         switch (_type)
         {         {
             case CIMType::BOOLEAN:             case CIMType::BOOLEAN:
             {             {
                   // ATTN-RK-P3-20020220: Why can't this just use
                   // _toXml(out, _u._booleanArray->data(), _u._booleanArray->size);
                   // like everybody else?
                   out << "<VALUE.ARRAY>\n";
   
                 for (Uint32 i = 0, n = _u._booleanArray->size; i < n; i++)                 for (Uint32 i = 0, n = _u._booleanArray->size; i < n; i++)
                 {                 {
                     out << "<VALUE>";                     out << "<VALUE>";
                     _toXml(out, Boolean(_u._booleanArray->data()[i]));                     _toXml(out, Boolean(_u._booleanArray->data()[i]));
                     out << "</VALUE>\n";                     out << "</VALUE>\n";
                 }                 }
   
                   out << "</VALUE.ARRAY>\n";
                 break;                 break;
             }             }
  
Line 683 
Line 897 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 _toXml(out, _u._dateTimeArray->data(), _u._dateTimeArray->size);                 _toXml(out, _u._dateTimeArray->data(), _u._dateTimeArray->size);
                 break;                 break;
         }  
  
         out << "</VALUE.ARRAY>\n";              case CIMType::REFERENCE:
                   _toXml(out, _u._referenceArray->data(),
                               _u._referenceArray->size);
                   break;
   
               default:
                   throw CIMValueInvalidType();
           }
     }     }
     else if (_type == CIMType::REFERENCE)     else if (_type == CIMType::REFERENCE)
     {     {
         _u._referenceValue->toXml(out);          // Has to be separate because it uses VALUE.REFERENCE tag
           _toXml(out, *_u._referenceValue);
     }     }
     else     else
     {     {
Line 752 
Line 973 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 _toXml(out, *_u._dateTimeValue);                 _toXml(out, *_u._dateTimeValue);
                 break;                 break;
               default:
                   throw CIMValueInvalidType();
         }         }
  
         out << "</VALUE>\n";         out << "</VALUE>\n";
     }     }
 } }
  
 void CIMValue::print() const  String CIMValue::toXml(Boolean forceTag) const
   {
       Array<Sint8> out;
       toXml(out, forceTag);
       out.append('\0');
       return String(out.getData());
   }
   
   void CIMValue::toMof(Array<Sint8>& out) const
   {
       // if the CIMValue is Null we return nothing.
       // The alternative is to return the Null indicator.
       if (_isNull)
       {
           out << "null";
           return ;
       }
   
   
       if (_isArray)
       {
           switch (_type)
           {
               case CIMType::BOOLEAN:
               {
                   _toMof(out, _u._booleanArray->data(), _u._booleanArray->size);
                   break;
               }
               case CIMType::UINT8:
                   _toMof(out, _u._uint8Array->data(), _u._uint8Array->size);
                   break;
   
               case CIMType::SINT8:
                   _toMof(out, _u._sint8Array->data(), _u._sint8Array->size);
                   break;
   
               case CIMType::UINT16:
                   _toMof(out, _u._uint16Array->data(), _u._uint16Array->size);
                   break;
   
               case CIMType::SINT16:
                   _toMof(out, _u._sint16Array->data(), _u._sint16Array->size);
                   break;
   
               case CIMType::UINT32:
                   _toMof(out, _u._uint32Array->data(), _u._uint32Array->size);
                   break;
   
               case CIMType::SINT32:
                   _toMof(out, _u._sint32Array->data(), _u._sint32Array->size);
                   break;
   
               case CIMType::UINT64:
                   _toMof(out, _u._uint64Array->data(), _u._uint64Array->size);
                   break;
   
               case CIMType::SINT64:
                   _toMof(out, _u._sint64Array->data(), _u._sint64Array->size);
                   break;
   
               case CIMType::REAL32:
                   _toMof(out, _u._real32Array->data(), _u._real32Array->size);
                   break;
   
               case CIMType::REAL64:
                   _toMof(out, _u._real64Array->data(), _u._real64Array->size);
                   break;
   
               case CIMType::CHAR16:
                   _toMof(out, _u._char16Array->data(), _u._char16Array->size);
                   break;
   
               case CIMType::STRING:
                   _toMof(out, _u._stringArray->data(), _u._stringArray->size);
                   break;
   
               case CIMType::DATETIME:
                   _toMof(out, _u._dateTimeArray->data(),
                               _u._dateTimeArray->size);
                   break;
   
               case CIMType::REFERENCE:
                   _toMof(out, _u._referenceArray->data(),
                               _u._referenceArray->size);
                   break;
   
               default:
                   throw CIMValueInvalidType();
           }
       }
       else
       {
           switch (_type)
           {
               case CIMType::BOOLEAN:
                   _toMof(out, Boolean(_u._booleanValue != 0));
                   break;
   
               case CIMType::UINT8:
                   _toMof(out, _u._uint8Value);
                   break;
   
               case CIMType::SINT8:
                   _toMof(out, _u._sint8Value);
                   break;
   
               case CIMType::UINT16:
                   _toMof(out, _u._uint16Value);
                   break;
   
               case CIMType::SINT16:
                   _toMof(out, _u._sint16Value);
                   break;
   
               case CIMType::UINT32:
                   _toMof(out, _u._uint32Value);
                   break;
   
               case CIMType::SINT32:
                   _toMof(out, _u._sint32Value);
                   break;
   
               case CIMType::UINT64:
                   _toMof(out, _u._uint64Value);
                   break;
   
               case CIMType::SINT64:
                   _toMof(out, _u._sint64Value);
                   break;
   
               case CIMType::REAL32:
                   _toMof(out, _u._real32Value);
                   break;
   
               case CIMType::REAL64:
                   _toMof(out, _u._real64Value);
                   break;
   
               case CIMType::CHAR16:
                   _toMof(out, Char16(_u._char16Value));
                   break;
   
               case CIMType::STRING:
                   _toMof(out, *_u._stringValue);
                   break;
   
               case CIMType::DATETIME:
                   _toMof(out, *_u._dateTimeValue);
                   break;
   
               case CIMType::REFERENCE:
                   _toMof(out, *_u._referenceValue);
                   break;
   
               default:
                   throw CIMValueInvalidType();
           }
       }
   }
   
   
   void CIMValue::print( Boolean forceTag, PEGASUS_STD(ostream) &os) const
 { {
     Array<Sint8> tmp;     Array<Sint8> tmp;
     toXml(tmp);      toXml(tmp, forceTag);
     tmp.append('\0');     tmp.append('\0');
     std::cout << tmp.getData() << std::endl;      os << tmp.getData() << PEGASUS_STD(endl);
 } }
  
   
 void CIMValue::set(Boolean x) void CIMValue::set(Boolean x)
 { {
     clear();     clear();
     _u._booleanValue = (Uint8)x;     _u._booleanValue = (Uint8)x;
     _type = CIMType::BOOLEAN;     _type = CIMType::BOOLEAN;
       _isNull = false;
 } }
  
 void CIMValue::set(Uint8 x) void CIMValue::set(Uint8 x)
Line 778 
Line 1164 
     clear();     clear();
     _u._uint8Value = x;     _u._uint8Value = x;
     _type = CIMType::UINT8;     _type = CIMType::UINT8;
       _isNull = false;
 } }
  
 void CIMValue::set(Sint8 x) void CIMValue::set(Sint8 x)
Line 785 
Line 1172 
     clear();     clear();
     _u._sint8Value = x;     _u._sint8Value = x;
     _type = CIMType::SINT8;     _type = CIMType::SINT8;
       _isNull = false;
 } }
  
 void CIMValue::set(Uint16 x) void CIMValue::set(Uint16 x)
Line 792 
Line 1180 
     clear();     clear();
     _u._uint16Value = x;     _u._uint16Value = x;
     _type = CIMType::UINT16;     _type = CIMType::UINT16;
       _isNull = false;
 } }
  
 void CIMValue::set(Sint16 x) void CIMValue::set(Sint16 x)
Line 799 
Line 1188 
     clear();     clear();
     _u._sint16Value = x;     _u._sint16Value = x;
     _type = CIMType::SINT16;     _type = CIMType::SINT16;
       _isNull = false;
 } }
  
 void CIMValue::set(Uint32 x) void CIMValue::set(Uint32 x)
Line 806 
Line 1196 
     clear();     clear();
     _u._uint32Value = x;     _u._uint32Value = x;
     _type = CIMType::UINT32;     _type = CIMType::UINT32;
       _isNull = false;
 } }
  
 void CIMValue::set(Sint32 x) void CIMValue::set(Sint32 x)
Line 813 
Line 1204 
     clear();     clear();
     _u._sint32Value = x;     _u._sint32Value = x;
     _type = CIMType::SINT32;     _type = CIMType::SINT32;
       _isNull = false;
 } }
  
 void CIMValue::set(Uint64 x) void CIMValue::set(Uint64 x)
Line 820 
Line 1212 
     clear();     clear();
     _u._uint64Value = x;     _u._uint64Value = x;
     _type = CIMType::UINT64;     _type = CIMType::UINT64;
       _isNull = false;
 } }
  
 void CIMValue::set(Sint64 x) void CIMValue::set(Sint64 x)
Line 827 
Line 1220 
     clear();     clear();
     _u._sint64Value = x;     _u._sint64Value = x;
     _type = CIMType::SINT64;     _type = CIMType::SINT64;
       _isNull = false;
 } }
  
 void CIMValue::set(Real32 x) void CIMValue::set(Real32 x)
Line 834 
Line 1228 
     clear();     clear();
     _u._real32Value = x;     _u._real32Value = x;
     _type = CIMType::REAL32;     _type = CIMType::REAL32;
       _isNull = false;
 } }
  
 void CIMValue::set(Real64 x) void CIMValue::set(Real64 x)
Line 841 
Line 1236 
     clear();     clear();
     _u._real64Value = x;     _u._real64Value = x;
     _type = CIMType::REAL64;     _type = CIMType::REAL64;
       _isNull = false;
 } }
  
 void CIMValue::set(const Char16& x) void CIMValue::set(const Char16& x)
Line 848 
Line 1244 
     clear();     clear();
     _u._char16Value = x;     _u._char16Value = x;
     _type = CIMType::CHAR16;     _type = CIMType::CHAR16;
       _isNull = false;
 } }
  
 void CIMValue::set(const String& x) void CIMValue::set(const String& x)
Line 855 
Line 1252 
     clear();     clear();
     _u._stringValue = new String(x);     _u._stringValue = new String(x);
     _type = CIMType::STRING;     _type = CIMType::STRING;
       _isNull = false;
 } }
  
 void CIMValue::set(const char* x) void CIMValue::set(const char* x)
 { {
     set(String(x));     set(String(x));
       _isNull = false;
 } }
  
 void CIMValue::set(const CIMDateTime& x) void CIMValue::set(const CIMDateTime& x)
Line 867 
Line 1266 
     clear();     clear();
     _u._dateTimeValue = new CIMDateTime(x);     _u._dateTimeValue = new CIMDateTime(x);
     _type = CIMType::DATETIME;     _type = CIMType::DATETIME;
       _isNull = false;
 } }
  
 void CIMValue::set(const CIMReference& x) void CIMValue::set(const CIMReference& x)
Line 874 
Line 1274 
     clear();     clear();
     _u._referenceValue = new CIMReference(x);     _u._referenceValue = new CIMReference(x);
     _type = CIMType::REFERENCE;     _type = CIMType::REFERENCE;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<Boolean>& x) void CIMValue::set(const Array<Boolean>& x)
Line 882 
Line 1283 
     _Inc(_u._booleanArray = x._rep);     _Inc(_u._booleanArray = x._rep);
     _type = CIMType::BOOLEAN;     _type = CIMType::BOOLEAN;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<Uint8>& x) void CIMValue::set(const Array<Uint8>& x)
Line 890 
Line 1292 
     _Inc(_u._uint8Array = x._rep);     _Inc(_u._uint8Array = x._rep);
     _type = CIMType::UINT8;     _type = CIMType::UINT8;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<Sint8>& x) void CIMValue::set(const Array<Sint8>& x)
Line 898 
Line 1301 
     _Inc(_u._sint8Array = x._rep);     _Inc(_u._sint8Array = x._rep);
     _type = CIMType::SINT8;     _type = CIMType::SINT8;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<Uint16>& x) void CIMValue::set(const Array<Uint16>& x)
Line 906 
Line 1310 
     _Inc(_u._uint16Array = x._rep);     _Inc(_u._uint16Array = x._rep);
     _type = CIMType::UINT16;     _type = CIMType::UINT16;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<Sint16>& x) void CIMValue::set(const Array<Sint16>& x)
Line 914 
Line 1319 
     _Inc(_u._sint16Array = x._rep);     _Inc(_u._sint16Array = x._rep);
     _type = CIMType::SINT16;     _type = CIMType::SINT16;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<Uint32>& x) void CIMValue::set(const Array<Uint32>& x)
Line 922 
Line 1328 
     _Inc(_u._uint32Array = x._rep);     _Inc(_u._uint32Array = x._rep);
     _type = CIMType::UINT32;     _type = CIMType::UINT32;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<Sint32>& x) void CIMValue::set(const Array<Sint32>& x)
Line 930 
Line 1337 
     _Inc(_u._sint32Array = x._rep);     _Inc(_u._sint32Array = x._rep);
     _type = CIMType::SINT32;     _type = CIMType::SINT32;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<Uint64>& x) void CIMValue::set(const Array<Uint64>& x)
Line 938 
Line 1346 
     _Inc(_u._uint64Array = x._rep);     _Inc(_u._uint64Array = x._rep);
     _type = CIMType::UINT64;     _type = CIMType::UINT64;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<Sint64>& x) void CIMValue::set(const Array<Sint64>& x)
Line 946 
Line 1355 
     _Inc(_u._sint64Array = x._rep);     _Inc(_u._sint64Array = x._rep);
     _type = CIMType::SINT64;     _type = CIMType::SINT64;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<Real32>& x) void CIMValue::set(const Array<Real32>& x)
Line 954 
Line 1364 
     _Inc(_u._real32Array = x._rep);     _Inc(_u._real32Array = x._rep);
     _type = CIMType::REAL32;     _type = CIMType::REAL32;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<Real64>& x) void CIMValue::set(const Array<Real64>& x)
Line 962 
Line 1373 
     _Inc(_u._real64Array = x._rep);     _Inc(_u._real64Array = x._rep);
     _type = CIMType::REAL64;     _type = CIMType::REAL64;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<Char16>& x) void CIMValue::set(const Array<Char16>& x)
Line 970 
Line 1382 
     _Inc(_u._char16Array = x._rep);     _Inc(_u._char16Array = x._rep);
     _type = CIMType::CHAR16;     _type = CIMType::CHAR16;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<String>& x) void CIMValue::set(const Array<String>& x)
Line 978 
Line 1391 
     _Inc(_u._stringArray = x._rep);     _Inc(_u._stringArray = x._rep);
     _type = CIMType::STRING;     _type = CIMType::STRING;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::set(const Array<CIMDateTime>& x) void CIMValue::set(const Array<CIMDateTime>& x)
Line 986 
Line 1400 
     _Inc(_u._dateTimeArray = x._rep);     _Inc(_u._dateTimeArray = x._rep);
     _type = CIMType::DATETIME;     _type = CIMType::DATETIME;
     _isArray = true;     _isArray = true;
       _isNull = false;
   }
   
   void CIMValue::set(const Array<CIMReference>& x)
   {
       clear();
       _Inc(_u._referenceArray = x._rep);
       _type = CIMType::REFERENCE;
       _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::get(Boolean& x) const void CIMValue::get(Boolean& x) const
Line 1214 
Line 1638 
  
 void CIMValue::get(Array<CIMDateTime>& x) const void CIMValue::get(Array<CIMDateTime>& x) const
 { {
   #ifdef CIMValueisNullexception
       if (_isNull)
           throw CIMValueIsNull();
   #endif
   
     if (_type != CIMType::DATETIME || !_isArray)     if (_type != CIMType::DATETIME || !_isArray)
         throw TypeMismatch();         throw TypeMismatch();
  
     x.set(_u._dateTimeArray);     x.set(_u._dateTimeArray);
 } }
  
   void CIMValue::get(Array<CIMReference>& x) const
   {
       if (_type != CIMType::REFERENCE || !_isArray)
           throw TypeMismatch();
   
       x.set(_u._referenceArray);
   }
   
 void CIMValue::_init() void CIMValue::_init()
 { {
     _type = CIMType::NONE;     _type = CIMType::NONE;
     _isArray = false;     _isArray = false;
       _isNull = true;
     _u._voidPtr = 0;     _u._voidPtr = 0;
 } }
  
Line 1232 
Line 1670 
     if (!x.typeCompatible(y))     if (!x.typeCompatible(y))
         return false;         return false;
  
       if (x._isNull != y._isNull)
           return false;
   
     if (x._isArray)     if (x._isArray)
     {     {
         switch (x._type)         switch (x._type)
Line 1291 
Line 1732 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 return Array<CIMDateTime>(x._u._dateTimeArray) ==                 return Array<CIMDateTime>(x._u._dateTimeArray) ==
                     Array<CIMDateTime>(y._u._dateTimeArray);                     Array<CIMDateTime>(y._u._dateTimeArray);
   
               case CIMType::REFERENCE:
                   return Array<CIMReference>(x._u._referenceArray) ==
                       Array<CIMReference>(y._u._referenceArray);
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
     else     else
Line 1341 
Line 1788 
  
             case CIMType::REFERENCE:             case CIMType::REFERENCE:
                 return *x._u._referenceValue == *y._u._referenceValue;                 return *x._u._referenceValue == *y._u._referenceValue;
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
  
Line 1350 
Line 1799 
  
 void CIMValue::setNullValue(CIMType type, Boolean isArray, Uint32 arraySize) void CIMValue::setNullValue(CIMType type, Boolean isArray, Uint32 arraySize)
 { {
   
     clear();     clear();
  
     if (isArray)     if (isArray)
Line 1411 
Line 1861 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 set(Array<CIMDateTime>(arraySize));                 set(Array<CIMDateTime>(arraySize));
                 break;                 break;
   
               case CIMType::REFERENCE:
                   set(Array<CIMReference>(arraySize));
                   break;
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
     else     else
Line 1476 
Line 1932 
             case CIMType::REFERENCE:             case CIMType::REFERENCE:
                 set(CIMReference());                 set(CIMReference());
                 break;                 break;
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
   
       // Set the Null attribute. Note that this must be after the set
       // because the set functions sets the _isNull.
   
       _isNull = true;
 } }
  
 String CIMValue::toString() const String CIMValue::toString() const
 { {
     Array<Sint8> out;     Array<Sint8> out;
  
       //ATTN: Not sure what we should do with getstring for Null CIMValues
       //Choice return empty string or exception out.
       if (_isNull)
           return String();
   
     if (_isArray)     if (_isArray)
     {     {
         switch (_type)         switch (_type)
         {         {
             case CIMType::BOOLEAN:             case CIMType::BOOLEAN:
             {             {
                 for (Uint32 i = 0, n = _u._booleanArray->size; i < n; i++)                  int size = _u._booleanArray->size;
                   bool *p = _u._booleanArray->data();
                   for (Uint32 i = 0; i < _u._booleanArray->size; i++)
                 {                 {
                     _toXml(out, Boolean(_u._booleanArray->data()[i]));                      _toString(out, Boolean(_u._booleanArray->data()[i]));
   
                     out << " ";                     out << " ";
                 }                 }
                 break;                 break;
             }             }
  
             case CIMType::UINT8:             case CIMType::UINT8:
                 _toStr(out, _u._uint8Array->data(), _u._uint8Array->size);                  _toString(out, _u._uint8Array->data(), _u._uint8Array->size);
                 break;                 break;
  
             case CIMType::SINT8:             case CIMType::SINT8:
                 _toStr(out, _u._sint8Array->data(), _u._sint8Array->size);                  _toString(out, _u._sint8Array->data(), _u._sint8Array->size);
                 break;                 break;
  
             case CIMType::UINT16:             case CIMType::UINT16:
                 _toStr(out, _u._uint16Array->data(), _u._uint16Array->size);                  _toString(out, _u._uint16Array->data(), _u._uint16Array->size);
                 break;                 break;
  
             case CIMType::SINT16:             case CIMType::SINT16:
                 _toStr(out, _u._sint16Array->data(), _u._sint16Array->size);                  _toString(out, _u._sint16Array->data(), _u._sint16Array->size);
                 break;                 break;
  
             case CIMType::UINT32:             case CIMType::UINT32:
                 _toStr(out, _u._uint32Array->data(), _u._uint32Array->size);                  _toString(out, _u._uint32Array->data(), _u._uint32Array->size);
                 break;                 break;
  
             case CIMType::SINT32:             case CIMType::SINT32:
                 _toStr(out, _u._sint32Array->data(), _u._sint32Array->size);                  _toString(out, _u._sint32Array->data(), _u._sint32Array->size);
                 break;                 break;
  
             case CIMType::UINT64:             case CIMType::UINT64:
                 _toStr(out, _u._uint64Array->data(), _u._uint64Array->size);                  _toString(out, _u._uint64Array->data(), _u._uint64Array->size);
                 break;                 break;
  
             case CIMType::SINT64:             case CIMType::SINT64:
                 _toStr(out, _u._sint64Array->data(), _u._sint64Array->size);                  _toString(out, _u._sint64Array->data(), _u._sint64Array->size);
                 break;                 break;
  
             case CIMType::REAL32:             case CIMType::REAL32:
                 _toStr(out, _u._real32Array->data(), _u._real32Array->size);                  _toString(out, _u._real32Array->data(), _u._real32Array->size);
                 break;                 break;
  
             case CIMType::REAL64:             case CIMType::REAL64:
                 _toStr(out, _u._real64Array->data(), _u._real64Array->size);                  _toString(out, _u._real64Array->data(), _u._real64Array->size);
                 break;                 break;
  
             case CIMType::CHAR16:             case CIMType::CHAR16:
                 _toStr(out, _u._char16Array->data(), _u._char16Array->size);                  _toString(out, _u._char16Array->data(), _u._char16Array->size);
                 break;                 break;
  
             case CIMType::STRING:             case CIMType::STRING:
                 _toStr(out, _u._stringArray->data(), _u._stringArray->size);                  _toString(out, _u._stringArray->data(), _u._stringArray->size);
                 break;                 break;
  
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 _toStr(out, _u._dateTimeArray->data(), _u._dateTimeArray->size);                  _toString(out, _u._dateTimeArray->data(), _u._dateTimeArray->size);
                 break;                 break;
   
               case CIMType::REFERENCE:
                   _toString(out, _u._referenceArray->data(), _u._referenceArray->size);
                   break;
   
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
     else if (_type == CIMType::REFERENCE)  
     {  
         // ATTN: work on this:  
     }  
     else     else
     {     {
         switch (_type)         switch (_type)
         {         {
             case CIMType::BOOLEAN:             case CIMType::BOOLEAN:
                 _toXml(out, Boolean(_u._booleanValue != 0));                  _toString(out, Boolean(_u._booleanValue != 0));
                 break;                 break;
  
             case CIMType::UINT8:             case CIMType::UINT8:
                 _toXml(out, _u._uint8Value);                  _toString(out, _u._uint8Value);
                 break;                 break;
  
             case CIMType::SINT8:             case CIMType::SINT8:
                 _toXml(out, _u._sint8Value);                  _toString(out, _u._sint8Value);
                 break;                 break;
  
             case CIMType::UINT16:             case CIMType::UINT16:
                 _toXml(out, _u._uint16Value);                  _toString(out, _u._uint16Value);
                 break;                 break;
  
             case CIMType::SINT16:             case CIMType::SINT16:
                 _toXml(out, _u._sint16Value);                  _toString(out, _u._sint16Value);
                 break;                 break;
  
             case CIMType::UINT32:             case CIMType::UINT32:
                 _toXml(out, _u._uint32Value);                  _toString(out, _u._uint32Value);
                 break;                 break;
  
             case CIMType::SINT32:             case CIMType::SINT32:
                 _toXml(out, _u._sint32Value);                  _toString(out, _u._sint32Value);
                 break;                 break;
  
             case CIMType::UINT64:             case CIMType::UINT64:
                 _toXml(out, _u._uint64Value);                  _toString(out, _u._uint64Value);
                 break;                 break;
  
             case CIMType::SINT64:             case CIMType::SINT64:
                 _toXml(out, _u._sint64Value);                  _toString(out, _u._sint64Value);
                 break;                 break;
  
             case CIMType::REAL32:             case CIMType::REAL32:
                 _toXml(out, _u._real32Value);                  _toString(out, _u._real32Value);
                 break;                 break;
  
             case CIMType::REAL64:             case CIMType::REAL64:
                 _toXml(out, _u._real64Value);                  _toString(out, _u._real64Value);
                 break;                 break;
  
             case CIMType::CHAR16:             case CIMType::CHAR16:
                 _toXml(out, Char16(_u._char16Value));                  _toString(out, Char16(_u._char16Value));
                 break;                 break;
  
             case CIMType::STRING:             case CIMType::STRING:
                 _toXml(out, *_u._stringValue);                  _toString(out, *_u._stringValue);
                 break;                 break;
  
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 _toXml(out, *_u._dateTimeValue);                  _toString(out, *_u._dateTimeValue);
                 break;                 break;
   
               case CIMType::REFERENCE:
                   _toString(out, *_u._referenceValue);
                   break;
   
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
  


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.24

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2