OWBI1_WQLOperand.cpp

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
00005 // Portions Copyright (C) 2003-2004 Vintela, Inc. All rights reserved.
00006 //
00007 // Permission is hereby granted, free of charge, to any person obtaining a copy
00008 // of this software and associated documentation files (the "Software"), to
00009 // deal in the Software without restriction, including without limitation the
00010 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00011 // sell copies of the Software, and to permit persons to whom the Software is
00012 // furnished to do so, subject to the following conditions:
00013 // 
00014 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
00015 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
00016 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
00017 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
00018 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00019 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
00020 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00021 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00022 //
00023 //==============================================================================
00024 //
00025 // Author: Mike Brasher (mbrasher@bmc.com)
00026 //
00027 // Modified By: Dan Nuffer
00028 //
00029 //%/////////////////////////////////////////////////////////////////////////////
00030 #include "OWBI1_config.h"
00031 #include "OWBI1_WQLOperand.hpp"
00032 #include "OWBI1_StringBuffer.hpp"
00033 #include "OW_ExceptionIds.hpp"
00034 
00035 namespace OWBI1
00036 {
00037 
00038 using namespace OpenWBEM;
00039 OWBI1_DEFINE_EXCEPTION_WITH_ID(TypeMismatch);
00040 String WQLOperand::toString() const
00041 {
00042    StringBuffer result;
00043    switch (_type)
00044    {
00045    case PROPERTY_NAME:
00046       {
00047          result = "PROPERTY_NAME: ";
00048          result += _string;
00049          break;
00050       }
00051    case STRING_VALUE:
00052       {
00053          result = "STRING_VALUE: ";
00054          result += _string;
00055          break;
00056       }
00057    case INTEGER_VALUE:
00058       {
00059          result = "INTEGER_VALUE: ";
00060          result += _integerValue;
00061          break;
00062       }
00063    case DOUBLE_VALUE:
00064       {
00065          result = "DOUBLE_VALUE: ";
00066          result += _doubleValue;
00067          break;
00068       } 
00069    case BOOLEAN_VALUE:
00070       {
00071          result = "BOOLEAN_VALUE: ";
00072          if (_booleanValue)
00073          {
00074             result += "TRUE";
00075          }
00076          else
00077          {
00078             result += "FALSE";
00079          }
00080          break;
00081       }
00082    default:
00083       result = "NULL_VALUE";
00084       break;
00085    }
00086    return result.releaseString();
00087 }
00088 bool operator==(const WQLOperand& x, const WQLOperand& y)
00089 {
00090    if (x.getType() != y.getType())
00091    {
00092       return false;
00093    }
00094    switch (x.getType())
00095    {
00096       case WQLOperand::NULL_VALUE:
00097          return true;
00098       case WQLOperand::INTEGER_VALUE:
00099          return x.getIntegerValue() == y.getIntegerValue();
00100       case WQLOperand::DOUBLE_VALUE:
00101          return x.getDoubleValue() == y.getDoubleValue();
00102       case WQLOperand::BOOLEAN_VALUE:
00103          return x.getBooleanValue() == y.getBooleanValue();
00104       case WQLOperand::STRING_VALUE:
00105          return x.getStringValue() == y.getStringValue();
00106       case WQLOperand::PROPERTY_NAME:
00107          return x.getPropertyName() == y.getPropertyName();
00108    }
00109    return false;
00110 }
00111 
00112 } // end namespace OWBI1
00113 

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