OWBI1_WQLOperand.hpp

Go to the documentation of this file.
00001 
00002 //
00003 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
00004 // The Open Group, Tivoli Systems, Vintela, Inc..
00005 //
00006 // Permission is hereby granted, free of charge, to any person obtaining a copy
00007 // of this software and associated documentation files (the "Software"), to
00008 // deal in the Software without restriction, including without limitation the
00009 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00010 // sell copies of the Software, and to permit persons to whom the Software is
00011 // furnished to do so, subject to the following conditions:
00012 // 
00013 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
00014 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
00015 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
00016 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
00017 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00018 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
00019 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00020 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00021 //
00022 //==============================================================================
00023 //
00024 // Author: Mike Brasher (mbrasher@bmc.com)
00025 //
00026 // Modified By: Dan Nuffer
00027 //
00029 #ifndef OWBI1_WQL_OPERAND_HPP_INCLUDE_GUARD_
00030 #define OWBI1_WQL_OPERAND_HPP_INCLUDE_GUARD_
00031 #include "OWBI1_config.h"
00032 #include "OWBI1_Types.hpp"
00033 #include "OWBI1_String.hpp"
00034 #include "OWBI1_Exception.hpp"
00035 
00036 namespace OWBI1
00037 {
00038 
00039 OWBI1_DECLARE_APIEXCEPTION(TypeMismatch, OWBI1_WQLCOMMON_API)
00043 enum WQLIntegerValueTag 
00044 { 
00045    WQL_INTEGER_VALUE_TAG 
00046 };
00050 enum WQLDoubleValueTag 
00051 { 
00052    WQL_DOUBLE_VALUE_TAG 
00053 };
00057 enum WQLBoolValueTag 
00058 { 
00059    WQL_BOOLEAN_VALUE_TAG 
00060 };
00064 enum WQLStringValueTag 
00065 { 
00066    WQL_STRING_VALUE_TAG 
00067 };
00071 enum WQLPropertyNameTag 
00072 { 
00073    WQL_PROPERTY_NAME_TAG 
00074 };
00106 class OWBI1_OWBI1PROVIFC_API WQLOperand
00107 {
00108 public:
00112    enum Type
00113    {
00114       NULL_VALUE,
00115       INTEGER_VALUE,
00116       DOUBLE_VALUE,
00117       BOOLEAN_VALUE,
00118       STRING_VALUE,
00119       PROPERTY_NAME
00120    };
00123    WQLOperand()
00124       : _type(NULL_VALUE) 
00125    {
00126    }
00129    WQLOperand(Int64 x, WQLIntegerValueTag)
00130       : _integerValue(x)
00131       , _type(INTEGER_VALUE)
00132    {
00133    }
00136    WQLOperand(Real64 x, WQLDoubleValueTag)
00137       : _doubleValue(x)
00138       , _type(DOUBLE_VALUE)
00139    {
00140    }
00143    WQLOperand(bool x, WQLBoolValueTag)
00144       : _booleanValue(x)
00145       , _type(BOOLEAN_VALUE)
00146    {
00147    }
00150    WQLOperand(const String& x, WQLStringValueTag)
00151       : _string(x)
00152       , _type(STRING_VALUE)
00153    {
00154    }
00157    WQLOperand(const String& x, WQLPropertyNameTag)
00158       : _string(x)
00159       , _type(PROPERTY_NAME)
00160    {
00161    }
00164    Type getType() const { return _type; }
00167    void setIntegerValue(Int32 x)
00168    {
00169       _integerValue = x;
00170       _type = INTEGER_VALUE;
00171    }
00174    void setDoubleValue(Real64 x)
00175    {
00176       _doubleValue = x;
00177       _type = DOUBLE_VALUE;
00178    }
00181    void setBoolValue(bool x)
00182    {
00183       _booleanValue = x;
00184       _type = BOOLEAN_VALUE;
00185    }
00188    void setStringValue(const String& x)
00189    {
00190       _string = x;
00191       _type = STRING_VALUE;
00192    }
00195    void setPropertyName(const String& x)
00196    {
00197       _string = x;
00198       _type = PROPERTY_NAME;
00199    }
00202    Int64 getIntegerValue() const
00203    {
00204       if (_type != INTEGER_VALUE)
00205          OWBI1_THROW(TypeMismatchException, "Type mismatch");
00206       return _integerValue;
00207    }
00211    Real64 getDoubleValue() const
00212    {
00213       if (_type != DOUBLE_VALUE)
00214          OWBI1_THROW(TypeMismatchException, "Type mismatch");
00215       return _doubleValue;
00216    }
00220    bool getBooleanValue() const
00221    {
00222       if (_type != BOOLEAN_VALUE)
00223          OWBI1_THROW(TypeMismatchException, "Type mismatch");
00224       return _booleanValue;
00225    }
00229    const String& getStringValue() const
00230    {
00231       if (_type != STRING_VALUE)
00232          OWBI1_THROW(TypeMismatchException, "Type mismatch");
00233       return _string;
00234    }
00238    const String& getPropertyName() const
00239    {
00240       if (_type != PROPERTY_NAME)
00241          OWBI1_THROW(TypeMismatchException, "Type mismatch");
00242       return _string;
00243    }
00246    String toString() const;
00247 private:
00248    union
00249    {
00250       Int64 _integerValue;
00251       Real64 _doubleValue;
00252       bool _booleanValue;
00253    };
00254    String _string;
00255    Type _type;
00256 };
00257 OWBI1_OWBI1PROVIFC_API bool operator==(const WQLOperand& x, const WQLOperand& y);
00258 
00259 } // end namespace OWBI1
00260 
00261 #endif

Generated on Thu Feb 9 08:48:29 2006 for openwbem by  doxygen 1.4.6