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

  1 mike  1.11 //%/////////////////////////////////////////////////////////////////////////////
  2            //
  3            // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
  4            //
  5            // Permission is hereby granted, free of charge, to any person obtaining a copy
  6            // of this software and associated documentation files (the "Software"), to 
  7            // deal in the Software without restriction, including without limitation the 
  8            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 
  9            // sell copies of the Software, and to permit persons to whom the Software is
 10            // furnished to do so, subject to the following conditions:
 11            // 
 12            // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN 
 13            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 14            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 15            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
 16            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
 17            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
 18            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 19            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 20            //
 21            //==============================================================================
 22 mike  1.11 //
 23            // Author: Mike Brasher (mbrasher@bmc.com)
 24            //
 25            // Modified By:
 26            //
 27            //%/////////////////////////////////////////////////////////////////////////////
 28            
 29            #ifndef Pegasus_Value_h
 30            #define Pegasus_Value_h
 31            
 32            #include <Pegasus/Common/String.h>
 33            #include <Pegasus/Common/Config.h>
 34            #include <Pegasus/Common/CIMType.h>
 35            #include <Pegasus/Common/CIMDateTime.h>
 36            #include <Pegasus/Common/Union.h>
 37            #include <Pegasus/Common/Array.h>
 38            
 39            PEGASUS_NAMESPACE_BEGIN
 40            
 41            /**
 42                The CIMValue class represents a value of any of the CIM data types
 43 mike  1.11     (see CIMType.h for a list of valid CIM data types). This class
 44                encapsulates a union which holds the current value. The class also
 45                has a type field indicating the type of that value.
 46            */
 47            class PEGASUS_COMMON_LINKAGE CIMValue
 48            {
 49            public:
 50                ///	Constructor
 51                CIMValue();
 52            
 53                ///	Constructor
 54                CIMValue(Boolean x) { _init(); set(x); }
 55            
 56                ///	Constructor
 57                CIMValue(Uint8 x) { _init(); set(x); }
 58            
 59                ///	Constructor
 60                CIMValue(Sint8 x) { _init(); set(x); }
 61            
 62                ///	Constructor
 63                CIMValue(Uint16 x) { _init(); set(x); }
 64 mike  1.11 
 65                ///	Constructor
 66                CIMValue(Sint16 x) { _init(); set(x); }
 67            
 68                ///	Constructor
 69                CIMValue(Uint32 x) { _init(); set(x); }
 70            
 71                ///	Constructor
 72                CIMValue(Sint32 x) { _init(); set(x); }
 73            
 74                ///	Constructor
 75                CIMValue(Uint64 x) { _init(); set(x); }
 76            
 77                ///	Constructor
 78                CIMValue(Sint64 x) { _init(); set(x); }
 79            
 80                ///	Constructor
 81                CIMValue(Real32 x) { _init(); set(x); }
 82            
 83                ///	Constructor
 84                CIMValue(Real64 x) { _init(); set(x); }
 85 mike  1.11 
 86                ///	Constructor
 87                CIMValue(const Char16& x) { _init(); set(x); }
 88            
 89                ///	Constructor
 90                CIMValue(const String& x) { _init(); set(x); }
 91            
 92                ///	Constructor
 93                CIMValue(const char* x) { _init(); set(x); }
 94            
 95                ///	Constructor
 96                CIMValue(const CIMDateTime& x) { _init(); set(x); }
 97            
 98                ///	Constructor
 99                CIMValue(const CIMReference& x) { _init(); set(x); }
100            
101                ///	Constructor
102                CIMValue(const Array<Boolean>& x) { _init(); set(x); }
103            
104                ///	Constructor
105                CIMValue(const Array<Uint8>& x) { _init(); set(x); }
106 mike  1.11 
107                ///	Constructor
108                CIMValue(const Array<Sint8>& x) { _init(); set(x); }
109            
110                ///	Constructor
111                CIMValue(const Array<Uint16>& x) { _init(); set(x); }
112            
113                ///	Constructor
114                CIMValue(const Array<Sint16>& x) { _init(); set(x); }
115            
116                ///	Constructor
117                CIMValue(const Array<Uint32>& x) { _init(); set(x); }
118            
119                ///	Constructor
120                CIMValue(const Array<Sint32>& x) { _init(); set(x); }
121            
122                ///	Constructor
123                CIMValue(const Array<Uint64>& x) { _init(); set(x); }
124            
125                ///	Constructor
126                CIMValue(const Array<Sint64>& x) { _init(); set(x); }
127 mike  1.11 
128                ///	Constructor
129                CIMValue(const Array<Real32>& x) { _init(); set(x); }
130            
131                ///	Constructor
132                CIMValue(const Array<Real64>& x) { _init(); set(x); }
133            
134                ///	Constructor
135                CIMValue(const Array<Char16>& x) { _init(); set(x); }
136            
137                ///	Constructor
138                CIMValue(const Array<String>& x) { _init(); set(x); }
139            
140                ///	Constructor
141                CIMValue(const Array<CIMDateTime>& x) { _init(); set(x); }
142            
143                ///	Constructor
144                CIMValue(const CIMValue& x);
145            
146                ///	Destrustructor
147                ~CIMValue();
148 mike  1.11 
149                /// Operator =
150                CIMValue& operator=(const CIMValue& x) 
151                { 
152            	assign(x); return *this; 
153                }
154            
155                /// CIMMethod assign
156                void assign(const CIMValue& x);
157            
158                /// CIMMethod clear
159                void clear();
160            
161                /** CIMMethod typeCompatible - Compares the types of two values.
162            	@return true if compatible.
163                */
164                Boolean typeCompatible(const CIMValue& x) const
165                {
166            	return _type == x._type && _isArray == x._isArray;
167                }
168            
169 mike  1.11     /** CIMMethod isArray - Determines if the value is an array
170            	@return TRUE if the value is an array
171                */
172                Boolean isArray() const { return _isArray; }
173            
174 mike  1.12     /** Returns whether the CIMvalue object is null. 
175            	Null is the specific condition where no value has
176            	yet been set into the value.
177            	If a CIMValue object is Null, any get on that object
178            	will create an exception.
179            	@return Returns True if the CIMValue object is Null
180                */
181                Boolean isNull() const { return _isNull; }
182            
183 mike  1.11     /** CIMMethod getArraySize
184            	@return The number of entries in the array
185                */
186                Uint32 getArraySize() const;
187            
188                CIMType getType() const 
189                { 
190            	return CIMType(_type); 
191                }
192            
193                /// method setNullvalue - ATTN:
194                void setNullValue(CIMType type, Boolean isArray, Uint32 arraySize = 0);
195            
196                /// method set - ATTN:
197                void set(Boolean x);
198            
199                /// CIMMethod Set
200                void set(Uint8 x);
201            
202                void set(Sint8 x);
203            
204 mike  1.11     void set(Uint16 x);
205            
206                void set(Sint16 x);
207            
208                void set(Uint32 x);
209            
210                void set(Sint32 x);
211            
212                void set(Uint64 x);
213            
214                void set(Sint64 x);
215            
216                void set(Real32 x);
217            
218                void set(Real64 x);
219            
220                void set(const Char16& x);
221            
222                void set(const String& x);
223            
224                void set(const char* x);
225 mike  1.11 
226                void set(const CIMDateTime& x);
227            
228                void set(const CIMReference& x);
229            
230                void set(const Array<Boolean>& x);
231            
232                void set(const Array<Uint8>& x);
233            
234                void set(const Array<Sint8>& x);
235            
236                void set(const Array<Uint16>& x);
237            
238                void set(const Array<Sint16>& x);
239            
240                void set(const Array<Uint32>& x);
241            
242                void set(const Array<Sint32>& x);
243            
244                void set(const Array<Uint64>& x);
245            
246 mike  1.11     void set(const Array<Sint64>& x);
247            
248                void set(const Array<Real32>& x);
249            
250                void set(const Array<Real64>& x);
251            
252                void set(const Array<Char16>& x);
253            
254                void set(const Array<String>& x);
255            
256                void set(const Array<CIMDateTime>& x);
257            
258                /// CIMMethod get - ATTN
259                void get(Boolean& x) const;
260            
261                void get(Uint8& x) const;
262            
263                void get(Sint8& x) const;
264            
265                void get(Uint16& x) const;
266            
267 mike  1.11     void get(Sint16& x) const;
268            
269                void get(Uint32& x) const;
270            
271                void get(Sint32& x) const;
272            
273                void get(Uint64& x) const;
274            
275                void get(Sint64& x) const;
276            
277                void get(Real32& x) const;
278            
279                void get(Real64& x) const;
280            
281                void get(Char16& x) const;
282            
283                void get(String& x) const;
284            
285                void get(CIMDateTime& x) const;
286            
287                void get(CIMReference& x) const;
288 mike  1.11 
289                void get(Array<Boolean>& x) const;
290            
291                void get(Array<Uint8>& x) const;
292            
293                void get(Array<Sint8>& x) const;
294            
295                void get(Array<Uint16>& x) const;
296            
297                void get(Array<Sint16>& x) const;
298            
299                void get(Array<Uint32>& x) const;
300            
301                void get(Array<Sint32>& x) const;
302            
303                void get(Array<Uint64>& x) const;
304            
305                void get(Array<Sint64>& x) const;
306            
307                void get(Array<Real32>& x) const;
308            
309 mike  1.11     void get(Array<Real64>& x) const;
310            
311                void get(Array<Char16>& x) const;
312            
313                void get(Array<String>& x) const;
314            
315                void get(Array<CIMDateTime>& x) const; 
316            
317 mike  1.12     /** toXML - Converts a CIMValue object to XML.
318            	@out Sint8 Array to hold the XML representation
319            	@return Returns the XML representation of the CIMValue
320            	object in the input parameter out. 
321 mike  1.11     */
322                void toXml(Array<Sint8>& out) const;
323            
324 mike  1.12     /** toXML - Converts a CIMValue object to XML.
325            	@return Returns the XML representation of the CIMValue
326            	object in String form.
327                */
328                String toXml() const;
329            
330 mike  1.11     /** CIMMethod print - Format and print the Value to std output
331                	stream
332            	@return None
333            	<PRE>
334            	Example:
335            	    CIMValue value(Boolean(true));
336            	    value.print();	  // Prints "true"
337            	</PRE> 
338                */
339                void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const;
340            
341 mike  1.12     /** toMof - Converts a CIMValueObject to Mof.
342            	@out Sint8 Array to hold the Mof representation
343            	@return Returns the Mof representation of the CIMValue
344            	object in the input parameter out. 
345                */
346                void toMof(Array<Sint8>& out) const;
347            
348            
349                /** toString - Converts the CIMvalue to a string.  Should only be
350                        used for output purposes.  To get an actual String value, use
351                        get(String &).
352 mike  1.11 	@return - String output for CIMValue.
353            	<PRE>
354            	Example:
355            	    String test;
356            	    CIMValue value(Boolean(true));
357 mike  1.12 	    test = value.toString();	  // puts "TRUE" into test
358 mike  1.11 	</PRE>
359            	*/
360                String toString() const;
361            
362            private:
363            
364                void _init();
365            
366                CIMType _type;
367                Boolean _isArray;
368 mike  1.12     Boolean _isNull;
369 mike  1.11     Union _u;
370            
371                friend class CIMMethodRep;
372                friend class CIMParameterRep;
373                friend class CIMPropertyRep;
374                friend class CIMQualifierRep;
375                friend class CIMQualifierDeclRep;
376                PEGASUS_COMMON_LINKAGE friend Boolean operator==(
377            	const CIMValue& x, 
378            	const CIMValue& y);
379            };
380            
381            PEGASUS_COMMON_LINKAGE Boolean operator==(const CIMValue& x, const CIMValue& y);
382            
383            inline Boolean operator!=(const CIMValue& x, const CIMValue& y)
384            {
385                return !operator==(x, y);
386            }
387            
388            #define PEGASUS_ARRAY_T CIMValue
389            # include "ArrayInter.h"
390 mike  1.11 #undef PEGASUS_ARRAY_T
391            
392            PEGASUS_NAMESPACE_END
393            
394            #endif /* Pegasus_Value_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2