(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.37 and 1.46

version 1.37, 2002/08/16 01:28:06 version 1.46, 2004/04/27 19:23:27
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2003////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,  // Copyright (c) 2000, 2001, 2002  BMC Software, Hewlett-Packard Development
 // The Open Group, Tivoli Systems  // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
   // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
   // IBM Corp.; EMC Corporation, The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 37 
Line 39 
 #include "Union.h" #include "Union.h"
 #include "Indentor.h" #include "Indentor.h"
 #include "XmlWriter.h" #include "XmlWriter.h"
   #include "CommonUTF.h"
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
Line 45 
Line 48 
 #undef PEGASUS_ARRAY_T #undef PEGASUS_ARRAY_T
  
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
   
 // //
 // _toString routines: // _toString routines:
 // //
Line 68 
Line 72 
  
 inline void _toString(Array<Sint8>& out, Char16 x) inline void _toString(Array<Sint8>& out, Char16 x)
 { {
     // ATTN: How to convert 16-bit characters to printable form?      // We need to convert the Char16 to UTF8 then append the UTF8
     out.append(Sint8(x));      // character into the array.
       // NOTE: The UTF8 character could be several bytes long.
       // WARNING: This function will put in replacement character for
       // all characters that have surogate pairs.
   
       char str[6];
       memset(str,0x00,sizeof(str));
       char* charIN = (char *)&x;
   
       const Uint16 *strsrc = (Uint16 *)charIN;
       Uint16 *endsrc = (Uint16 *)&charIN[1];
   
       Uint8 *strtgt = (Uint8 *)str;
       Uint8 *endtgt = (Uint8 *)&str[5];
   
       UTF16toUTF8(&strsrc,
                   endsrc,
                   &strtgt,
                   endtgt);
   
       out.append((Sint8 *)str, UTF_8_COUNT_TRAIL_BYTES(str[0]) +1);
 } }
  
 inline void _toString(Array<Sint8>& out, const String& x) inline void _toString(Array<Sint8>& out, const String& x)
Line 79 
Line 103 
  
 inline void _toString(Array<Sint8>& out, const CIMDateTime& x) inline void _toString(Array<Sint8>& out, const CIMDateTime& x)
 { {
     out << x.getString();      out << x.toString();
 } }
  
 inline void _toString(Array<Sint8>& out, const CIMObjectPath& x) inline void _toString(Array<Sint8>& out, const CIMObjectPath& x)
Line 118 
Line 142 
  
     void reset()     void reset()
     {     {
         _type = CIMTYPE_NONE;          _type = CIMTYPE_BOOLEAN;
         _isArray = false;         _isArray = false;
         _isNull = true;         _isNull = true;
         _u._voidPtr = 0;          _u._booleanValue = false;
     }     }
  
     CIMType _type;     CIMType _type;
Line 356 
Line 380 
     _rep->_type = x._rep->_type;     _rep->_type = x._rep->_type;
     _rep->_isArray = x._rep->_isArray;     _rep->_isArray = x._rep->_isArray;
     _rep->_isNull = x._rep->_isNull;     _rep->_isNull = x._rep->_isNull;
     _rep->_u._voidPtr = 0;  
  
     if (_rep->_isArray)     if (_rep->_isArray)
     {     {
Line 436 
Line 459 
                 _rep->_u._referenceArray =                 _rep->_u._referenceArray =
                     new Array<CIMObjectPath>(*(x._rep->_u._referenceArray));                     new Array<CIMObjectPath>(*(x._rep->_u._referenceArray));
                 break;                 break;
   
             default:             default:
                 throw CIMValueInvalidType();                  PEGASUS_ASSERT(false);
         }         }
     }     }
     else     else
     {     {
         switch (_rep->_type)         switch (_rep->_type)
         {         {
             case CIMTYPE_NONE:  
                 break;  
   
             case CIMTYPE_BOOLEAN:             case CIMTYPE_BOOLEAN:
                 _rep->_u._booleanValue = x._rep->_u._booleanValue;                 _rep->_u._booleanValue = x._rep->_u._booleanValue;
                 break;                 break;
Line 511 
Line 532 
  
             // Should never get here. testing complete enum             // Should never get here. testing complete enum
             default:             default:
                 throw CIMValueInvalidType();                  PEGASUS_ASSERT(false);
         }         }
     }     }
 } }
  
 //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()
 { {
     if (_rep->_isArray)     if (_rep->_isArray)
Line 585 
Line 603 
                 delete _rep->_u._referenceArray;                 delete _rep->_u._referenceArray;
                 break;                 break;
  
             //default:              default:
                 //throw CIMValueInvalidType();                  PEGASUS_ASSERT(false);
         }         }
     }     }
     else     else
Line 618 
Line 636 
             case CIMTYPE_REFERENCE:             case CIMTYPE_REFERENCE:
                 delete _rep->_u._referenceValue;                 delete _rep->_u._referenceValue;
                 break;                 break;
             //default:  
                 //throw CIMValueInvalidType();              default:
                   PEGASUS_ASSERT(false);
         }         }
     }     }
  
Line 650 
Line 669 
  
     switch (_rep->_type)     switch (_rep->_type)
     {     {
         case CIMTYPE_NONE:  
             return 0;  
             break;  
   
         case CIMTYPE_BOOLEAN:         case CIMTYPE_BOOLEAN:
             return _rep->_u._booleanArray->size();             return _rep->_u._booleanArray->size();
             break;             break;
Line 713 
Line 728 
         case CIMTYPE_REFERENCE:         case CIMTYPE_REFERENCE:
             return _rep->_u._referenceArray->size();             return _rep->_u._referenceArray->size();
             break;             break;
         // Should never get here. switch on complete enum  
         default:          //default:  // Handled below
             throw CIMValueInvalidType();  
     }     }
  
     // Unreachable!     // Unreachable!
Line 730 
Line 744 
  
 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 796 
Line 809 
             case CIMTYPE_REFERENCE:             case CIMTYPE_REFERENCE:
                 set(Array<CIMObjectPath>(arraySize));                 set(Array<CIMObjectPath>(arraySize));
                 break;                 break;
   
             default:             default:
                 throw CIMValueInvalidType();                  throw TypeMismatchException();
         }         }
     }     }
     else     else
Line 863 
Line 877 
             case CIMTYPE_REFERENCE:             case CIMTYPE_REFERENCE:
                 set(CIMObjectPath());                 set(CIMObjectPath());
                 break;                 break;
   
             default:             default:
                 throw CIMValueInvalidType();                  throw TypeMismatchException();
         }         }
     }     }
  
Line 1132 
Line 1147 
 void CIMValue::get(Boolean& x) const void CIMValue::get(Boolean& x) const
 { {
     if (_rep->_type != CIMTYPE_BOOLEAN || _rep->_isArray)     if (_rep->_type != CIMTYPE_BOOLEAN || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._booleanValue != 0;     x = _rep->_u._booleanValue != 0;
 } }
  
 void CIMValue::get(Uint8& x) const void CIMValue::get(Uint8& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT8 || _rep->_isArray)     if (_rep->_type != CIMTYPE_UINT8 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._uint8Value;     x = _rep->_u._uint8Value;
 } }
  
 void CIMValue::get(Sint8& x) const void CIMValue::get(Sint8& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT8 || _rep->_isArray)     if (_rep->_type != CIMTYPE_SINT8 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._sint8Value;     x = _rep->_u._sint8Value;
 } }
  
 void CIMValue::get(Uint16& x) const void CIMValue::get(Uint16& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT16 || _rep->_isArray)     if (_rep->_type != CIMTYPE_UINT16 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._uint16Value;     x = _rep->_u._uint16Value;
 } }
  
 void CIMValue::get(Sint16& x) const void CIMValue::get(Sint16& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT16 || _rep->_isArray)     if (_rep->_type != CIMTYPE_SINT16 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._sint16Value;     x = _rep->_u._sint16Value;
 } }
  
 void CIMValue::get(Uint32& x) const void CIMValue::get(Uint32& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT32 || _rep->_isArray)     if (_rep->_type != CIMTYPE_UINT32 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._uint32Value;     x = _rep->_u._uint32Value;
 } }
  
 void CIMValue::get(Sint32& x) const void CIMValue::get(Sint32& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT32 || _rep->_isArray)     if (_rep->_type != CIMTYPE_SINT32 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._sint32Value;     x = _rep->_u._sint32Value;
 } }
  
 void CIMValue::get(Uint64& x) const void CIMValue::get(Uint64& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT64 || _rep->_isArray)     if (_rep->_type != CIMTYPE_UINT64 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._uint64Value;     x = _rep->_u._uint64Value;
 } }
  
 void CIMValue::get(Sint64& x) const void CIMValue::get(Sint64& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT64 || _rep->_isArray)     if (_rep->_type != CIMTYPE_SINT64 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._sint64Value;     x = _rep->_u._sint64Value;
 } }
  
 void CIMValue::get(Real32& x) const void CIMValue::get(Real32& x) const
 { {
     if (_rep->_type != CIMTYPE_REAL32 || _rep->_isArray)     if (_rep->_type != CIMTYPE_REAL32 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._real32Value;     x = _rep->_u._real32Value;
 } }
  
 void CIMValue::get(Real64& x) const void CIMValue::get(Real64& x) const
 { {
     if (_rep->_type != CIMTYPE_REAL64 || _rep->_isArray)     if (_rep->_type != CIMTYPE_REAL64 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._real64Value;     x = _rep->_u._real64Value;
 } }
  
 void CIMValue::get(Char16& x) const void CIMValue::get(Char16& x) const
 { {
     if (_rep->_type != CIMTYPE_CHAR16 || _rep->_isArray)     if (_rep->_type != CIMTYPE_CHAR16 || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = _rep->_u._char16Value;     x = _rep->_u._char16Value;
 } }
  
 void CIMValue::get(String& x) const void CIMValue::get(String& x) const
 { {
     if (_rep->_type != CIMTYPE_STRING || _rep->_isArray)     if (_rep->_type != CIMTYPE_STRING || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._stringValue;     x = *_rep->_u._stringValue;
 } }
  
 void CIMValue::get(CIMDateTime& x) const void CIMValue::get(CIMDateTime& x) const
 { {
     if (_rep->_type != CIMTYPE_DATETIME || _rep->_isArray)     if (_rep->_type != CIMTYPE_DATETIME || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._dateTimeValue;     x = *_rep->_u._dateTimeValue;
 } }
  
 void CIMValue::get(CIMObjectPath& x) const void CIMValue::get(CIMObjectPath& x) const
 { {
     if (_rep->_type != CIMTYPE_REFERENCE || _rep->_isArray)     if (_rep->_type != CIMTYPE_REFERENCE || _rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._referenceValue;     x = *_rep->_u._referenceValue;
 } }
  
 void CIMValue::get(Array<Boolean>& x) const void CIMValue::get(Array<Boolean>& x) const
 { {
     if (_rep->_type != CIMTYPE_BOOLEAN || !_rep->_isArray)     if (_rep->_type != CIMTYPE_BOOLEAN || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._booleanArray;     x = *_rep->_u._booleanArray;
 } }
  
 void CIMValue::get(Array<Uint8>& x) const void CIMValue::get(Array<Uint8>& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT8 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_UINT8 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._uint8Array;     x = *_rep->_u._uint8Array;
 } }
  
 void CIMValue::get(Array<Sint8>& x) const void CIMValue::get(Array<Sint8>& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT8 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_SINT8 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._sint8Array;     x = *_rep->_u._sint8Array;
 } }
  
 void CIMValue::get(Array<Uint16>& x) const void CIMValue::get(Array<Uint16>& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT16 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_UINT16 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._uint16Array;     x = *_rep->_u._uint16Array;
 } }
  
 void CIMValue::get(Array<Sint16>& x) const void CIMValue::get(Array<Sint16>& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT16 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_SINT16 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._sint16Array;     x = *_rep->_u._sint16Array;
 } }
  
 void CIMValue::get(Array<Uint32>& x) const void CIMValue::get(Array<Uint32>& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT32 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_UINT32 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._uint32Array;     x = *_rep->_u._uint32Array;
 } }
  
 void CIMValue::get(Array<Sint32>& x) const void CIMValue::get(Array<Sint32>& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT32 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_SINT32 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._sint32Array;     x = *_rep->_u._sint32Array;
 } }
  
 void CIMValue::get(Array<Uint64>& x) const void CIMValue::get(Array<Uint64>& x) const
 { {
     if (_rep->_type != CIMTYPE_UINT64 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_UINT64 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._uint64Array;     x = *_rep->_u._uint64Array;
 } }
  
 void CIMValue::get(Array<Sint64>& x) const void CIMValue::get(Array<Sint64>& x) const
 { {
     if (_rep->_type != CIMTYPE_SINT64 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_SINT64 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._sint64Array;     x = *_rep->_u._sint64Array;
 } }
  
 void CIMValue::get(Array<Real32>& x) const void CIMValue::get(Array<Real32>& x) const
 { {
     if (_rep->_type != CIMTYPE_REAL32 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_REAL32 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._real32Array;     x = *_rep->_u._real32Array;
 } }
  
 void CIMValue::get(Array<Real64>& x) const void CIMValue::get(Array<Real64>& x) const
 { {
     if (_rep->_type != CIMTYPE_REAL64 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_REAL64 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._real64Array;     x = *_rep->_u._real64Array;
 } }
  
 void CIMValue::get(Array<Char16>& x) const void CIMValue::get(Array<Char16>& x) const
 { {
     if (_rep->_type != CIMTYPE_CHAR16 || !_rep->_isArray)     if (_rep->_type != CIMTYPE_CHAR16 || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._char16Array;     x = *_rep->_u._char16Array;
 } }
  
 void CIMValue::get(Array<String>& x) const void CIMValue::get(Array<String>& x) const
 { {
     if (_rep->_type != CIMTYPE_STRING || !_rep->_isArray)     if (_rep->_type != CIMTYPE_STRING || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._stringArray;     x = *_rep->_u._stringArray;
 } }
  
 void CIMValue::get(Array<CIMDateTime>& x) const void CIMValue::get(Array<CIMDateTime>& x) const
 { {
 // ATTN-RK-20020815: Use UninitializedObject exception here if CIMValue is null?  
   
     if (_rep->_type != CIMTYPE_DATETIME || !_rep->_isArray)     if (_rep->_type != CIMTYPE_DATETIME || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._dateTimeArray;     x = *_rep->_u._dateTimeArray;
 } }
  
 void CIMValue::get(Array<CIMObjectPath>& x) const void CIMValue::get(Array<CIMObjectPath>& x) const
 { {
     if (_rep->_type != CIMTYPE_REFERENCE || !_rep->_isArray)     if (_rep->_type != CIMTYPE_REFERENCE || !_rep->_isArray)
         throw TypeMismatch();          throw TypeMismatchException();
  
       if (!_rep->_isNull)
     x = *_rep->_u._referenceArray;     x = *_rep->_u._referenceArray;
 } }
  
Line 1442 
Line 1485 
             case CIMTYPE_REFERENCE:             case CIMTYPE_REFERENCE:
                 return (*_rep->_u._referenceArray) ==                 return (*_rep->_u._referenceArray) ==
                     (*x._rep->_u._referenceArray);                     (*x._rep->_u._referenceArray);
   
             default:             default:
                 throw CIMValueInvalidType();                  PEGASUS_ASSERT(false);
         }         }
     }     }
     else     else
Line 1498 
Line 1542 
                     *x._rep->_u._referenceValue;                     *x._rep->_u._referenceValue;
  
             default:             default:
                 throw CIMValueInvalidType();                  PEGASUS_ASSERT(false);
         }         }
     }     }
  
Line 1601 
Line 1645 
                 break;                 break;
  
             default:             default:
                 throw CIMValueInvalidType();                  PEGASUS_ASSERT(false);
         }         }
     }     }
     else     else
Line 1669 
Line 1713 
                 break;                 break;
  
             default:             default:
                 throw CIMValueInvalidType();                  PEGASUS_ASSERT(false);
         }         }
     }     }
  


Legend:
Removed from v.1.37  
changed lines
  Added in v.1.46

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2