(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.11.2.2

version 1.2, 2001/02/26 04:33:28 version 1.11.2.2, 2001/08/01 11:17:36
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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL  // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING  // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER  // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 // DEALINGS IN THE SOFTWARE.  // 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  //==============================================================================
 //BEGIN_HISTORY  
 // //
 // Author:  // Author: Mike Brasher (mbrasher@bmc.com)
 // //
 // $Log$  // Modified By:
 // 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 37 
  
 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 179 
Line 170 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // _toXml() routines:  // _toXml() and _toMof routines:
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
Line 187 
Line 178 
 { {
     out << (x ? "TRUE" : "FALSE");     out << (x ? "TRUE" : "FALSE");
 } }
   inline void _toMof(Array<Sint8>& out, Boolean x)
   {
       out << (x ? "TRUE" : "FALSE");
   }
  
 template<class T> template<class T>
 inline void _integerToXml(Array<Sint8>& out, const T& x) inline void _integerToXml(Array<Sint8>& out, const T& x)
Line 195 
Line 190 
     sprintf(buffer, "%d", x);     sprintf(buffer, "%d", x);
     out << (char*)buffer;     out << (char*)buffer;
 } }
   /* ATTNKS template<class T>
   inline void _integerToMof(Array<Sint8>& out, const T& x)
   {
       char buffer[32];
       sprintf(buffer, "%d", x);
       out << (char*)buffer;
   }
   */
 inline void _toXml(Array<Sint8>& out, Uint8 x) { _integerToXml(out, x); } inline void _toXml(Array<Sint8>& out, Uint8 x) { _integerToXml(out, x); }
   inline void _toMof(Array<Sint8>& out, Uint8 x) { _integerToXml(out, x); }
  
 inline void _toXml(Array<Sint8>& out, Sint8 x) { _integerToXml(out, x); } inline void _toXml(Array<Sint8>& out, Sint8 x) { _integerToXml(out, x); }
   inline void _toMof(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, Uint16 x) { _integerToXml(out, x); }
   inline void _toMof(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, Sint16 x) { _integerToXml(out, x); }
   inline void _toMof(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, Uint32 x) { _integerToXml(out, x); }
   inline void _toMof(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, Sint32 x) { _integerToXml(out, x); }
   inline void _toMof(Array<Sint8>& out, Sint32 x) { _integerToXml(out, x); }
  
 inline void _toXml(Array<Sint8>& out, Uint64 x) inline void _toXml(Array<Sint8>& out, Uint64 x)
 { {
Line 214 
Line 222 
     _UnsignedIntToStr(x, buffer);     _UnsignedIntToStr(x, buffer);
     out << buffer;     out << buffer;
 } }
   inline void _toMof(Array<Sint8>& out, Uint64 x)
   {
       char buffer[128];
       _UnsignedIntToStr(x, buffer);
       out << buffer;
   }
  
 inline void _toXml(Array<Sint8>& out, Sint64 x) inline void _toXml(Array<Sint8>& out, Sint64 x)
 { {
Line 221 
Line 235 
     _SignedIntToStr(x, buffer);     _SignedIntToStr(x, buffer);
     out << buffer;     out << buffer;
 } }
   inline void _toMof(Array<Sint8>& out, Sint64 x)
   {
       char buffer[128];
       _SignedIntToStr(x, buffer);
       out << buffer;
   }
  
 void _toXml(Array<Sint8>& out, Real32 x) void _toXml(Array<Sint8>& out, Real32 x)
 { {
Line 229 
Line 249 
     sprintf(buffer, "%f", x);     sprintf(buffer, "%f", x);
     out << buffer;     out << buffer;
 } }
   void _toMof(Array<Sint8>& out, Real32 x)
   {
       // ATTN: Does this format match the CIM/XML format?
       char buffer[128];
       sprintf(buffer, "%f", x);
       out << buffer;
   }
  
 void _toXml(Array<Sint8>& out, Real64 x) void _toXml(Array<Sint8>& out, Real64 x)
 { {
Line 236 
Line 263 
     sprintf(buffer, "%f", x);     sprintf(buffer, "%f", x);
     out << buffer;     out << buffer;
 } }
   void _toMof(Array<Sint8>& out, Real64 x)
   {
       char buffer[128];
       sprintf(buffer, "%f", x);
       out << buffer;
   }
  
 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 _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 _toMof(Array<Sint8>& out, const String& x)
   {
       out << "\"";
       const Char16* tmp = x.getData();
       char c;
       while (c = *tmp++)
       {
           switch (c)
           {
               case '"':
                   out.append("'", 1);
                   break;
   
               case ' ':
                   out.append(Sint8(c));
                   break;
   
               default:
                   out.append(Sint8(c));
           }
   
       }
       out << "\"";
   }
  
 inline void _toXml(Array<Sint8>& out, const CIMDateTime& x) inline void _toXml(Array<Sint8>& out, const CIMDateTime& x)
 { {
     out << x.getString();     out << x.getString();
 } }
   inline void _toMof(Array<Sint8>& out, const CIMDateTime& x)
   {
       out << x.getString();
   }
  
 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)
Line 264 
Line 329 
         out << "</VALUE>\n";         out << "</VALUE>\n";
     }     }
 } }
   template<class T>
   void _toMof(Array<Sint8>& out, const T* p, Uint32 size)
   {
       Boolean isFirstEntry = true;
       out << "{";
       while (size--)
       {
           // Put comma on all but first entry.
           if (!isFirstEntry)
           {
               out << ", ";
           }
           isFirstEntry = false;
           _toMof(out, *p++);
       }
       out << "}";
   }
  
 template<class T> template<class T>
 void _toStr(Array<Sint8>& out, const T* p, Uint32 size) void _toStr(Array<Sint8>& out, const T* p, Uint32 size)
Line 306 
Line 388 
  
     _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 757 
Line 840 
         out << "</VALUE>\n";         out << "</VALUE>\n";
     }     }
 } }
   void CIMValue::toMof(Array<Sint8>& out) const    //ATTNKS:
   {
       if (_isArray)
       {
           switch (_type)
           {
               case CIMType::BOOLEAN:
               {
                   for (Uint32 i = 0, n = _u._booleanArray->size; i < n; i++)
                   {
                       _toMof(out, Boolean(_u._booleanArray->data()[i]));
                   }
                   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;
           }
       }
       else if (_type == CIMType::REFERENCE)
       {
           _u._referenceValue->toMof(out);
       }
       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;
           }
       }
   }
  
 void CIMValue::print() const  
   void CIMValue::print(PEGASUS_STD(ostream) &os) const
 { {
     Array<Sint8> tmp;     Array<Sint8> tmp;
     toXml(tmp);     toXml(tmp);
     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)
Line 882 
Line 1099 
     _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 1108 
     _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 1117 
     _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 1126 
     _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 1135 
     _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 1144 
     _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 1153 
     _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 1162 
     _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 1171 
     _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 1180 
     _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 1189 
     _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 1198 
     _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 1207 
     _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 1216 
     _Inc(_u._dateTimeArray = x._rep);     _Inc(_u._dateTimeArray = x._rep);
     _type = CIMType::DATETIME;     _type = CIMType::DATETIME;
     _isArray = true;     _isArray = true;
       _isNull = false;
 } }
  
 void CIMValue::get(Boolean& x) const void CIMValue::get(Boolean& x) const
Line 1224 
Line 1455 
 { {
     _type = CIMType::NONE;     _type = CIMType::NONE;
     _isArray = false;     _isArray = false;
       _isNull = true;
     _u._voidPtr = 0;     _u._voidPtr = 0;
 } }
  
Line 1350 
Line 1582 
  
 void CIMValue::setNullValue(CIMType type, Boolean isArray, Uint32 arraySize) void CIMValue::setNullValue(CIMType type, Boolean isArray, Uint32 arraySize)
 { {
       _isNull = true;
   
     clear();     clear();
  
     if (isArray)     if (isArray)
Line 1554 
Line 1788 
     }     }
     else if (_type == CIMType::REFERENCE)     else if (_type == CIMType::REFERENCE)
     {     {
         // ATTN: work on this:          return _u._referenceValue->toString();
     }     }
     else     else
     {     {


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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2