(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.12 and 1.13

version 1.12, 2001/12/13 14:53:55 version 1.13, 2002/02/18 13:59:48
Line 23 
Line 23 
 // Author: Mike Brasher (mbrasher@bmc.com) // Author: Mike Brasher (mbrasher@bmc.com)
 // //
 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
   //              Karl Schopmeyer, (k.schopmeyer@opengroup.org)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 382 
Line 383 
 template<class T> template<class T>
 void _toMof(Array<Sint8>& out, const T* p, Uint32 size) void _toMof(Array<Sint8>& out, const T* p, Uint32 size)
 { {
       //ATTNKS: Account for the Null value here
     Boolean isFirstEntry = true;     Boolean isFirstEntry = true;
     // if there are any entries in the array output them     // if there are any entries in the array output them
     if (size)     if (size)
Line 495 
Line 497 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 _Inc(_u._dateTimeArray = x._u._dateTimeArray);                 _Inc(_u._dateTimeArray = x._u._dateTimeArray);
                 break;                 break;
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
     else     else
Line 564 
Line 568 
                 _u._referenceValue                 _u._referenceValue
                     = new CIMReference(*(x._u._referenceValue));                     = new CIMReference(*(x._u._referenceValue));
                 break;                 break;
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
 } }
Line 637 
Line 643 
  
         case CIMType::REFERENCE:         case CIMType::REFERENCE:
             return 0;             return 0;
           default:
               throw CIMValueInvalidType();
     }     }
  
     // Unreachable!     // Unreachable!
Line 644 
Line 652 
     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.
 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 705 
Line 720 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 _Dec(_u._dateTimeArray);                 _Dec(_u._dateTimeArray);
                 break;                 break;
               //default:
                   //throw CIMValueInvalidType();
         }         }
     }     }
     else     else
Line 736 
Line 753 
             case CIMType::REFERENCE:             case CIMType::REFERENCE:
                 delete _u._referenceValue;                 delete _u._referenceValue;
                 break;                 break;
               //default:
                   //throw CIMValueInvalidType();
         }         }
     }     }
  
Line 744 
Line 763 
  
 void CIMValue::toXml(Array<Sint8>& out) const void CIMValue::toXml(Array<Sint8>& out) const
 { {
       // If the CIMValue is Null, no element is returned.
       //ATTNCH: Feb 12 added the isNull test KS
       // Note that I ouptut absolutly nothing
   
       if (_isNull)
       {
           // out << "\n";
           return;
       }
     if (_isArray)     if (_isArray)
     {     {
         out << "<VALUE.ARRAY>\n";         out << "<VALUE.ARRAY>\n";
Line 812 
Line 840 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 _toXml(out, _u._dateTimeArray->data(), _u._dateTimeArray->size);                 _toXml(out, _u._dateTimeArray->data(), _u._dateTimeArray->size);
                 break;                 break;
               default:
                   throw CIMValueInvalidType();
         }         }
  
         out << "</VALUE.ARRAY>\n";         out << "</VALUE.ARRAY>\n";
Line 881 
Line 911 
             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";
Line 895 
Line 927 
     return String(out.getData());     return String(out.getData());
 } }
  
 void CIMValue::toMof(Array<Sint8>& out) const    //ATTNKS:  void CIMValue::toMof(Array<Sint8>& out) const
 { {
       // if the CIMValue is Null we return nothing.
       if (_isNull)
           return;
   
     if (_isArray)     if (_isArray)
     {     {
         switch (_type)         switch (_type)
Line 904 
Line 940 
             case CIMType::BOOLEAN:             case CIMType::BOOLEAN:
             {             {
                 for (Uint32 i = 0, n = _u._booleanArray->size; i < n; i++)                 for (Uint32 i = 0, n = _u._booleanArray->size; i < n; i++)
                 {  
                     _toMof(out, Boolean(_u._booleanArray->data()[i]));                     _toMof(out, Boolean(_u._booleanArray->data()[i]));
                 }  
                 break;                 break;
             }             }
             case CIMType::UINT8:             case CIMType::UINT8:
Line 960 
Line 994 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 _toMof(out, _u._dateTimeArray->data(),                 _toMof(out, _u._dateTimeArray->data(),
                             _u._dateTimeArray->size); break;                             _u._dateTimeArray->size); break;
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
     else if (_type == CIMType::REFERENCE)     else if (_type == CIMType::REFERENCE)
Line 1025 
Line 1061 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 _toMof(out, *_u._dateTimeValue);                 _toMof(out, *_u._dateTimeValue);
                 break;                 break;
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
 } }
Line 1038 
Line 1076 
     os << tmp.getData() << PEGASUS_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 1050 
Line 1090 
     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 1057 
Line 1098 
     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 1064 
Line 1106 
     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 1071 
Line 1114 
     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 1078 
Line 1122 
     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 1085 
Line 1130 
     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 1092 
Line 1138 
     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 1099 
Line 1146 
     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 1106 
Line 1154 
     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 1113 
Line 1162 
     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 1120 
Line 1170 
     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 1127 
Line 1178 
     clear();     clear();
     new(_u._stringValue) String(x);     new(_u._stringValue) 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 1139 
Line 1192 
     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 1146 
Line 1200 
     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 1500 
Line 1555 
  
 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();
  
Line 1519 
Line 1579 
     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 1578 
Line 1641 
             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);
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
     else     else
Line 1630 
Line 1695 
  
             case CIMType::REFERENCE:             case CIMType::REFERENCE:
                 return *x._u._referenceValue == *y._u._referenceValue;                 return *x._u._referenceValue == *y._u._referenceValue;
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
  
Line 1639 
Line 1706 
  
 void CIMValue::setNullValue(CIMType type, Boolean isArray, Uint32 arraySize) void CIMValue::setNullValue(CIMType type, Boolean isArray, Uint32 arraySize)
 { {
     _isNull = true;  
  
     clear();     clear();
  
Line 1702 
Line 1768 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 set(Array<CIMDateTime>(arraySize));                 set(Array<CIMDateTime>(arraySize));
                 break;                 break;
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
     else     else
Line 1767 
Line 1835 
             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 (_isArray)     if (_isArray)
     {     {
         switch (_type)         switch (_type)
Line 1842 
Line 1920 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 _toString(out, _u._dateTimeArray->data(), _u._dateTimeArray->size);                 _toString(out, _u._dateTimeArray->data(), _u._dateTimeArray->size);
                 break;                 break;
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
     else if (_type == CIMType::REFERENCE)     else if (_type == CIMType::REFERENCE)
Line 1907 
Line 1987 
             case CIMType::DATETIME:             case CIMType::DATETIME:
                 _toString(out, *_u._dateTimeValue);                 _toString(out, *_u._dateTimeValue);
                 break;                 break;
               default:
                   throw CIMValueInvalidType();
         }         }
     }     }
  


Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2