//%///////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // 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. // //============================================================================== // // Author: Mike Brasher (mbrasher@bmc.com) // // Modified By: Karl schopmeyer (k.schopmeyer@opengroup.org) // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) // //%///////////////////////////////////////////////////////////////////////////// #ifndef Pegasus_Value_h #define Pegasus_Value_h #include #include #include #include #include #include PEGASUS_NAMESPACE_BEGIN /** The CIMValue class represents a value of any of the CIM data types (see CIMType.h for a list of valid CIM data types). This class encapsulates a union which holds the current value. The class also has a type field indicating the type of that value. */ class PEGASUS_COMMON_LINKAGE CIMValue { public: /// Constructor CIMValue(); /// Constructor CIMValue(Boolean x) { _init(); set(x); } /// Constructor CIMValue(Uint8 x) { _init(); set(x); } /// Constructor CIMValue(Sint8 x) { _init(); set(x); } /// Constructor CIMValue(Uint16 x) { _init(); set(x); } /// Constructor CIMValue(Sint16 x) { _init(); set(x); } /// Constructor CIMValue(Uint32 x) { _init(); set(x); } /// Constructor CIMValue(Sint32 x) { _init(); set(x); } /// Constructor CIMValue(Uint64 x) { _init(); set(x); } /// Constructor CIMValue(Sint64 x) { _init(); set(x); } /// Constructor CIMValue(Real32 x) { _init(); set(x); } /// Constructor CIMValue(Real64 x) { _init(); set(x); } /// Constructor CIMValue(const Char16& x) { _init(); set(x); } /// Constructor CIMValue(const String& x) { _init(); set(x); } /// Constructor CIMValue(const char* x) { _init(); set(x); } /// Constructor CIMValue(const CIMDateTime& x) { _init(); set(x); } /// Constructor CIMValue(const CIMReference& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const Array& x) { _init(); set(x); } /// Constructor CIMValue(const CIMValue& x); /// Destructor ~CIMValue(); /// Operator = CIMValue& operator=(const CIMValue& x) { assign(x); return *this; } /** assign - The method to assign one CIMValue object to another CIMValue object. */ void assign(const CIMValue& x); /** clear - Clears the attributes and value of the CIMValue object.
    ATTNDOC:
    
*/ void clear(); /** typeCompatible - Compares the types of two CIMvalues. This compares the type field and the array indicators. @return true if both are of the same type and both are either arrays or not. Else returns false.
            CIMValue a(Boolean(true);
            CIMValue b = a;
            if b.typeCompatible(a)
                ...
        
*/ Boolean typeCompatible(const CIMValue& x) const { return _type == x._type && _isArray == x._isArray; } /** isArray - Determines if the value is an array @return TRUE if the value is an array */ Boolean isArray() const { return _isArray; } /** Returns whether the CIMvalue object is Null. Null is the specific condition where no value has yet been set into the value. If a CIMValue object is Null, any get on that object will create an exception. @return Returns True if the CIMValue object is Null */ Boolean isNull() const { return _isNull; } /** getArraySize = Returns the size of an Array CIMValue @return The number of entries in the array */ Uint32 getArraySize() const; /** getType - Gets the CIMType attribute for the CIMValue. The CIMType is defined in ATTN: @return Returns the CIMType value */ CIMType getType() const { return CIMType(_type); } /** setNullvalue - Sets the CIMType, the Array indicator and if it is the arraytype, the Arraysize of a CIMValue and sets the isNull Attribute. This function is used to set up CIMValues an NULL but with valid CIMType and array characteristics (ex. when update from XML) @param type - The CIMType for this CIMValue @paramisArray - Boolean indicating whether this is an array CIMValue @param arraySize (optional) Uint32parameter indicating the array size @return void */ void setNullValue(CIMType type, Boolean isArray, Uint32 arraySize = 0); /** set - Sets the type, Array attribute and puts the value provided into the value of the target CIMValue. This function sets the CIMValue to nonNull also. All of the CIMTypes defined in ATTN: and the Array types defined in ATTN: may be set. @param x Typed value (ex. Boolean(true). @return void
            CIMValue x;
            x.set(Uint16(9));
        
*/ void set(Boolean x); /// Set void set(Uint8 x); /// void set(Sint8 x); /// void set(Uint16 x); /// void set(Sint16 x); /// void set(Uint32 x); /// void set(Sint32 x); /// void set(Uint64 x); /// void set(Sint64 x); /// void set(Real32 x); /// void set(Real64 x); /// void set(const Char16& x); /// void set(const String& x); /// void set(const char* x); /// void set(const CIMDateTime& x); /// void set(const CIMReference& x); /// void set(const Array& x); /// void set(const Array& x); /// void set(const Array& x); /// void set(const Array& x); /// void set(const Array& x); /// void set(const Array& x); /// void set(const Array& x); /// void set(const Array& x); /// void set(const Array& x); /// void set(const Array& x); /// void set(const Array& x); /// void set(const Array& x); /// void set(const Array& x); /// void set(const Array& x); /// void set(const Array& x); /** get - Gets the value of a CIMValue @param ATTNDOC: @return ATTNDOC: */ void get(Boolean& x) const; /// void get(Uint8& x) const; /// void get(Sint8& x) const; /// void get(Uint16& x) const; /// void get(Sint16& x) const; /// void get(Uint32& x) const; /// void get(Sint32& x) const; /// void get(Uint64& x) const; /// void get(Sint64& x) const; /// void get(Real32& x) const; /// void get(Real64& x) const; /// void get(Char16& x) const; /// void get(String& x) const; /// void get(CIMDateTime& x) const; /// void get(CIMReference& x) const; /// void get(Array& x) const; /// void get(Array& x) const; ////// void get(Array& x) const; /// void get(Array& x) const; /// void get(Array& x) const; /// void get(Array& x) const; /// void get(Array& x) const; /// void get(Array& x) const; /// void get(Array& x) const; /// void get(Array& x) const; /// void get(Array& x) const; /// void get(Array& x) const; /// void get(Array& x) const; /// void get(Array& x) const; /// void get(Array& x) const; /** toXML - Converts a CIMValue object to XML. The XML is appended to the Array provided with the call. Returns the result as an XML element wrapped in the , , , or tags. If the CIMValue is Null, no element is returned. @paramout Sint8 Array to hold the XML representation @return Returns the XML representation of the CIMValue object in the input parameter out. */ void toXml(Array& out) const; /** toXML - Converts a CIMValue object to XML. There is no input parameter and the result is returned as a String rather than appended to an 8-bit array as above. Returns the element as value wrapped in the , , , or tags. If the CIMValue is Null, no element is returned. @return Returns the XML representation of the CIMValue object in String form. */ String toXml() const; /** CIMMethod print - Format and print the Value as XML to std output stream @return None
	Example:
	    CIMValue value(Boolean(true));
	    value.print();	  // Prints "true"
	
*/ void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const; /** toMof - Converts a CIMValueObject to Mof. @out Sint8 Array to hold the Mof representation @return Returns the Mof representation of the CIMValue object in the input parameter out. */ void toMof(Array& out) const; /** toString - Converts the CIMvalue to a string. Should only be used for output purposes. To get an actual String value, use get(String &). @return - String output for CIMValue. @exception - Throws exception CIMValueInvalidType if the CIMValue has an invalid type. Normally this is a Pegasus internal error.
	Example:
	    String test;
	    CIMValue value(Boolean(true));
	    test = value.toString();	  // puts "TRUE" into test
	
*/ String toString() const; private: void _init(); CIMType _type; Boolean _isArray; Boolean _isNull; Union _u; friend class CIMMethodRep; friend class CIMParameterRep; friend class CIMPropertyRep; friend class CIMQualifierRep; friend class CIMQualifierDeclRep; PEGASUS_COMMON_LINKAGE friend Boolean operator==( const CIMValue& x, const CIMValue& y); }; PEGASUS_COMMON_LINKAGE Boolean operator==(const CIMValue& x, const CIMValue& y); inline Boolean operator!=(const CIMValue& x, const CIMValue& y) { return !operator==(x, y); } #define PEGASUS_ARRAY_T CIMValue # include "ArrayInter.h" #undef PEGASUS_ARRAY_T PEGASUS_NAMESPACE_END #endif /* Pegasus_Value_h */