OW_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 "OW_config.h"
00031 #include "OW_WQLOperand.hpp"
00032 #include "OW_StringBuffer.hpp"
00033 #include "OW_ExceptionIds.hpp"
00034 
00035 namespace OW_NAMESPACE
00036 {
00037 
00038 OW_DEFINE_EXCEPTION_WITH_ID(TypeMismatch);
00039 String WQLOperand::toString() const
00040 {
00041    StringBuffer result;
00042    switch (_type)
00043    {
00044    case PROPERTY_NAME:
00045       {
00046          result = "PROPERTY_NAME: ";
00047          result += _string;
00048          break;
00049       }
00050    case STRING_VALUE:
00051       {
00052          result = "STRING_VALUE: ";
00053          result += _string;
00054          break;
00055       }
00056    case INTEGER_VALUE:
00057       {
00058          result = "INTEGER_VALUE: ";
00059          result += _integerValue;
00060          break;
00061       }
00062    case DOUBLE_VALUE:
00063       {
00064          result = "DOUBLE_VALUE: ";
00065          result += _doubleValue;
00066          break;
00067       } 
00068    case BOOLEAN_VALUE:
00069       {
00070          result = "BOOLEAN_VALUE: ";
00071          if (_booleanValue)
00072          {
00073             result += "TRUE";
00074          }
00075          else
00076          {
00077             result += "FALSE";
00078          }
00079          break;
00080       }
00081    default:
00082       result = "NULL_VALUE";
00083       break;
00084    }
00085    return result.releaseString();
00086 }
00087 bool operator==(const WQLOperand& x, const WQLOperand& y)
00088 {
00089    if (x.getType() != y.getType())
00090    {
00091       return false;
00092    }
00093    switch (x.getType())
00094    {
00095       case WQLOperand::NULL_VALUE:
00096          return true;
00097       case WQLOperand::INTEGER_VALUE:
00098          return x.getIntegerValue() == y.getIntegerValue();
00099       case WQLOperand::DOUBLE_VALUE:
00100          return x.getDoubleValue() == y.getDoubleValue();
00101       case WQLOperand::BOOLEAN_VALUE:
00102          return x.getBooleanValue() == y.getBooleanValue();
00103       case WQLOperand::STRING_VALUE:
00104          return x.getStringValue() == y.getStringValue();
00105       case WQLOperand::PROPERTY_NAME:
00106          return x.getPropertyName() == y.getPropertyName();
00107    }
00108    return false;
00109 }
00110 
00111 } // end namespace OW_NAMESPACE
00112 

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